Closed mvorisek closed 8 months ago
https://github.com/phpstan/phpdoc-parser/blob/1.25.0/doc/grammars/phpdoc-method.peg#L11 grammar already allows in as defined in https://github.com/phpstan/phpdoc-parser/blob/1.25.0/doc/grammars/type.abnf#L6
I wonder why the method grammar files are named *.peg
instead of *.abnf
and if fuzzed/tested.
That has nothing to do with the type being union. It because it's a grammar conflict with static methods.
So for example, if you could use any of the following, it works just fine:
$this|null
?static
null|static
I tried improving the conflict resolution logic we use: https://github.com/phpstan/phpdoc-parser/pull/230
Jan, thank you!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Bug report
I know the current workaround is to place parenthesis around the return type, but this is problematic, as almost every CS fixer removes the parenthesis.
Like
\Closure(): void
, ie. type even with space is supported [1], unioned (and intersected) types should be supported as well.[1] https://phpstan.org/r/e9b294c3-2f5f-42a1-b4a7-c2ad93a83c2f
Code snippet that reproduces the problem
https://phpstan.org/r/ad8c4bfc-4c57-48fc-838e-fc3d14a6d491
Expected output
no phpstan parser error