ID:               36693
 Comment by:       nacho at ziggo dot nl
 Reported By:      iain at iaindooley dot com
 Status:           No Feedback
 Bug Type:         Class/Object related
 Operating System: FreeBSD 6.0
 PHP Version:      5.1.2
 New Comment:

Description:
------------
This seems to be broken again on version 5.3.1 (Debian/Apache)

Reproduce code:
---------------
<?php
class Foo {

        private $a = 'a';

        public $b = 'b';

        protected $c = 'c';

        public function __construct() {}

        public function Export() {

                $vars = get_object_vars($this);

                return $vars;

        }

}

class Bar extends Foo {

        private $d = 'd';

        public $e = 'e';

        protected $f = 'f';

}

$foo = new Foo();
$bar = new Bar();

var_dump($foo->Export());
var_dump($bar->Export());
?>

Expected result:
----------------
array(3) {
  ["a"]=>
  string(1) "a"
  ["b"]=>
  string(1) "b"
  ["c"]=>
  string(1) "c"
}
array(5) {
  ["d"]=>
  string(1) "d"
  ["e"]=>
  string(1) "e"
  ["f"]=>
  string(1) "f"
  ["a"]=>
  string(1) "a"
  ["b"]=>
  string(1) "b"
  ["c"]=>
  string(1) "c"
}

Actual result:
--------------
array(3) {
  ["a"]=>
  string(1) "a"
  ["b"]=>
  string(1) "b"
  ["c"]=>
  string(1) "c"
}
array(5) {
  ["d"]=>
  string(1) "d"
  ["e"]=>
  string(1) "e"
  ["f"]=>
  string(1) "f"
  ["b"]=>
  string(1) "b"
  ["c"]=>
  string(1) "c"
}


Previous Comments:
------------------------------------------------------------------------

[2006-08-16 21:13:52] tony2...@php.net

That's correct behavior, since you're calling it outside of the object
scope.

------------------------------------------------------------------------

[2006-08-16 20:50:09] thomas at epiphantastic dot com

Forgot to say, I'm running PHP 5.1.2

------------------------------------------------------------------------

[2006-08-16 20:48:52] thomas at epiphantastic dot com

I'm experiencing this same problem, running PHP on Windows with both
Apache and IIS. Here's the code:

<?php
class TestClass {
        private $var1 = "private";
        protected $var2 = "protected";
        public $var3 = "public";
}

$o = new TestClass();
foreach(array_keys(get_object_vars($o)) as $key)
        echo $key;
?>

I'd expect to see 3 values outputted but only one comes back.

------------------------------------------------------------------------

[2006-03-23 01:00:05] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

------------------------------------------------------------------------

[2006-03-15 16:04:48] m...@php.net

Please try using this CVS snapshot:

  http://snaps.php.net/php5.1-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.1-win32-latest.zip

Cannot reproduce.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/36693

-- 
Edit this bug report at http://bugs.php.net/?id=36693&edit=1

Reply via email to