<?php
class A
{
private $a_private = 1;
protected $a_protected = 2;
public $a_public = 3;
}
class C extends A
{
private $c_private = 1;
protected $c_protected = 2;
public $c_public = 3;
}
class B extends A
{
private $b_private = 1;
protected $b_protected = 2;
public $b_public = 3;
protected $sub;
function __construct(){
$this->sub = new C();
}
function __debugInfo(){
return ['foo'=>'bar'];
}
}
function object_dump($object){
return (function($object){
return (array)$object;
})->bindTo($object, get_class($object))($object);
}
var_dump(object_dump(new B));
- Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
- array(7) {
[" A a_private"]=>
int(1)
[" * a_protected"]=>
int(2)
["a_public"]=>
int(3)
[" B b_private"]=>
int(1)
[" * b_protected"]=>
int(2)
["b_public"]=>
int(3)
[" * sub"]=>
object(C)#2 (6) {
["a_private":"A":private]=>
int(1)
["a_protected":protected]=>
int(2)
["a_public"]=>
int(3)
["c_private":"C":private]=>
int(1)
["c_protected":protected]=>
int(2)
["c_public"]=>
int(3)
}
}
- Output for 8.3.5
- Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
array(7) {
[" A a_private"]=>
int(1)
[" * a_protected"]=>
int(2)
["a_public"]=>
int(3)
[" B b_private"]=>
int(1)
[" * b_protected"]=>
int(2)
["b_public"]=>
int(3)
[" * sub"]=>
object(C)#2 (6) {
["a_private":"A":private]=>
int(1)
["a_protected":protected]=>
int(2)
["a_public"]=>
int(3)
["c_private":"C":private]=>
int(1)
["c_protected":protected]=>
int(2)
["c_public"]=>
int(3)
}
}
- Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
- array(7) {
[" B b_private"]=>
int(1)
[" * b_protected"]=>
int(2)
["b_public"]=>
int(3)
[" * sub"]=>
object(C)#2 (6) {
["c_private":"C":private]=>
int(1)
["c_protected":protected]=>
int(2)
["c_public"]=>
int(3)
["a_private":"A":private]=>
int(1)
["a_protected":protected]=>
int(2)
["a_public"]=>
int(3)
}
[" A a_private"]=>
int(1)
[" * a_protected"]=>
int(2)
["a_public"]=>
int(3)
}
preferences:
151.07 ms | 403 KiB | 182 Q