3v4l.org

run code in 300+ PHP versions simultaneously
<?php /*interface FooInterface { public function method(); }*/ class Foo { public function method(X $arg = null) { } } class Bar extends Foo { public function method() { } } class Baz extends Bar { public function method(Y $arg = null) { } }
Output for 8.4.1 - 8.4.12
Deprecated: Foo::method(): Implicitly marking parameter $arg as nullable is deprecated, the explicit nullable type must be used instead in /in/94Lqc on line 8 Fatal error: Declaration of Bar::method() must be compatible with Foo::method(?X $arg = null) in /in/94Lqc on line 14
Process exited with code 255.
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
Fatal error: Declaration of Bar::method() must be compatible with Foo::method(?X $arg = null) in /in/94Lqc on line 14
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Warning: Declaration of Bar::method() should be compatible with Foo::method(?X $arg = NULL) in /in/94Lqc on line 14
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
Warning: Declaration of Bar::method() should be compatible with Foo::method(?X $arg = NULL) in /in/94Lqc on line 17

preferences:
121.3 ms | 410 KiB | 5 Q