3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ArrayClass { public function foo(array $foo) { /* ... */ } } class IterableClass extends ArrayClass { // This implementation also accepts Traversable. // Variance is already possible in this special case using "iterable". public function foo(iterable $foo) { /* ... */ } } class EverythingClass extends ArrayClass { // This implementation accepts all values. // Restrictions may be done via user code in the method body. // Variance is currently not allowed, it throws a warning if parent or child miss a type. public function foo($foo) { /* ... */ } }
Output for 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Output for 7.1.0 - 7.1.20
Warning: Declaration of EverythingClass::foo($foo) should be compatible with ArrayClass::foo(array $foo) in /in/N3FoQ on line 18
Output for 7.0.0 - 7.0.20
Warning: Declaration of IterableClass::foo(iterable $foo) should be compatible with ArrayClass::foo(array $foo) in /in/N3FoQ on line 11 Warning: Declaration of EverythingClass::foo($foo) should be compatible with ArrayClass::foo(array $foo) in /in/N3FoQ on line 18
Output for 5.6.0 - 5.6.28
Strict Standards: Declaration of IterableClass::foo() should be compatible with ArrayClass::foo(array $foo) in /in/N3FoQ on line 11 Strict Standards: Declaration of EverythingClass::foo() should be compatible with ArrayClass::foo(array $foo) in /in/N3FoQ on line 18

preferences:
194.71 ms | 402 KiB | 194 Q