for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PiedWeb\CMSBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Translation\TranslatorInterface;
use PiedWeb\CMSBundle\Entity\PageInterface as Page;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
class MediaController extends AbstractController
{
protected $translator;
public function download(
string $path,
Request $request,
$request
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
/** @scrutinizer ignore-unused */ Request $request,
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
TranslatorInterface $translator,
$translator
/** @scrutinizer ignore-unused */ TranslatorInterface $translator,
ParameterBagInterface $params
$params
/** @scrutinizer ignore-unused */ ParameterBagInterface $params
) {
$pathToFile = $this->get('kernel')->getProjectDir().'/media/'.substr(str_replace('..', '', $path), strlen('media/'));
if (!file_exists($pathToFile)) {
throw $this->createNotFoundException('The media does not exist...');
}
$response = new BinaryFileResponse($pathToFile);
$response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT);
return $response;
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.