mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 10:07:12 +00:00
bump phpstan to master. Fixed ignored errors
This commit is contained in:
+16
-9
@@ -18,6 +18,7 @@ use LogicException;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\TagFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\StaticMethod;
|
||||
use Webmozart\Assert\Assert;
|
||||
use function array_shift;
|
||||
use function count;
|
||||
@@ -51,7 +52,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
/**
|
||||
* Factory method for easy instantiation.
|
||||
*
|
||||
* @param string[] $additionalTags
|
||||
* @param array<class-string<StaticMethod>> $additionalTags
|
||||
*/
|
||||
public static function createInstance(array $additionalTags = []) : self
|
||||
{
|
||||
@@ -79,6 +80,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
if (is_object($docblock)) {
|
||||
if (!method_exists($docblock, 'getDocComment')) {
|
||||
$exceptionMessage = 'Invalid object passed; the given object must support the getDocComment method';
|
||||
|
||||
throw new InvalidArgumentException($exceptionMessage);
|
||||
}
|
||||
|
||||
@@ -106,6 +108,9 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<StaticMethod> $handler
|
||||
*/
|
||||
public function registerTagHandler(string $tagName, string $handler) : void
|
||||
{
|
||||
$this->tagFactory->registerTagHandler($tagName, $handler);
|
||||
@@ -118,8 +123,8 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
*/
|
||||
private function stripDocComment(string $comment) : string
|
||||
{
|
||||
/** @var string $comment */
|
||||
$comment = preg_replace('#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u', '$1', $comment);
|
||||
Assert::string($comment);
|
||||
$comment = trim($comment);
|
||||
|
||||
// reg ex above is not able to remove */ from a single line docblock
|
||||
@@ -130,7 +135,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
return str_replace(["\r\n", "\r"], "\n", $comment);
|
||||
}
|
||||
|
||||
// phpcs:disable SlevomatCodingStandard.Commenting.ForbiddenAnnotations.AnnotationForbidden
|
||||
// phpcs:disable
|
||||
/**
|
||||
* Splits the DocBlock into a template marker, summary, description and block of tags.
|
||||
*
|
||||
@@ -144,6 +149,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
*/
|
||||
private function splitDocBlock(string $comment) : array
|
||||
{
|
||||
// phpcs:enable
|
||||
// Performance improvement cheat: if the first character is an @ then only tags are in this DocBlock. This
|
||||
// method does not split tags so we return this verbatim as the fourth result (tags). This saves us the
|
||||
// performance impact of running a regular expression
|
||||
@@ -152,9 +158,8 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
}
|
||||
|
||||
// clears all extra horizontal whitespace from the line endings to prevent parsing issues
|
||||
/** @var string $comment */
|
||||
$comment = preg_replace('/\h*$/Sum', '', $comment);
|
||||
|
||||
Assert::string($comment);
|
||||
/*
|
||||
* Splits the docblock into a template marker, summary, description and tags section.
|
||||
*
|
||||
@@ -247,11 +252,11 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
private function splitTagBlockIntoTagLines(string $tags) : array
|
||||
{
|
||||
$result = [];
|
||||
foreach (explode("\n", $tags) as $tag_line) {
|
||||
if (isset($tag_line[0]) && ($tag_line[0] === '@')) {
|
||||
$result[] = $tag_line;
|
||||
foreach (explode("\n", $tags) as $tagLine) {
|
||||
if (isset($tagLine[0]) && ($tagLine[0] === '@')) {
|
||||
$result[] = $tagLine;
|
||||
} else {
|
||||
$result[count($result) - 1] .= "\n" . $tag_line;
|
||||
$result[count($result) - 1] .= "\n" . $tagLine;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +274,9 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
||||
// @codeCoverageIgnoreStart
|
||||
// Can't simulate this; this only happens if there is an error with the parsing of the DocBlock that
|
||||
// we didn't foresee.
|
||||
|
||||
throw new LogicException('A tag block started with text instead of an at-sign(@): ' . $tags);
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user