for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PHPSA\Analyzer\Pass\Statement;
use PhpParser\Node\Stmt\ClassMethod;
use PHPSA\Analyzer\Helper\DefaultMetadataPassTrait;
use PHPSA\Analyzer\Pass\AnalyzerPassInterface;
use PHPSA\Context;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use phpDocumentor\Reflection\DocBlock;
class TestAnnotation implements AnalyzerPassInterface
{
use DefaultMetadataPassTrait;
/**
* @param ClassMethod $methodStmt
* @param Context $context
* @return bool
*/
public function pass(ClassMethod $methodStmt, Context $context)
$functionName = $methodStmt->name;
if (!$functionName) {
return false;
}
if (substr($functionName, 0, 4) !== 'test') {
if ($methodStmt->getDocComment()) {
$phpdoc = new DocBlock($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 array
public function getRegister()
return [
ClassMethod::class
];