for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Controller\Frontend;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use App\Repository\ItemRepository;
use Ramsey\Uuid\Uuid;
class Item extends AbstractController
{
/**
* @var ItemRepository
*/
private $repository;
* @param ItemRepository $repository
public function __construct(
ItemRepository $repository
)
$this->repository = $repository;
}
* @Route("/item/{id}/{slug}", name="item", methods={"GET"})
* @param string $id
* @param string $slug
* @return Response
public function item(string $id, string $slug): Response
$slug
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function item(string $id, /** @scrutinizer ignore-unused */ string $slug): Response
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
try {
$uuid = Uuid::fromString($id);
$item = $this->repository->getItem($uuid);
} catch (\Exception $e) {
$error = $e->getMessage();
return $this->render('frontend/item.html.twig', [
'item' => $item ?? null,
'error' => $error ?? null
]);
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.