3v4l.org

run code in 300+ 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.0.0 - 8.0.26, 8.1.0 - 8.1.13, 8.2rc1 - rc3
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:
28.53 ms | 415 KiB | 12 Q