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('Bar\type_hint', E_RECOVERABLE_ERROR); function parse_error($code, $error) { print ' => ' . $code . ':' . $error; exit; } set_error_handler('Bar\parse_error', E_STRICT); } }
based on M844k
Output for 7.0.0 - 7.3.0beta1
Output for 5.5.0 - 5.6.28
Fatal error: Declaration of Bar\BarClass::foo() must be compatible with Foo\FooInterface::foo(Foo\string $str) in /in/d8TfI on line 16
Process exited with code 255.