3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class LoginRedirectResponse extends RedirectResponse {} function loginCheck(SecurityContext $sc, UrlGenerator $urlgen) { //This is a factory if ($sc->isGranted('IS_AUTHENTICATED_FULLY')) { return new LoginRedirectResponse($urlgen->generate('home')); } return null; } class HomeController { public function loginAction(Request $req, Twig_Environment $twig, UrlGenerator $urlgen, LoginRedirectResponse $redirectResponse = null) { if ($redirectResponse) { return $redirectResponse; } $session = $req->getSession(); $errorConst = $sc::AUTHENTICATION_ERROR; $lastUsernameConst = $sc::LAST_USERNAME; return $twig->render('login.html.twig', array( 'error' => ($session->has($errorConst)) ? $session->get($errorConst)->getMessage() : null, 'last_username' => $session->get($lastUsernameConst), )); } } $injector->delegate('LoginRedirectResponse', 'loginCheck'); $injector->execute(['HomeController', 'loginAction'])
Output for 5.4.0 - 5.4.28
Parse error: syntax error, unexpected end of file in /in/8CKZl on line 38
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected '[', expecting ')' in /in/8CKZl on line 38
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in /in/8CKZl on line 25
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_PAAMAYIM_NEKUDOTAYIM in /in/8CKZl on line 25
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting ')' in /in/8CKZl on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting ')' in /in/8CKZl on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/8CKZl on line 6
Process exited with code 255.