3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo extends ReflectionClass { public function newInstance($arg=null, ...$args) { $args = \array_slice(\array_merge([$arg], $args), 0, \func_num_args()); return parent::newInstance(...$args); } } $foo = new Foo(Exception::class); $ex = $foo->newInstance('Test', 0); var_dump($ex);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of Foo::newInstance($arg = null, ...$args) should either be compatible with ReflectionClass::newInstance(mixed ...$args): object, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/eeVf8 on line 5 object(Exception)#2 (7) { ["message":protected]=> string(4) "Test" ["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0) ["file":protected]=> string(9) "/in/eeVf8" ["line":protected]=> int(8) ["trace":"Exception":private]=> array(2) { [0]=> array(6) { ["file"]=> string(9) "/in/eeVf8" ["line"]=> int(8) ["function"]=> string(11) "newInstance" ["class"]=> string(15) "ReflectionClass" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(4) "Test" [1]=> int(0) } } [1]=> array(6) { ["file"]=> string(9) "/in/eeVf8" ["line"]=> int(13) ["function"]=> string(11) "newInstance" ["class"]=> string(3) "Foo" ["type"]=> string(2) "->" ["args"]=> array(2) { [0]=> string(4) "Test" [1]=> int(0) } } } ["previous":"Exception":private]=> NULL }

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:
49.28 ms | 404 KiB | 8 Q