ID: 45595 Updated by: [EMAIL PROTECTED] Reported By: robin_fernandes at uk dot ibm dot com -Status: Open +Status: Assigned Bug Type: SPL related -Operating System: Windows +Operating System: * PHP Version: 5.2CVS-2008-07-22 (snap) -Assigned To: +Assigned To: helly New Comment:
Assigned to the SPL maintainer. Previous Comments: ------------------------------------------------------------------------ [2008-07-22 17:02:41] robin_fernandes at uk dot ibm dot com Description: ------------ The SPL documentation states that if the ArrayObject::STD_PROP_LIST flag is set on an ArrayObject instance: "Properties of the object have their normal functionality when accessed as list (var_dump, foreach, etc.)" (see http://www.php.net/~helly/php/ext/spl/classArrayObject.html#daebe26f8478746da33c266a730714a9 ) This flag does affect var_dump(), but it seems to have no impact on foreach. See reproduce code. I'm not sure whether this is a functional problem or a documentation problem. Reproduce code: --------------- <?php // ArrayObject::STD_PROP_LIST: // Properties of the object have their normal functionality when accessed as list (var_dump, foreach, etc.) echo "Create instance of ArrayObject and add some normal properties...\n"; $ao = new ArrayObject(array('x', 'y', 'z'), ArrayObject::STD_PROP_LIST); $ao->p1 = 1; $ao->p2 = 2; $ao->p3 = 3; echo "\nGet property list with var_dump:\n"; var_dump($ao); echo "\nGet property list with foreach:\n"; foreach ($ao as $key=>$value) { echo " $key=>$value\n"; } ?> Expected result: ---------------- Create instance of ArrayObject and add some normal properties... Get property list with var_dump: object(ArrayObject)#1 (3) { ["p1"]=> int(1) ["p2"]=> int(2) ["p3"]=> int(3) } Get property list with foreach: p1=>1 p2=>2 p3=>3 Actual result: -------------- Create instance of ArrayObject and add some normal properties... Get property list with var_dump: object(ArrayObject)#1 (3) { ["p1"]=> int(1) ["p2"]=> int(2) ["p3"]=> int(3) } Get property list with foreach: 0=>x 1=>y 2=>z ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45595&edit=1
