3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { public function display() { $cb = self::fooStaticMethod(); call_user_func($cb, $this); } public static function fooStaticMethod() { return self::getCallable(); } private static function getCallable() { return function (Foo $foo) { $foo->fooMethod(); }; } private function fooMethod() { var_dump('fii'); } } class Bar extends Foo { } $bar = new Bar(); $bar->display();
based on rfp6X
Output for 5.4.10 - 5.4.29, 7.0.0 - 7.2.0
string(3) "fii"
Output for 5.4.30 - 5.6.28
Fatal error: Call to private method Foo::fooMethod() from context 'Bar' in /in/7dtUA on line 20
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Fatal error: Call to private method Foo::fooMethod() from context '' in /in/7dtUA on line 20
Process exited with code 255.