Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array union types aren't handled properly #49

Open
Daimona opened this issue Jan 28, 2020 · 0 comments
Open

Array union types aren't handled properly #49

Daimona opened this issue Jan 28, 2020 · 0 comments

Comments

@Daimona
Copy link

Daimona commented Jan 28, 2020

My Environment (version of the project, operating system, or hardware):
Any environment will do. I'm using phpda 2.0.2 from composer.

My phpda.yml:
Any config file, e.g. the default.

When I run this command: vendor/bin/phpda

If the project analyzed uses PSR5 array union types, e.g.

* @return (string|array)[]

You get:

Warning "\array)" is not a valid Fqsen. on line [line + file]

PSR5 array union types are already supported by TypeResolver/ReflectionDocBlock. The problem seems to be that, in order to parse the union type, TypeResolver splits the line at ( and )[] (ref).
However, NameResolver strips every occurrence of [], hence TypeResolver will try to split (string|array), which in turn gives the following parts:

[ '(', 'string', '|', 'array)' ]

and the last one isn't recognised as a valid type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant