php-src/Zend/tests/bug27798.phpt

71 lines
956 B
Plaintext
Raw Normal View History

2004-10-04 08:58:47 +00:00
--TEST--
Bug #27798 (private / protected variables not exposed by get_object_vars() inside class)
--FILE--
<?php
class Base
{
2020-02-03 21:52:20 +00:00
public $Foo = 1;
protected $Bar = 2;
private $Baz = 3;
2018-09-16 17:16:42 +00:00
2020-02-03 21:52:20 +00:00
function __construct()
{
echo __METHOD__ . "\n";
var_dump(get_object_vars($this));
}
2004-10-04 08:58:47 +00:00
}
class Child extends Base
{
2020-02-03 21:52:20 +00:00
private $Baz = 4;
2004-10-04 08:58:47 +00:00
2020-02-03 21:52:20 +00:00
function __construct()
{
parent::__construct();
echo __METHOD__ . "\n";
var_dump(get_object_vars($this));
}
2004-10-04 08:58:47 +00:00
}
var_dump(get_object_vars(new Base));
var_dump(get_object_vars(new Child));
?>
--EXPECT--
Base::__construct
array(3) {
["Foo"]=>
int(1)
["Bar"]=>
int(2)
["Baz"]=>
int(3)
}
array(1) {
["Foo"]=>
int(1)
}
Base::__construct
array(3) {
["Foo"]=>
int(1)
["Bar"]=>
int(2)
["Baz"]=>
int(3)
2004-10-04 08:58:47 +00:00
}
Child::__construct
array(3) {
["Baz"]=>
int(4)
["Foo"]=>
int(1)
["Bar"]=>
int(2)
}
array(1) {
["Foo"]=>
int(1)
}