3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class LoginRedirectResponse extends RedirectResponse {} function loginCheck(SecurityContext $sc, UrlGenerator $urlgen) { 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/O7OOL on line 37
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected '[', expecting ')' in /in/O7OOL on line 37
Process exited with code 255.