From:             robin_fernandes at uk dot ibm dot com
Operating system: Windows
PHP version:      5.2CVS-2008-07-22 (snap)
PHP Bug Type:     SPL related
Bug description:  ArrayObject::STD_PROP_LIST does not behave as documented with 
foreach

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 bug report at http://bugs.php.net/?id=45595&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45595&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45595&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45595&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45595&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=45595&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45595&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45595&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45595&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45595&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45595&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=45595&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=45595&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45595&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45595&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45595&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45595&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45595&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45595&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45595&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45595&r=mysqlcfg

Reply via email to