Fix File::isReference() method#1609
Merged
gsherwood merged 4 commits intosquizlabs:masterfrom Sep 25, 2017
Merged
Conversation
87b672e to
18ef222
Compare
A number of these will currently fail.
…nce not being identified correctly Since PHP 5.6, default values in function declarations can contain constant expressions. These expressions can contain a `T_BITWISE_AND`, but the `File::getMethodParameters()` method did not account for this and would misidentify the `T_BITWISE_AND` as indicating that the variable was being passed by reference. Includes a new unit test for the `File::getMethodParameters()` method to specifically safeguard against this issue.
The `File:isReference()` method misidentified a number of situations where the `T_BITWISE_AND` token was encountered, most notably: * An array assignment of a calculated value with a bitwise and operator in it ,was being misidentified as a reference. * A calculated default value for a function parameter with a bitwise and operator in it, was being misidentified as a reference. * New by reference was not recognized as a reference. * References to class properties with `self::`, `parent::`, `static::`, `namespace\Class::`, `classname::` were not recognized as references. This commit fixes these cases. Fixes 1604
18ef222 to
badc598
Compare
Contributor
Author
|
Rebased for merge conflicts |
Contributor
Author
|
@gsherwood Anything I can do to help move this one forward ? |
Member
Nope. Hopefully will get to it next week before release. |
Member
|
Thanks a lot for this. Sorry I didn't get around to it before the release. |
Contributor
Author
|
Thanks for merging this. I'm just glad it's fixed now. |
This file contains hidden or 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
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.
The
File::isReference()method misidentified a number of situations where theT_BITWISE_ANDtoken was encountered, most notably:self::,parent::,static::,namespace\Class::,classname::were not recognized as references.This PR fixes these cases and adds dedicated unit test files for this method.
Fixes #1604
As part of this fix, the
File::getMethodParameters()method also needed to be fixed.Since PHP 5.6, default values in function declarations can contain constant expressions.
These expressions can contain a
T_BITWISE_AND, but theFile::getMethodParameters()method did not account for this and would misidentify theT_BITWISE_ANDas indicating that the variable was being passed by reference.Includes a new unit test for the
File::getMethodParameters()method to specifically safeguard against this issue.