Doc #60688 [NEW]: Array comparison documentation inconsistency

From: Date: Sun, 08 Jan 2012 23:48:34 +0000
Subject: Doc #60688 [NEW]: Array comparison documentation inconsistency
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-7753@lists.php.net to get a copy of this message
From: Operating system: Debian PHP version: 5.3.8 Package: Documentation problem Bug Type: Documentation Problem Bug description:Array comparison documentation inconsistency 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 bug report at https://bugs.php.net/bug.php?id=60688&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60688&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60688&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60688&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=60688&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60688&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=60688&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=60688&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=60688&r=needscript Try newer version: https://bugs.php.net/fix.php?id=60688&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=60688&r=support Expected behavior: https://bugs.php.net/fix.php?id=60688&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=60688&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=60688&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=60688&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60688&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=60688&r=dst IIS Stability: https://bugs.php.net/fix.php?id=60688&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=60688&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=60688&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=60688&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=60688&r=mysqlcfg

« previous php.doc.bugs (#7753) next »