3v4l.org

run code in 500+ PHP versions simultaneously
<?php trait theTrait { protected function test($a, $x=[]) { echo $a; } } class theClass { use theTrait; } class theExtend extends theClass { protected function test($a) { echo 'prefixed: ' . $a; } } $x = new theClass;
Output for 8.5.0 - 8.5.9
Fatal error: Declaration of theExtend::test($a) must be compatible with theClass::test($a, $x = []) in /in/iedIW on line 17 Stack trace: #0 {main}
Process exited with code 255.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.33, 8.3.0 - 8.3.33, 8.4.1 - 8.4.24
Fatal error: Declaration of theExtend::test($a) must be compatible with theClass::test($a, $x = []) in /in/iedIW on line 17
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Warning: Declaration of theExtend::test($a) should be compatible with theClass::test($a, $x = Array) in /in/iedIW on line 17
Output for 7.3.0 - 7.3.33
Warning: Declaration of theExtend::test($a) should be compatible with theClass::test($a, $x = Array) in /in/iedIW on line 16

preferences:
84.92 ms | 1473 KiB | 4 Q