Doc #60688 [Opn->Fbk]: Array comparison documentation inconsistency
| From: | frozenfire@php.net | Date: | Tue, 24 Jan 2012 23:04:06 +0000 |
| Subject: | Doc #60688 [Opn->Fbk]: Array comparison documentation inconsistency | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-7854@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60688&edit=1
ID: 60688
Updated by: frozenfire@php.net
Reported by: wolfgang dot stengel at gmx dot de
Summary: Array comparison documentation inconsistency
-Status: Open
+Status: Feedback
Type: Documentation Problem
Package: Documentation problem
Operating System: Debian
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
I'm not seeing how this minor engine quirk produces a distinguishable effect upon
the result of the operation. Could you provide a test script which demonstrates
that different results will be produced based on a different invocation?
Previous Comments:
------------------------------------------------------------------------
[2012-01-08 23:48:34] wolfgang dot stengel at gmx dot de
Description:
------------
Comparing arrays is in the PHP manual described as "Array with fewer members is
smaller, if key from operand 1 is not found in operand 2 then arrays are
uncomparable, otherwise - compare value by value (see following example)"
(http://www.php.net/manual/en/language.operators.comparison.php).
This does not mention that the order in which the operands are compared is
reversed with the > and >= operators (I think). I found this in
zend_language_parser.y:
T_IS_GREATER_OR_EQUAL expr { zend_do_binary_op(ZEND_IS_SMALLER_OR_EQUAL, &$$, &$3,
&$1 TSRMLS_CC); }
This will lead to the foreach in the transcription of the comparison code
iterating over $b instead of $a in the example below.
Test script:
---------------
$a=array(0 => 2, 'test' => 2);
$b=array('test' => 3, 0 => 1);
var_dump($a>$b);
Expected result:
----------------
The documentation should mention that the > and >= operators flip the arguments.
Actual result:
--------------
The documentation does not mention that the > and >= operators flip the arguments.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60688&edit=1