for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace WebTheory\Saveyour\Controller;
use WebTheory\Saveyour\Contracts\Controller\InputPurifierInterface;
use WebTheory\Saveyour\Contracts\Formatting\InputFormatterInterface;
use WebTheory\Saveyour\Contracts\Validation\ValidatorInterface;
class InputPurifier implements InputPurifierInterface
{
protected ValidatorInterface $validator;
protected InputFormatterInterface $formatter;
public function __construct(ValidatorInterface $validator, InputFormatterInterface $formatter)
$this->validator = $validator;
$this->formatter = $formatter;
}
public function handleInput($input)
$report = $this->validator->inspect($input);
if (true === $report->validationStatus()) {
return $this->formatter->formatInput($input);
foreach ($report->ruleViolations() as $violation) {
$this->handleRuleViolation($violation);
return $this->returnIfFailed();
$this->returnIfFailed()
WebTheory\Saveyour\Contr...ifier::returnIfFailed()
This check looks for function or method calls that always return null and whose return value is used.
class A { function getObject() { return null; } } $a = new A(); if ($a->getObject()) {
The method getObject() can return nothing but null, so it makes no sense to use the return value.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
protected function returnIfFailed()
return null;
protected function handleRuleViolation($rule): void
$rule
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
protected function handleRuleViolation(/** @scrutinizer ignore-unused */ $rule): void
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
//
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.