3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private int $a = 1; 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 B extends A { private int $b = 2; } (new B())->doit();
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
get_object_vars() Array ( [a] => 1 ) Closure Array ( [b] => 2 )

preferences:
71.19 ms | 406 KiB | 5 Q