mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Be more strict about type definitions on param
Throw on invalid type definitions and unexpected type definitions. Not all types resolved by phpstan's parser are valid for docblocks, they might in a more complex type system but I do not see how these types would ever apply to param tags.
This commit is contained in:
@@ -17,6 +17,7 @@ use Mockery as m;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Method;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\MethodParameter;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Param;
|
||||
@@ -218,4 +219,30 @@ DOC;
|
||||
$docblock->getTags()
|
||||
);
|
||||
}
|
||||
|
||||
public function testInvalidTypeParamResultsInInvalidTag(): void
|
||||
{
|
||||
$docCommment = '
|
||||
/**
|
||||
* This is an example of a summary.
|
||||
*
|
||||
* @param array\Foo> $test
|
||||
*/
|
||||
';
|
||||
$factory = DocBlockFactory::createInstance();
|
||||
$docblock = $factory->create($docCommment);
|
||||
|
||||
self::assertEquals(
|
||||
[
|
||||
InvalidTag::create(
|
||||
'array\Foo> $test',
|
||||
'param',
|
||||
)->withError(
|
||||
new \InvalidArgumentException(
|
||||
'Could not find type in array\Foo> $test, please check for malformed notations')
|
||||
),
|
||||
],
|
||||
$docblock->getTags()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user