3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace Foo { interface FooInterface { public function foo(string $str); } } namespace Bar { use Foo\FooInterface; class BarClass implements FooInterface { public function foo(string $str) { } } if (version_compare(PHP_VERSION, '7.0', '<')) { function type_hint($code, $error) { if (strpos($error, 'string, string') !== false) { return true; } if (strpos($error, 'int, integer') !== false) { return true; } if (strpos($error, 'bool, boolean') !== false) { return true; } if (strpos($error, 'float, double') !== false) { return true; } return false; } } set_error_handler('type_hint', E_RECOVERABLE_ERROR); }
based on 7UNP3
Output for 7.0.0 - 7.3.0rc3
Warning: set_error_handler() expects the argument (type_hint) to be a valid callback in /in/Jnclu on line 44
Output for 5.5.0 - 5.6.21
Fatal error: Declaration of Bar\BarClass::foo() must be compatible with Foo\FooInterface::foo(Foo\string $str) in /in/Jnclu on line 16
Process exited with code 255.