Bug #51520 [Opn->Csd]: strict-parameter of array_search() and object-identity
| From: | degeberg@php.net | Date: | Fri, 09 Apr 2010 14:04:32 +0000 |
| Subject: | Bug #51520 [Opn->Csd]: strict-parameter of array_search() and object-identity | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-4183@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51520&edit=1
ID: 51520
Updated by: degeberg@php.net
Reported by: r dot wilczek at web-appz dot de
Summary: strict-parameter of array_search() and object-identity
-Status: Open
+Status: Closed
Type: Bug
Package: Documentation problem
Operating System: Linux
PHP Version: 5.3.2
-Assigned To:
+Assigned To: degeberg
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Previous Comments:
------------------------------------------------------------------------
[2010-04-09 16:04:23] degeberg@php.net
Automatic comment from SVN on behalf of degeberg
Revision: http://svn.php.net/viewvc/?view=revision&revision=297745
Log: Fixed PHP bug #51520 (strict-parameter of array_search() and
object-identity)
------------------------------------------------------------------------
[2010-04-09 15:53:35] r dot wilczek at web-appz dot de
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 this bug report at http://bugs.php.net/bug.php?id=51520&edit=1