Skip to content

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Apr 15, 2025

Description

Until now, the sniff would blindly forbid both heredoc and nowdoc syntax.

With the change as proposed in this PR, the sniff still does so, but now uses different error codes for encountered heredocs vs nowdocs, which allows for selectively ignoring one or the other, either from the ruleset or inline.

Includes updating the error message to be more specific for each error code as well.

Suggested changelog entry

  • The error code Squiz.PHP.Heredoc.NotAllowed has been replaced by Squiz.PHP.Heredoc.HeredocNotAllowed and Squiz.PHP.Heredoc.NowdocNotAllowed.
    • This allows for forbidding either heredocs or nowdocs without forbidding both.

Related issues/external references

Fixes squizlabs/PHP_CodeSniffer#2318

Until now, the sniff would blindly forbid both heredoc and nowdoc syntax.

With the change as proposed in this PR, the sniff still does so, but now uses different error codes for encountered heredocs vs nowdocs, which allows for selectively ignoring one or the other, either from the ruleset or inline.

Includes updating the error message to be more specific for each error code as well.

Fixes squizlabs/PHP_CodeSniffer 2318
@jrfnl jrfnl merged commit 73ca486 into 4.x Apr 15, 2025
54 checks passed
@jrfnl jrfnl deleted the phpcs-4.0/feature/sq-2318-squiz-heredoc-split-errorcode branch April 15, 2025 18:06
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.

2 participants