3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { private function testPrivate (bool $str) { echo "Class A\n"; } public function test() { $this->testPrivate(true); } function getClosure() { return function() use ($foo) { return $this->testPrivate($foo); }; } } class B extends A { private function testPrivate (string $value) { echo "Class B\n"; } function getClosure($foo) { return function() use ($foo) { return $this->testPrivate($foo); }; } } $a = new A(); $b = new B(); $fn = $b->getClosure(true); $fn2 = $fn->bindTo($a); $fn2();
based on ObOa4
Output for 7.0.0 - 7.2.0
Warning: Declaration of B::getClosure($foo) should be compatible with A::getClosure() in /in/49kUM on line 28 Fatal error: Uncaught Error: Call to private method A::testPrivate() from context 'B' in /in/49kUM:25 Stack trace: #0 /in/49kUM(36): B->{closure}() #1 {main} thrown in /in/49kUM on line 25
Process exited with code 255.
Output for 5.4.10 - 5.6.28
Strict Standards: Declaration of B::getClosure() should be compatible with A::getClosure() in /in/49kUM on line 28 Fatal error: Call to private method A::testPrivate() from context 'B' in /in/49kUM on line 25
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Strict Standards: Declaration of B::testPrivate() should be compatible with that of A::testPrivate() in /in/49kUM on line 28 Strict Standards: Declaration of B::getClosure() should be compatible with that of A::getClosure() in /in/49kUM on line 28 Fatal error: Call to undefined method Closure::bindTo() in /in/49kUM on line 34
Process exited with code 255.