Skip to content

Conversation

@jrfnl
Copy link
Member

@jrfnl jrfnl commented Nov 11, 2025

Description

In a tab indented file with --tab-width set, the fixer for the Generic.Strings.UnnecessaryHeredoc sniff 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

  • Bug fix (non-breaking change which fixes an issue)

In a tab indented file with `--tab-width` set, the fixer for the `Generic.Strings.UnnecessaryHeredoc` sniff 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.

Fixes 1320
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generic.Strings.UnnecessaryHeredoc incorrectly converts tabs into spaces in heredoc

2 participants