3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { protected function _a() { return 'waa?'; } } class B extends A{} $c = function() { return $this->_a(); }; $b = new B; $c = $c->bindTo($b); var_dump($c); $c();
based on YqCj1
Output for 7.0.0 - 7.2.0
object(Closure)#3 (1) { ["this"]=> object(B)#2 (0) { } } Fatal error: Uncaught Error: Call to protected method A::_a() from context 'Closure' in /in/qSfET:12 Stack trace: #0 /in/qSfET(17): Closure->{closure}() #1 {main} thrown in /in/qSfET on line 12
Process exited with code 255.
Output for 5.4.10 - 5.6.28
object(Closure)#3 (1) { ["this"]=> object(B)#2 (0) { } } Fatal error: Call to protected method A::_a() from context 'Closure' in /in/qSfET on line 12
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Fatal error: Call to undefined method Closure::bindTo() in /in/qSfET on line 15
Process exited with code 255.