3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php declare(strict_types=1); interface ValidatorInterface { public function validate($number); } interface LegacyValidatorInterface { public function validate($number, $deprecated = false); } class Validator implements LegacyValidatorInterface, ValidatorInterface { public function validate($number, $deprecated = false) { echo func_num_args(); echo "\n"; } } class Decorator implements ValidatorInterface { /** * @var ValidatorInterface */ private $core; /** * @param ValidatorInterface $core */ public function __construct(ValidatorInterface $core) { $this->core = $core; } public function validate($number) { $this->core->validate($number); } } declare(strict_types=1); $v = new Decorator(new Validator()); $v->validate("1", false); $v->validate("1");
based on nnBaG
Output for 7.0.0 - 7.1.6
Fatal error: strict_types declaration must be the very first statement in the script in /in/LLU3X on line 48
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught Error: strict_types declaration must be the very first statement in the script: (Line: 48, Char: 23) in /in/LLU3X:48 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Warning: Unsupported declare 'strict_types' in /in/LLU3X on line 4 Warning: Unsupported declare 'strict_types' in /in/LLU3X on line 48 1 1