php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
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 commitsRelated reports
 [2010-12-11 00:58 UTC] 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-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
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 15 10:01:27 2024 UTC