PEAR/ScopeClosingBrace: prevent fixer conflict with itself #423
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.
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