Skip to content

Commit

Permalink
PHPCSDebug/TokenList: visualize whitespace in PHP 7.3+ heredoc/nowdoc…
Browse files Browse the repository at this point in the history
… 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).
  • Loading branch information
jrfnl committed Sep 23, 2022
1 parent bf0e337 commit 747f7e9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion PHPCSDebug/Sniffs/Debug/TokenListSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ public function process(File $phpcsFile, $stackPtr)
if (isset($token['orig_content'])) {
$content = $this->visualizeWhitespace($content);
$content .= $sep . 'Orig: ' . $this->visualizeWhitespace($token['orig_content']);
} elseif ($token['code'] === \T_WHITESPACE) {
} elseif ($token['code'] === \T_WHITESPACE
|| $token['code'] === \T_END_HEREDOC
|| $token['code'] === \T_END_NOWDOC
) {
$content = $this->visualizeWhitespace($content);
} elseif (isset(Tokens::$commentTokens[$token['code']]) === true) {
/*
Expand Down

0 comments on commit 747f7e9

Please sign in to comment.