Bug #51520 [NEW]: strict-parameter of array_search() and object-identity

From: Date: Fri, 09 Apr 2010 13:53:35 +0000
Subject: Bug #51520 [NEW]: strict-parameter of array_search() and object-identity
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-4182@lists.php.net to get a copy of this message
From: Operating system: Linux PHP version: 5.3.2 Package: Documentation problem Bug Type: Bug Bug description:strict-parameter of array_search() and object-identity Description: ------------ Documentation for array_search() says: "If the third parameter strict is set to TRUE then the array_search() function will also check the types of the needle in the haystack." But: if the array contains objects, setting the strict-parameter to TRUE will check for object-identity, not only for equality of type and value. If the comparison would check for equality of type and value only, the strict variant would output int(0) in the example below, for $foo and $bar do not differ in type or value. I suggest to supplement the documentation. Test script: --------------- $foo = new stdClass; $foo->foo = 'a'; $bar = clone $foo; var_dump(array_search($bar, array($foo))); var_dump(array_search($bar, array($foo), true)); Expected result: ---------------- If the documentation is right (and array_search() has a bug): int(0) int(0) If the documentation is wrong (and array_search() currently works as expected): int(0) bool(false) Actual result: -------------- int(0) bool(false) -- Edit bug report at http://bugs.php.net/bug.php?id=51520&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51520&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51520&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51520&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=51520&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51520&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=51520&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=51520&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=51520&r=needscript Try newer version: http://bugs.php.net/fix.php?id=51520&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=51520&r=support Expected behavior: http://bugs.php.net/fix.php?id=51520&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=51520&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=51520&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=51520&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51520&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=51520&r=dst IIS Stability: http://bugs.php.net/fix.php?id=51520&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=51520&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=51520&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=51520&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=51520&r=mysqlcfg

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