3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test(ReflectionFunctionAbstract $r) { var_dump($r->isClosure()); $dc = $r->getDeclaringClass(); var_dump($dc ? $dc->getName() : 'no declaring class'); $csc = $r->getClosureScopeClass(); var_dump($csc ? $csc->getName() : 'no closure scope class'); echo "\n\n"; } class C { function f() { return function($p) {}; } } $c = new C; $cl = $c->f(); // instantiate ReflectionFunction directly on closure $rf = new ReflectionFunction($cl); test($rf); // get ReflectionFunction via one of the initial ReflectionFunction's ReflectionParameter objects $rps = $rf->getParameters(); $rp = $rps[0]; test($rp->getDeclaringFunction());
Output for git.master, git.master_jit, rfc.property-hooks
bool(true) Fatal error: Uncaught Error: Call to undefined method ReflectionFunction::getDeclaringClass() in /in/MMvgW:4 Stack trace: #0 /in/MMvgW(20): test(Object(ReflectionFunction)) #1 {main} thrown in /in/MMvgW on line 4
Process exited with code 255.

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:
36.16 ms | 401 KiB | 8 Q