-
Notifications
You must be signed in to change notification settings - Fork 127
Closed
Description
In v4.3.2 calling \phpDocumentor\Reflection\DocBlockFactory::create
for this phpDoc:
/**
* @return array<string, Channel>
*/
will cause a RuntimeException
from \phpDocumentor\Reflection\TypeResolver::parseTypes:263
with message 'A type is missing in a collection expression'
.
The bug seems to be in \phpDocumentor\Reflection\DocBlock\Tags\Return_::create:50
. This split:
$parts = preg_split('/\s+/Su', $body, 2);
doesn't take generics into account. array<string,
is being read as type and Channel>
becomes the description. Removing the space after comma solves the problem.
I've tried to determine if those spaces are actually a valid syntax and it seems like they kind-of-are:
- Grammar on phpdoc.org doesn't allow for them (on a side note, the "phpDocumentor" link in top left leads to a 404)
- PSR-5 grammar currently doesn't support generics too
- However the PSR-5 draft did allow for them before Oct 16, 2018 and spaces were allowed.
- The file that throws exception
phpdocumentor/type-resolver/src/TypeResolver.php
does itself use spaces on lines 64-65:/** * @var array<string, string> List of recognized keywords and unto which Value Object they map * @psalm-var array<string, class-string<Type>> */
So the implementation seems to be inconsistent with grammar in PSR and usage in phpDocumentor/TypeResolver
.
Jabolek and kuraobi
Metadata
Metadata
Assignees
Labels
No labels