Skip to content

Commit 747f7e9

Browse files
committed
PHPCSDebug/TokenList: visualize whitespace in PHP 7.3+ heredoc/nowdoc closers
Since PHP 7.3, heredoc/nowdoc closers may be indented. This indent can use either tabs or spaces and the indent is included in the `T_END_HEREDOC`/`T_END_NOWDOC` token contents. This commit adds whitespace visualization for these tokens. No tests included as the tests would only work on PHP 7.3 and would break the pre-existing tests for PHP < 7.3 (due to the token stream being broken for flexible heredocs/nowdocs in PHP < 7.3).
1 parent bf0e337 commit 747f7e9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

PHPCSDebug/Sniffs/Debug/TokenListSniff.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ public function process(File $phpcsFile, $stackPtr)
104104
if (isset($token['orig_content'])) {
105105
$content = $this->visualizeWhitespace($content);
106106
$content .= $sep . 'Orig: ' . $this->visualizeWhitespace($token['orig_content']);
107-
} elseif ($token['code'] === \T_WHITESPACE) {
107+
} elseif ($token['code'] === \T_WHITESPACE
108+
|| $token['code'] === \T_END_HEREDOC
109+
|| $token['code'] === \T_END_NOWDOC
110+
) {
108111
$content = $this->visualizeWhitespace($content);
109112
} elseif (isset(Tokens::$commentTokens[$token['code']]) === true) {
110113
/*

0 commit comments

Comments
 (0)