3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo {private $a=1;} function test() { var_dump($this); } $closure = (new \ReflectionFunction('test'))->getClosure(); $object = new Foo; $closure = $closure->bindTo($object, get_class($object)); $closure();
based on 0eHZS
Output for 7.0.0 - 7.2.0
Warning: Cannot rebind scope of closure created by ReflectionFunctionAbstract::getClosure() in /in/YeDBj on line 10 Fatal error: Uncaught Error: Function name must be a string in /in/YeDBj:11 Stack trace: #0 {main} thrown in /in/YeDBj on line 11
Process exited with code 255.
Output for 5.4.0 - 5.6.28
object(Foo)#1 (1) { ["a":"Foo":private]=> int(1) }