property_exists incorrect on ArrayObject null and 0 values
| Bug #53515 | property_exists incorrect on ArrayObject null and 0 values | ||||
|---|---|---|---|---|---|
| Submitted: | 2010-12-10 10:32 UTC | Modified: | 2010-12-11 00:58 UTC | ||
| From: | mjong at magnafacta dot nl | Assigned: | felipe (profile) | ||
| Status: | Closed | Package: | SPL related | ||
| PHP Version: | 5.3.4 | OS: | Linux / Windows | ||
| Private report: | No | CVE-ID: | None | ||
[2010-12-10 10:32 UTC] 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
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2010-12-11 00:58 UTC] felipe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: felipe
[2010-12-11 00:58 UTC] felipe@php.net