TypeResolver
TypeResolver copied to clipboard
fix for multiple class-string classes
e.g.: class-string<\Foo\Bar|\Foo\Lall>
⇒ currently this will throw an exception like \Foo\Bar|\Foo\Lall is not a class string
Note that Psalm doesn't like that either: https://psalm.dev/r/06ca7972ec
PHPStan is fine with it though
Thanks a lot for this PR.
I do get what you are trying to achieve here. But I do not like the extra complexity it takes to get this all done. The maintainability of this parser is becoming an issue more and more. And I'm wondering how to change that because I understand that the type systems supported by psalm and phpstan are getting more complex as well.
maybe we should consider todo a rewrite of the parser to get it where I want it to be. I think the last thing any of us is waiting for are bugs in this lib, with high consequences for all consumers of this library.
This doesn't mean I will never merge this pr, but I want to check first if this can be solved in a more convenient way.
Since you created this PR our project has been changed, we have done some major rebuilding of the internals of this library. I think we should put this on a roadmap to support this notation. But that requires some breaking changes I think... as it means that the class-string
and interface-string
should possibly contain a type.
I don't like the solution with an aggregate type of *-string
objects. as it does not reflect the original type close enough to cover all situations. And I'm not sure how this will impact the behavior of the consuming projects.
I feel sorry to say this, but at this moment I think we cannot support this in the correct way.
https://github.com/phpDocumentor/TypeResolver/issues/186