Skip to content

Commit 1c4aa60

Browse files
authored
Merge pull request #533 from PHPCSStandards/feature/generic-disallowtabindent-dont-autofix-heredocnowdoc-indent
Generic/DisallowTabIndent: do not auto-fix heredoc/nowdoc closer indent
2 parents 71326b4 + 01b4cec commit 1c4aa60

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ public function process(File $phpcsFile, $stackPtr)
169169
continue;
170170
}
171171

172+
// Report, but don't auto-fix tab identation for a PHP 7.3+ flexible heredoc/nowdoc closer.
173+
// Auto-fixing this would cause parse errors as the indentation of the heredoc/nowdoc contents
174+
// needs to use the same type of indentation. Also see: https://3v4l.org/7OF3M .
175+
if ($tokens[$i]['code'] === T_END_HEREDOC || $tokens[$i]['code'] === T_END_NOWDOC) {
176+
$phpcsFile->addError($error, $i, $errorCode.'HeredocCloser');
177+
continue;
178+
}
179+
172180
$fix = $phpcsFile->addFixableError($error, $i, $errorCode);
173181
if ($fix === true) {
174182
if (isset($tokens[$i]['orig_content']) === true) {

src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.3.inc.fixed

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)