3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); namespace GetObjectVars; // use function PHPStan\Testing\assertType; function assertType($_, $a) {var_dump($a);} class Base { public int $a = 1; public string $b = ''; protected string $c = ''; private bool $d = false; public function getVars(): void { assertType('array{a: int, b: string, c: string, d: bool}', get_object_vars($this)); } } class Extended extends Base { public string $foo = 'foo'; public function getExtendedVars(): void { assertType('array{a: int, b: string, c: string}', get_object_vars($this)); } } (new Base)->getVars(); (new Extended)->getVars(); (new Extended)->getExtendedVars();
Output for git.master, git.master_jit, rfc.property-hooks
array(4) { ["a"]=> int(1) ["b"]=> string(0) "" ["c"]=> string(0) "" ["d"]=> bool(false) } array(5) { ["a"]=> int(1) ["b"]=> string(0) "" ["c"]=> string(0) "" ["d"]=> bool(false) ["foo"]=> string(3) "foo" } array(4) { ["a"]=> int(1) ["b"]=> string(0) "" ["c"]=> string(0) "" ["foo"]=> string(3) "foo" }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
35.75 ms | 406 KiB | 5 Q