#26010 [Ver]: Bug on get_object_vars() function

From: Date: Mon, 03 Nov 2003 20:53:39 +0000
Subject: #26010 [Ver]: Bug on get_object_vars() function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-49906@lists.php.net to get a copy of this message
ID: 26010 Updated by: andrew@php.net Reported By: rodrigo at intelligencegroup dot com dot br Status: Verified Bug Type: Zend Engine 2 problem Operating System: Linux (redhat 9) PHP Version: 5CVS-2003-10-28 (dev) New Comment: Correct me if i'm wrong, but isn't the purpose of the PPP elements to prevent this behavior? As i see it, this is the clearly an intended response of attempting to access the variables externally. Like i said, i may be wrong... ~ Andrew Heebner Previous Comments: ------------------------------------------------------------------------ [2003-11-01 17:29:32] schlueter at phpbar dot de This bug also appears when var_dump'ing an object - without using get_object_vars() with Beta2. (With print_r() I get the property names where private and public ones are marked - that's even nicer than just the name.) Reproduce code: --------------- <?php class foo { private $bar1 = 'foobar1'; protected $bar2 = 'foobar2'; public $bar3 = 'foobar3'; } $foo = new foo(); var_dump($foo); Expected result: ---------------- object(foo)#2 (3) { ["bar1"]=> string(6) "foobar1" ["bar2"]=> string(6) "foobar2" ["bar3"]=> string(6) "foobar3" } Actual result: -------------- object(foo)#2 (3) { [""]=> string(6) "foobar1" [""]=> string(6) "foobar2" ["bar3"]=> string(6) "foobar3" } ------------------------------------------------------------------------ [2003-10-29 13:34:24] moriyoshi@php.net Verified. Refraining from adding a test case till beta2 roll-up. ------------------------------------------------------------------------ [2003-10-27 15:27:11] rodrigo at intelligencegroup dot com dot br Description: ------------ The function get_object_vars() is getting back an array where public variables is ok, but private variables is being defined with no key. Reproduce code: --------------- <? class A { private $a; public $b; public function A() { $this->a = "value of a"; $this->b = "value of b"; } } $data = new A(); $objVars = get_object_vars($data); var_dump($objVars); ?> Expected result: ---------------- array(2) { ["a"]=> string(10) "value of a" ["b"]=> string(10) "value of b" } Actual result: -------------- array(2) { [""]=> string(10) "value of a" ["b"]=> string(10) "value of b" } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26010&edit=1

« previous php.bugs (#49906) next »