Generic/UnnecessaryHeredoc: bug fix - fixer changes indentation type #1321
+815
−16
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
In a tab indented file with
--tab-widthset, the fixer for theGeneric.Strings.UnnecessaryHeredocsniff would replace tabs with spaces in lines in the heredoc body, which were being replaced to update the escaping of special characters.For heredocs using PHP 7.3+ flexible heredoc syntax with tab indentation, that also meant that the fixer would end up causing a parse error in the updated file (see: https://3v4l.org/vpD1u#veol )
Fixed now.
Includes extensively expanded tests to safeguard this fix for all variations of heredoc syntax vs indentation whitespace which I could think of.
Suggested changelog entry
Fixed: Generic.Strings.UnnecessaryHeredoc - the fixer could incidentally change tab indentation to space indentation in lines in the heredoc body.
Related issues/external references
Fixes #1320
Types of changes