3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class SelectUserById { private $container; public function __construct($container) { $this->container = $container; } public function vai() { echo $this->container; } } abstract class QueryFactory { public function __invoke($container) { $class = static::QUERY_NAMESPACE; return new $class($container); } } final class SelectUserByIdFactory extends QueryFactory { const QUERY_NAMESPACE = SelectUserById::class; } $instance = (new SelectUserByIdFactory)('container here'); $instance->vai();
based on oYm2W
Output for 7.0.0 - 7.3.0rc3
container here
Output for hhvm-3.22.0
Fatal error: Uncaught Error: syntax error, unexpected '(' in /in/lKWjbj:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
Fatal error: Uncaught Error: syntax error, unexpected '(' in /in/lKWjbj:32 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected '(' in /in/lKWjbj on line 32
Process exited with code 255.