Skip to content

Generic/UnnecessaryHeredoc: 2 bug fixes involving escape sequences #1040

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

Merged
merged 2 commits into from
Apr 25, 2025

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Apr 20, 2025

Description

Generic/UnnecessaryHeredoc: bug fix - stray backslashes after fixing

If the original heredoc contained an escaped variable or an escaped backslash (neither of which need heredoc), the nowdoc version of the text string would contain stray backslashes as these escapes are not needed in nowdocs, so would be interpreted as literals.

Fixed now.

Includes tests.

Generic/UnnecessaryHeredoc: bug fix - false positives for heredoc with escape sequence

If the original heredoc contained an escape sequence, but no variable interpolation or expressions, it would be flagged as unnecessary and fixed to nowdoc, even though escape sequences are not supported in nowdocs.

Fixed now.

Includes tests.

Suggested changelog entry

Fixed: Generic.Strings.UnnecessaryHeredoc - false positive for heredocs containing escape sequences
Fixed: Generic.Strings.UnnecessaryHeredoc - fixer would not clean up escape sequences which aren't needed in nowdocs

Related issues/external references

Follow up on #633

jrfnl added 2 commits April 20, 2025 05:42
If the original heredoc contained an escaped variable or an escaped backslash (neither of which need heredoc), the nowdoc version of the text string would contain stray backslashes as these escapes are not needed in nowdocs, so would be interpreted as literals.

Fixed now.

Includes tests.
…h escape sequence

If the original heredoc contained an escape sequence, but no variable interpolation or expressions, it would be flagged as unnecessary and fixed to nowdoc, even though escape sequences are not supported in nowdocs.

Fixed now.

Includes tests.
@jrfnl jrfnl added this to the 3.13.0 milestone Apr 20, 2025
@jrfnl jrfnl merged commit 7fb48d6 into master Apr 25, 2025
63 checks passed
@jrfnl jrfnl deleted the feature/generic-unnecessaryheredoc-bug-fix-x2 branch April 25, 2025 03:37
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.

1 participant