phpDocumentor / ReflectionDocBlock

MIT License
9.35k stars 119 forks source link

support for array-shapes? #263

Closed voku closed 1 year ago

voku commented 4 years ago

I tried to collect data structures of php-files or -strings: https://github.com/voku/Simple-PHP-Code-Parser ... but I have a problem with the "ReflectionDocBlock" package, I do something like:

 $parsedParamTags = $phpDoc->getTagsByName('param');
$parsedReturnTag = $phpDoc->getTagsByName('return');

But then I get InvalidTag when I use modern PHPDocs from PHPStan (https://phpstan.org/writing-php-code/phpdoc-types) or psalm (https://psalm.dev/docs/annotating_code/type_syntax/array_types/#object-like-arrays). PS: The syntax is also supported by PhpStorm (https://blog.jetbrains.com/phpstorm/2020/10/phpstorm-2020-3-eap-2/#psalm_and_phpdoc_annotations).

Do you plan to support the new syntax for e.g. arrays-shapes?

e.g.:

/** 
 * @return array{stdClass: \stdClass, numbers: int|float} $lall
 */

"InvalidArgumentException | "\array{stdClass: \stdClass" is not a valid Fqsen.

kkmuffme commented 2 years ago

This is definitely needed, since it's getting much more common

jaapio commented 2 years ago

will be part of #343

jaapio commented 1 year ago

Fixed in https://github.com/phpDocumentor/ReflectionDocBlock/pull/343