From:             killgec at gmail dot com
Operating system: winXp
PHP version:      5.2.3
PHP Bug Type:     SPL related
Bug description:  ArrayObject::getArrayCopy() gives strange results

Description:
------------
ArrayObject::getArrayCopy() returns not only public properties of an
object, but private and protected properties, too. These last two have
strange "inner-style" keys with illegal characters. 

Documentation says that ArrayObject::getArrayCopy() returns array created
of public properties:
http://www.php.net/~helly/php/ext/spl/classArrayObject.html

Reproduce code:
---------------
class A {
        public $a = 1;
        protected $b = 2;
        private $c = 3;
        
}

$a = new A();
$ao = new ArrayObject($a);
print_R($ao->getArrayCopy());
var_dump((array)$ao);

Expected result:
----------------
Array
(
    [a] => 1
)
array(3) {
  ["a"]=>
  int(1)
}

Actual result:
--------------
Array
(
    [a] => 1
    [< 1 illegal character here>*< 1 illegal character here>b] => 2
    [< 1 illegal character here>A< 1 illegal character here>c] => 3
)
array(3) {
  ["a"]=>
  int(1)
  ["< 1 illegal character here>*< 1 illegal character here>b"]=>
  int(2)
  ["< 1 illegal character here>A< 1 illegal character here>c"]=>
  int(3)
}

literally:

Array
(
    [a] => 1
    [&#65533;*&#65533;b] => 2
    [&#65533;A&#65533;c] => 3
)
array(3) {
  ["a"]=>
  int(1)
  ["&#65533;*&#65533;b"]=>
  int(2)
  ["&#65533;A&#65533;c"]=>
  int(3)
}

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

Reply via email to