3v4l.org

run code in 300+ PHP versions simultaneously
<?php spl_autoload_register(function($class) { if ($class === 'A') { class A { public function foo($x): B { return new B; } } } else if ($class === 'B') { class B extends A { public function foo($x): C { return new C; } } var_dump(new B); } else if ($class === 'C') { class C extends B implements N { } } }); new C;
Output for 8.5.0 - 8.5.3
object(B)#2 (0) { } Fatal error: During inheritance of C with variance dependencies: Uncaught Error: Interface "N" not found in /in/oUoG2:18 Stack trace: #0 /in/oUoG2(23): {closure:/in/oUoG2:3}('C') #1 {main} in /in/oUoG2 on line 18 Stack trace: #0 /in/oUoG2(23): {closure:/in/oUoG2:3}('C') #1 {main}
Process exited with code 255.
Output for 8.4.1 - 8.4.14, 8.4.16 - 8.4.18
object(B)#2 (0) { } Fatal error: During inheritance of C with variance dependencies: Uncaught Error: Interface "N" not found in /in/oUoG2:18 Stack trace: #0 /in/oUoG2(23): {closure:/in/oUoG2:3}('C') #1 {main} in /in/oUoG2 on line 18
Process exited with code 255.
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30
object(B)#2 (0) { } Fatal error: During inheritance of C with variance dependencies: Uncaught Error: Interface "N" not found in /in/oUoG2:18 Stack trace: #0 /in/oUoG2(23): {closure}('C') #1 {main} in /in/oUoG2 on line 18
Process exited with code 255.
Output for 7.4.0 - 7.4.33
object(B)#2 (0) { } Fatal error: During inheritance of C with variance dependencies: Uncaught Error: Interface 'N' not found in /in/oUoG2:18 Stack trace: #0 [internal function]: {closure}('C') #1 /in/oUoG2(23): spl_autoload_call('C') #2 {main} in /in/oUoG2 on line 18
Process exited with code 255.
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
Fatal error: Declaration of B::foo($x): C must be compatible with A::foo($x): B in /in/oUoG2 on line 11
Process exited with code 255.

preferences:
109.56 ms | 1529 KiB | 4 Q