3v4l.org

run code in 300+ PHP versions simultaneously
<?php function myErrorHandler($errno, $errstr, $errfile, $errline) { if ( E_RECOVERABLE_ERROR===$errno ) { echo "'catched' catchable fatal error\n"; return true; } return false; } set_error_handler('myErrorHandler'); class ClassA { public function method_a (ClassB $b) {} } class ClassWrong{} $a = new ClassA; $a->method_a(new ClassWrong); echo 'done.';
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: ClassA::method_a(): Argument #1 ($b) must be of type ClassB, ClassWrong given, called in /in/Z2hmd on line 19 and defined in /in/Z2hmd:13 Stack trace: #0 /in/Z2hmd(19): ClassA->method_a(Object(ClassWrong)) #1 {main} thrown in /in/Z2hmd on line 13
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 ClassA::method_a() must be an instance of ClassB, instance of ClassWrong given, called in /in/Z2hmd on line 19 and defined in /in/Z2hmd:13 Stack trace: #0 /in/Z2hmd(19): ClassA->method_a(Object(ClassWrong)) #1 {main} thrown in /in/Z2hmd on line 13
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
'catched' catchable fatal error done.

preferences:
273.17 ms | 402 KiB | 376 Q