PHPSA\Analyzer\Pass\Statement\MethodCannotReturn::pass PHP Method

pass() public method

public pass ( ClassMethod $methodStmt, Context $context ) : boolean
$methodStmt PhpParser\Node\Stmt\ClassMethod
$context PHPSA\Context
return boolean
    public function pass(ClassMethod $methodStmt, Context $context)
    {
        if ($methodStmt->stmts === null) {
            return false;
        }
        if (count($methodStmt->stmts) == 0) {
            return false;
        }
        $result = false;
        if ($methodStmt->name == '__construct' || $methodStmt->name == '__destruct') {
            foreach ($this->findReturnStatement($methodStmt->stmts) as $returnStmt) {
                if (!$returnStmt->expr) {
                    continue;
                }
                $context->notice('return.construct', sprintf('Method %s cannot return a value.', $methodStmt->name), $returnStmt);
                $result = true;
            }
        }
        return $result;
    }
MethodCannotReturn