Generic/DisallowTabIndent: do not auto-fix heredoc/nowdoc closer indent #533
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
Follow up on squizlabs/PHP_CodeSniffer#3640, which added the
T_END_HEREDOC
andT_END_NOWDOC
tokens to the list of tokens to examine and was included in the 3.7.2 release.When a flexible heredoc/nowdoc is used, the indentation type of the heredoc/nowdoc content and the indentation type of the heredoc/nowdoc closer must be consistent, so auto-fixing the indentation of the closer, without also changing the indentation of the contents (from tabs to spaces) would cause a parse error. See: https://3v4l.org/7OF3M
I do believe indentation tabs should still be flagged, but the auto-fixer should be disabled.
To allow people to disregard tab indentation for heredoc/nowdoc closers completely, the error now also has a more specific error code -
TabsUsedHeredocCloser
-, which allows for excluding it in a ruleset.While the change in the error code could be considered a breaking change, the fact that the potential for a parse error hasn't been reported as a bug so far, leads me to believe this is not a frequently encountered situation, so the impact of the higher specificity for the error code should be minimal.
Suggested changelog entry
Generic.WhiteSpace.DisallowTabIndent
: tab indentation for heredoc/nowdoc closers will no longer be auto-fixed to prevent parse errors. They issue will still be reported.The error code for heredoc/nowdoc indentation using tabs has also been made more specific -
TabsUsedHeredocCloser
- to allow for selectively excluding the indentation check for heredoc/nowdoc closers.Related issues/external references
Types of changes