Between PHP 5.2.3 and 5.2.4 another backward incompatible change was introduced: parent classes now can not access private properties of child classes with get_object_vars(). See the following example:
class Bar {
public function dumpBar() {
var_dump(get_object_vars($this));
}
}
class Foo extends Bar {
public $public = 'public';
protected $protected = 'protected';
private $private = 'private';
public function dump() {
var_dump(get_object_vars($this));
}
}
$foo = new Foo();
$foo->dump();
$foo->dumpBar();
The result with PHP < 5.2.4:
E:\php\tests>php get_object_vars.php
array(3) {
["public"] => string(6) "public"
["protected"] => string(9) "protected"
["private"] => string(7) "private"
}
array(3) {
["public"] => string(6) "public"
["protected"] => string(9) "protected"
["private"] => string(7) "private"
}
And the result with PHP >= 5.2.4:
E:\php-5.2.4-Win32>php ../php/tests/get_object_vars.php
array(3) {
["public"] => string(6) "public"
["protected"] => string(9) "protected"
["private"] => string(7) "private"
}
array(2) {
["public"] => string(6) "public"
["protected"] => string(9) "protected"
}
As you can see the private property is missing now when dumped from the parent class Bar.