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
Phan doesn't narrow property types after explicit tests #805
Labels
enhancement
This improves the quality of Phan's analysis of a codebase
Comments
TysonAndre
added
the
enhancement
This improves the quality of Phan's analysis of a codebase
label
Jun 4, 2017
Updating this with a shorter self-contained example that has come up today:
|
Early (broken) work is included in TysonAndre#113 . This needs to be rebased, and tests are still failing. Additionally, inferences in the global scope may require more work. |
This was referenced Jun 5, 2018
wmfgerrit
pushed a commit
to wikimedia/mediawiki-services-parsoid
that referenced
this issue
Apr 1, 2019
Phan doesn't propagate the result of the test back to the value of the property, which is phan/phan#805. Workarounds suggested include adding a null-coalescing ?? operator or copying the property to a local variable, but I've chosen just to suppress the warning instead. Change-Id: I8c0e413d34ce6b34681657720995fadb25e79807
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Given the following example:
Phan will produce a warning for the Example::doubleMe() method, but not for the DoubleIntOrNull() function:
It looks like Phan doesn't allow the type union of $this->i to be updated within the scope of the if statement the way it does for local variables and parameters. (Or after it, when an else clause appears or simplify_ast is used.)
Workarounds in the code are to copy the property to a local variable, or to explicitly cast it at the point of use when its type has been checked.
Thanks!
The text was updated successfully, but these errors were encountered: