mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 08:28:54 +00:00
Fix bug #67034: Unable to compare DateInterval instances with == operator
Closes GH-1590.
This commit is contained in:
parent
9ed2d17d58
commit
3d9dad29c7
2 changed files with 24 additions and 2 deletions
|
@ -1685,7 +1685,7 @@ echo $a <=> $b; // 1
|
|||
<entry><type>object</type></entry>
|
||||
<entry><type>object</type></entry>
|
||||
<entry>Built-in classes can define its own comparison, different classes
|
||||
are uncomparable, same class see <link
|
||||
are incomparable, same class see <link
|
||||
linkend="language.oop5.object-comparison">Object Comparison</link>
|
||||
</entry>
|
||||
</row>
|
||||
|
@ -1698,7 +1698,7 @@ echo $a <=> $b; // 1
|
|||
<entry><type>array</type></entry>
|
||||
<entry><type>array</type></entry>
|
||||
<entry>Array with fewer members is smaller, if key from operand 1 is not
|
||||
found in operand 2 then arrays are uncomparable, otherwise - compare
|
||||
found in operand 2 then arrays are incomparable, otherwise - compare
|
||||
value by value (see following example)</entry>
|
||||
</row>
|
||||
<row>
|
||||
|
@ -1786,6 +1786,16 @@ function standard_array_compare($op1, $op2)
|
|||
</simpara>
|
||||
</note>
|
||||
|
||||
<sect2 xml:id="language.operators.comparison.incomparable">
|
||||
<title>Incomparable Values</title>
|
||||
<simpara>
|
||||
While identity comparison (<literal>===</literal> and <literal>!==</literal>)
|
||||
can be applied to arbitrary values, the other comparison operators should only be
|
||||
applied to comparable values. The result of comparing incomparable values is
|
||||
undefined, and should not be relied upon.
|
||||
</simpara>
|
||||
</sect2>
|
||||
|
||||
<sect2 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
|
|
|
@ -28,6 +28,11 @@
|
|||
is by calculating the difference between two date/time objects through
|
||||
<function>DateTimeInterface::diff</function>.
|
||||
</para>
|
||||
<para>
|
||||
Since there is no well defined way to compare date intervals,
|
||||
<classname>DateInterval</classname> instances are
|
||||
<link linkend="language.operators.comparison.incomparable">incomparable</link>.
|
||||
</para>
|
||||
</section>
|
||||
<!-- }}} -->
|
||||
|
||||
|
@ -201,6 +206,13 @@
|
|||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>7.4.0</entry>
|
||||
<entry>
|
||||
<classname>DateInterval</classname> instances are incomparable now;
|
||||
previously, all <classname>DateInterval</classname> instances were considered equal.
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>7.1.0</entry>
|
||||
<entry>The <varname>f</varname> property was added.</entry>
|
||||
|
|
Loading…
Reference in a new issue