3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { public function testIsCallable(callable $param) { return is_callable($param); } private function privateMethod() { echo "This is a private method"; } public function test($param) { if ($this->testIsCallable($param)) { $param(); } } } class B extends A { public function test($param) { if ($this->testIsCallable($param)) { $param(); } } } $a = new A(); $b = new B(); $callable = [$a, 'privMethod']; $a->test($callable); $b->test($callable);
based on pg4Il
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught TypeError: Argument 1 passed to A::testIsCallable() must be callable, array given, called in /in/D4FSO on line 14 and defined in /in/D4FSO:5 Stack trace: #0 /in/D4FSO(14): A->testIsCallable(Array) #1 /in/D4FSO(34): A->test(Array) #2 {main} thrown in /in/D4FSO on line 5
Process exited with code 255.
Output for 5.4.2 - 5.6.28
Catchable fatal error: Argument 1 passed to A::testIsCallable() must be callable, array given, called in /in/D4FSO on line 14 and defined in /in/D4FSO on line 5
Process exited with code 255.
Output for 5.3.17 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/D4FSO on line 32
Process exited with code 255.