3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait SmartObject { public function __call(string $name, array $args) { return 'smart ' . $name; } } class Component { use SmartObject; } class FormControl extends Component { public function __call(string $name, array $args): mixed { return 'control ' . $name; } } class CustomFormControl extends FormControl { use SmartObject; } var_dump((new FormControl)->foo()); var_dump((new CustomFormControl)->foo());
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
Fatal error: Declaration of SmartObject::__call(string $name, array $args) must be compatible with FormControl::__call(string $name, array $args): mixed in /in/35EZW on line 4
Process exited with code 255.

preferences:
59.49 ms | 406 KiB | 5 Q