for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PiedWeb\CMSBundle\Service;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Vich\UploaderBundle\Mapping\PropertyMapping;
class VichUploadPropertyNamer extends \Vich\UploaderBundle\Naming\PropertyNamer //implements NamerInterface, ConfigurableInterface
{
/**
* Guess the extension of the given file.
*
* @param UploadedFile $file
* @return string|null
*/
private function getExtension(UploadedFile $file): ?string
getExtension()
This check looks for private methods that have been defined, but are not used inside the class.
$file
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
private function getExtension(/** @scrutinizer ignore-unused */ UploadedFile $file): ?string
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
var_dump('hello'); exit;
var_dump('hello')
exit
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.
$originalName = $file->getClientOriginalName();
$originalName = $file->getClientOriginalName()
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.
return
die
function fx() { try { doSomething(); return true; } catch (\Exception $e) { return false; } return false; }
In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.
return false
if ($extension = pathinfo($originalName, PATHINFO_EXTENSION)) {
return strtolower($extension);
}
if ($extension = $file->guessExtension()) {
return null;
public function name($object, PropertyMapping $mapping): string
return strtolower(parent::name($object, $mapping));
This check looks for private methods that have been defined, but are not used inside the class.