PHPSA\Analyzer\Pass\Statement\TestAnnotation::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)
    {
        $functionName = $methodStmt->name;
        if (!$functionName) {
            return false;
        }
        if (substr($functionName, 0, 4) !== 'test') {
            return false;
        }
        if ($methodStmt->getDocComment()) {
            $phpdoc = $this->docBlockFactory->create($methodStmt->getDocComment()->getText());
            if ($phpdoc->hasTag('test')) {
                $context->notice('test.annotation', 'Annotation @test is not needed when the method is prefixed with test.', $methodStmt);
                return true;
            }
        }
        return false;
    }