Skip to content

Commit

Permalink
Merge pull request #533 from PHPCSStandards/feature/generic-disallowt…
Browse files Browse the repository at this point in the history
…abindent-dont-autofix-heredocnowdoc-indent

Generic/DisallowTabIndent: do not auto-fix heredoc/nowdoc closer indent
  • Loading branch information
jrfnl authored Jul 9, 2024
2 parents 71326b4 + 01b4cec commit 1c4aa60
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ public function process(File $phpcsFile, $stackPtr)
continue;
}

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

$fix = $phpcsFile->addFixableError($error, $i, $errorCode);
if ($fix === true) {
if (isset($tokens[$i]['orig_content']) === true) {
Expand Down

This file was deleted.

0 comments on commit 1c4aa60

Please # to comment.