-
Notifications
You must be signed in to change notification settings - Fork 185
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
Resolve expressions recursively #155
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Current coverage is 94.64% (diff: 96.07%)@@ master #155 diff @@
==========================================
Files 31 31
Lines 534 411 -123
Methods 69 67 -2
Messages 0 0
Branches 0 0
==========================================
- Hits 502 389 -113
+ Misses 32 22 -10
Partials 0 0
|
felixfbecker
force-pushed
the
resolve-expression
branch
from
November 17, 2016 21:23
321b322
to
cd7f401
Compare
felixfbecker
force-pushed
the
resolve-expression
branch
from
November 18, 2016 14:16
5863c60
to
54ad082
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #54
Code changes:
A symbol is now represented in the index by an instance of the
Definition
class. This class holds theSymbolInformation
, the FQN, and the type of the declaration (variable type, parameter type, function/method return type, property/constant type) in form of aphpDocumentor\Type
object. This type is taken from type hints and docblocks (known limitation: docblocks only support FQNs, not aliased names). All the logic is moved into a newDefinitionResolver
class that takes care of resolving any reference node to aDefinition
object. It has an all-new methodresolveExpression()
, that can take anyExpr
node and resolve it recursively to aphpDocumentor\Type
.Resulting Enhancements:
This means that we can now get the definition of any reference, no matter how nested. For example, if we have a method call, as long as we can resolve the left-hand side, we can resolve the whole expression. This works for indefinitely nested expressions, including array access (if the property is typed properly as a typed array via a docblock), property access and method return values. There is even some basic type inference -
resolveExpression()
will return the correct type for scalars, instantiations etc. so if you assign a variable in the scope, you don't need a docblock to specify the type. This even goes so far as an array will get a compound type of all values it is initialized with or a ternary will get a compound type of the possible branches.The
resolveExpression()
method will be a great foundation for completion support #9