3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public $x = 123; } class X { public function foo(\A $a) { echo $a->x; } } $aa = new \A; $xx = new \X; $xx->foo($aa); $xx->foo(null);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
123 Fatal error: Uncaught TypeError: X::foo(): Argument #1 ($a) must be of type A, null given, called in /in/UNc7t on line 20 and defined in /in/UNc7t:10 Stack trace: #0 /in/UNc7t(20): X->foo(NULL) #1 {main} thrown in /in/UNc7t on line 10
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
123 Fatal error: Uncaught TypeError: Argument 1 passed to X::foo() must be an instance of A, null given, called in /in/UNc7t on line 20 and defined in /in/UNc7t:10 Stack trace: #0 /in/UNc7t(20): X->foo(NULL) #1 {main} thrown in /in/UNc7t on line 10
Process exited with code 255.
Output for 5.5.0 - 5.5.35, 5.6.0 - 5.6.28
123 Catchable fatal error: Argument 1 passed to X::foo() must be an instance of A, null given, called in /in/UNc7t on line 20 and defined in /in/UNc7t on line 10
Process exited with code 255.

preferences:
138.71 ms | 409 KiB | 5 Q