3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /** * In middleware **/ class TemplateMiddleware { public function __construct(TemplateEngine $engine){} public function handle(Request $request, MiddlewareStack $stack): Response { $response = $stack->process($request); $data = $response->getBody(); if($tpl = $data->template){ $response = new Response(..., $this->engine->render()); } return $response; } } /** * In controller **/ class WebController { public function __construct(...) { $this->engine = new Twig(); } } /** * In application **/ class App { public function __construct() { $this->engine = new Twig(); } public function run(Request $request): Response { $router = new Router( new Endpoint('GET', '/path', new WebController($this->twig, ...); ); } }
based on 8r9ab
Output for 7.0.0 - 7.2.3
Parse error: syntax error, unexpected ',' in /in/UAWac on line 16
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: syntax error, unexpected ',' in /in/UAWac:-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/UAWac:16 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/UAWac on line 10
Process exited with code 255.