3v4l.org

run code in 300+ PHP versions simultaneously
<?php function reflectCallable($arg): ReflectionFunctionAbstract { if (is_array($arg)) { $ref = new ReflectionMethod(...$arg); } elseif (is_callable($arg)) { $ref = new ReflectionFunction($arg); } return $ref; } function definedFunc(Foo $foo) {} $callable = function(Foo $foo) {}; class Bar { public function baz(Foo $foo) {} } foreach (['definedFunc', $callable, ['Bar', 'baz']] as $callable) { $reflected = reflectCallable($callable); if ((string) $reflected->getParameters()[0]->getType() === 'Foo') { echo 'Callable takes Foo', PHP_EOL; } }
Output for git.master, git.master_jit, rfc.property-hooks
Callable takes Foo Callable takes Foo Callable takes 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:
18.57 ms | 401 KiB | 8 Q