3v4l.org

run code in 300+ PHP versions simultaneously
<?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 testIsCallable(callable $param) { return is_callable($param); } public function test($param) { if ($this->testIsCallable($param)) { $param(); } } } $a = new A(); $b = new B(); $callable = [$a, 'privMethod']; $a->test($callable); $b->test($callable);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught TypeError: A::testIsCallable(): Argument #1 ($param) must be of type callable, array given, called in /in/S0Eol on line 14 and defined in /in/S0Eol:5 Stack trace: #0 /in/S0Eol(14): A->testIsCallable(Array) #1 /in/S0Eol(38): A->test(Array) #2 {main} thrown in /in/S0Eol on line 5
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught TypeError: Argument 1 passed to A::testIsCallable() must be callable, array given, called in /in/S0Eol on line 14 and defined in /in/S0Eol:5 Stack trace: #0 /in/S0Eol(14): A->testIsCallable(Array) #1 /in/S0Eol(38): A->test(Array) #2 {main} thrown in /in/S0Eol on line 5
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Catchable fatal error: Argument 1 passed to A::testIsCallable() must be callable, array given, called in /in/S0Eol on line 14 and defined in /in/S0Eol on line 5
Process exited with code 255.

preferences:
312.74 ms | 402 KiB | 376 Q