for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Event;
use App\Controller\AuthenticatedInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\HttpKernel\KernelEvents;
class StudentSubscriber implements EventSubscriberInterface
{
public function __construct(ContainerInterface $container)
$container
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function __construct(/** @scrutinizer ignore-unused */ ContainerInterface $container)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
}
public function onKernelController(FilterControllerEvent $event)
$controller = $event->getController();
/*
* $controller passed can be either a class or a Closure.
* This is not usual in Symfony but it may happen.
* If it is a class, it comes in array format
*/
if (!is_array($controller)) {
return;
if ($controller[0] instanceof AuthenticatedInterface) {
if (isset($_SESSION['phpCAS']['user'])) {
throw new AccessDeniedHttpException('Access forbidden.');
public function onKernelRequest(GetResponseEvent $event)
if (HttpKernel::MASTER_REQUEST != $event->getRequestType())
public static function getSubscribedEvents()
return [ KernelEvents::CONTROLLER => 'onKernelController' ];
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.