- print_r: documentation ( source)
- get_object_vars: documentation ( source)
<?php
trait dumper {
public function doIt() {
print "get_object_vars()\n";
print_r(get_object_vars($this));
$closure = \Closure::bind(static function ($class) {
return get_object_vars($class);
}, NULL, $this);
$vars = $closure($this);
print "\n\nClosure\n";
print_r($vars);
}
}
class A {
use dumper;
private int $a = 1;
}
class B extends A {
}
class C extends B {
use dumper;
private int $a = 2;
}
print "Class A\n";
(new A())->doit();
print "\n\nClass B\n";
(new B())->doit();
print "\n\nClass C\n";
(new C())->doit();