3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait TestTrait { public function execute(int $id) { return $id + 1; } } class TestClass { use TestTrait { execute as executeTrait; } function __construct() { var_dump($this->execute(1)); var_dump($this->executeTrait(2)); } } new TestClass();
based on gvRKc
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.21, 7.4.0 - 7.4.10, 8.0.0alpha1 - beta3
int(2) int(3)
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Catchable fatal error: Argument 1 passed to TestClass::execute() must be an instance of int, integer given, called in /in/ANmkM on line 19 and defined in /in/ANmkM on line 5
Process exited with code 255.