#41678 [Opn->Bgs]: ArrayObject::getArrayCopy() gives strange results
| From: | helly@php.net | Date: | Fri, 15 Jun 2007 21:15:25 +0000 |
| Subject: | #41678 [Opn->Bgs]: ArrayObject::getArrayCopy() gives strange results | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-113842@lists.php.net to get a copy of this message | ||
ID: 41678
Updated by: helly@php.net
Reported By: killgec at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: SPL related
-Operating System: winXp
+Operating System: *
PHP Version: 5.2.3
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
These strange chars are actually zero's. And that is simply the way PHP
encodes public and protected member variables.
Previous Comments:
------------------------------------------------------------------------
[2007-06-13 12:10:31] killgec at gmail dot com
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
[�*�b] => 2
[�A�c] => 3
)
array(3) {
["a"]=>
int(1)
["�*�b"]=>
int(2)
["�A�c"]=>
int(3)
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41678&edit=1