-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
NameResolver does not appear to resolve nullable types #360
Comments
NullableTypes are supposed to be resolved here: https://github.com/nikic/PHP-Parser/blob/3.x/lib/PhpParser/NodeVisitor/NameResolver.php#L123 Do you have a test case for this issue? Edit: NullableType resolution was added by a485ecd in 3.0.2, are you sure you're not using an older version? |
You're right, I did some more investigating and it turns out I didn't correctly see what the problem was. What is happening is that I"m traversing a tree to find In other words, you did certainly implement it, but because the new resolving code is not in the To conclude, it's not so much of a bug, just not the behavior I expected. In order to get the types resolved, I now either have to do the entire resolving beforehand and visit the hierarchy twice, or move my code to the I'll leave you to decide if you want to change the behavior or not. If not, I won't hold it against you and I'll look into working around it :-). |
This makes sure function signatures are already fully resolved in enterNode(). Resolves issue #360.
Having a fully resolved signature in enterNode sounds like a reasonable use-case. I've moved the resolution code into |
Hello
When looking at
NameResolver
, it appears that PHP 7.1 nullable types are not resolved.resolveSignature
only checks forName
, but not forNullableType
. This seems to apply for both return types as well as parameter types.It is also hard to work around this as the method is private. However, I can understand this as it may not be a method you wish to expose in the extensible API of the class; on one hand you want to let users have control over what they can override if they so desire, but on the other hand you don't want to have to support an API that was never intended to be used outside of the library either.
IIRC, Symfony solved this by making everything protected, allowing complete extensibility, but marking methods that were really intended for consumption with the
@api
docblock tag (i.e. you have control, but there are no backwards compatibility guarantees for the elements without the tag). Although, they were also thinking about making someRequest
-related elementsfinal
, so I'm not sure what the best approach is anymore.Thanks in advance
The text was updated successfully, but these errors were encountered: