-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
PEAR/ScopeClosingBrace: prevent fixer conflict with itself #423
PEAR/ScopeClosingBrace: prevent fixer conflict with itself #423
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes make sense and correctly cover the test case added. The test case makes sense to me and is distinct from line 146 as that line has a ?>
token on the line too.
I've not spent time to understand the fixer conflict properly. The changes here look good to me. If they happen to resolve another related issue, then that's a bonus.
Thanks for looking this over @fredden !
The biggest difference with the test case on line 146 (and why that case previously already worked correctly) is that line 146 contains a mix of non-empty inline HTML and PHP code before the Leaving the ending The test case on line 146 is actually the reason for why I left the fixer alone.
For the record: The fixer conflict was that the fixer for the By fixing the |
I meant that there was a |
The `PEAR.WhiteSpace.ScopeClosingBrace` sniff could get into a conflict with itself when the scope closer was preceded by a PHP open tag and before that non-empty (i.e. non-indent) inline HTML. In that case, the sniff would not recognize that the close brace was not on a line by itself, as the search for the last content before would disregard the non-empty HTML and would continue searching, which meant that the "last relevant content before" token would point to a token on a previous line. This, in turn, then led to the sniff continuing on to the next error "Closing brace indented incorrectly", where the indent would now be incorrectly determined as `-1`, which in the fixer would lead to the original content and the replacement content being exactly the same, which created a fixer conflict. Fixed now by improving the "last content before" determination. Includes unit test. Related to 152
7903dd7
to
436d243
Compare
Rebased without changes, merging once the build has passed. |
Description
The
PEAR.WhiteSpace.ScopeClosingBrace
sniff could get into a conflict with itself when the scope closer was preceded by a PHP open tag and before that non-empty (i.e. non-indent) inline HTML.In that case, the sniff would not recognize that the close brace was not on a line by itself, as the search for the last content before would disregard the non-empty HTML and would continue searching, which meant that the "last relevant content before" token would point to a token on a previous line.
This, in turn, then led to the sniff continuing on to the next error "Closing brace indented incorrectly", where the indent would now be incorrectly determined as
-1
, which in the fixer would lead to the original content and the replacement content being exactly the same, which created a fixer conflict.Fixed now by improving the "last content before" determination.
Includes unit test.
Suggested changelog entry
Fixed PEAR.WhiteSpace.ScopeClosingBrace: when a close tag was preceded by non-empty inline HTML, the sniff would have a fixer conflict with itself.
Related issues/external references
Related to #152
Types of changes