Bug #53515 [Opn->Csd]: property_exists incorrect on ArrayObject null and 0 values
Edit report at http://bugs.php.net/bug.php?id=53515&edit=1
ID: 53515
Updated by: felipe@php.net
Reported by: mjong at magnafacta dot nl
Summary: property_exists incorrect on ArrayObject null and 0
values
-Status: Open
+Status: Closed
Type: Bug
Package: SPL related
Operating System: Linux / Windows
PHP Version: 5.3.4
-Assigned To:
+Assigned To: felipe
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2010-12-11 00:58:34] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=306213
Log: - Fixed bug #53515 (property_exists incorrect on ArrayObject null
and 0 values)
------------------------------------------------------------------------
[2010-12-10 10:32:55] mjong at magnafacta dot nl
Description:
------------
Calling property_exists() on an ArrayObject gives a false result on when
the value
is a false value. This is not in compliance with the description of
property_exists().
I tried this on PHP 5.3.2 and 5.3.3 under both Linux + Apache and
Windows + IIS.
Test script:
---------------
$a = array('a' => 1, 'b'=> true, 'c' => 0, 'd'
=> null, 'e' => false,
'f' => array());
$o = new ArrayObject($a, ArrayObject::ARRAY_AS_PROPS);
foreach ($a as $key => $value) {
echo $key . ': ' . (is_null($value) ? 'null' : $value) .
' array_key_exists: ' . (array_key_exists($key, $a) ? 'true' :
'false') .
' property_exists: ' . (property_exists($o, $key) ? 'true' :
'false');
}
Expected result:
----------------
a: 1 array_key_exists: true property_exists: true
b: 1 array_key_exists: true property_exists: true
c: 0 array_key_exists: true property_exists: true
d: null array_key_exists: true property_exists: true
e: array_key_exists: true property_exists: true
f: Array array_key_exists: true property_exists: true
Actual result:
--------------
a: 1 array_key_exists: true property_exists: true
b: 1 array_key_exists: true property_exists: true
c: 0 array_key_exists: true property_exists: false
d: null array_key_exists: true property_exists: false
e: array_key_exists: true property_exists: false
f: Array array_key_exists: true property_exists: false
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53515&edit=1
Thread (2 messages)