for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace ParaTest\Parser;
abstract class ParsedObject
{
/**
* @var string
*/
protected $docBlock;
protected $name;
public function __construct(string $doc, string $name)
$this->docBlock = $doc;
$this->name = $name;
}
* Get the name of a parsed object.
*
* @return string
public function getName(): string
return $this->name;
* Get the doc block comments of a parsed object.
public function getDocBlock()
return $this->docBlock;
* Returns whether or not the parsed object
* has an annotation matching the name and value
* if provided.
* @param string $anno
$anno
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter $italy is not defined by the method finale(...).
$italy
finale(...)
/** * @param array $germany * @param array $island * @param array $italy */ function finale($germany, $island) { return "2:1"; }
The most likely cause is that the parameter was removed, but the annotation was not.
* @param mixed $value
* @return bool
public function hasAnnotation(string $annotation, string $value = null): bool
$pattern = sprintf(
'/@%s%s/',
$annotation,
null !== $value ? "[\s]+$value" : '\b'
);
return 1 === preg_match($pattern, $this->docBlock);
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.