3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php interface Creator { public function create(): void; } class EchoCreator implements Creator { public function create(): void { echo 'Hello world!'; } } trait CreatorAble { abstract protected function creator(): Creator; public function useCreator(): void { $this->creator()->create(); } } final class SomeClass { private $creator; use CreatorAble; public function __construct(Creator $creator) { $this->creator = $creator; } private function creator(): Creator { return $this->creator; } } (new SomeClass(new EchoCreator))->useCreator();
based on YesW7
Output for hhvm-3.21.0, 7.1.0 - 7.1.8
Hello world!
Output for 7.0.0 - 7.0.20
Hello world! Fatal error: Uncaught TypeError: Return value of EchoCreator::create() must be an instance of void, none returned in /in/deDEh:14 Stack trace: #0 /in/deDEh(23): EchoCreator->create() #1 /in/deDEh(46): SomeClass->useCreator() #2 {main} thrown in /in/deDEh on line 14
Process exited with code 255.
Output for hhvm-3.18.4 - 3.20.2
Hello world! Fatal error: Uncaught TypeError: Value returned from method EchoCreator::create() must be of type void, null given in /in/deDEh:14 Stack trace: #0 /in/deDEh(23): EchoCreator->create() #1 /in/deDEh(46): SomeClass->useCreator() #2 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/deDEh on line 6
Process exited with code 255.