Skip to content

Commit e4e05a4

Browse files
committed
Debug/TokenList: change the column separator from :: to |
1 parent cb3024e commit e4e05a4

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

PHPCSDebug/Sniffs/Debug/TokenListSniff.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,15 @@ public function process(File $phpcsFile, $stackPtr)
8181

8282
$ptrPadding = \max(3, \strlen($last));
8383
$linePadding = \strlen($tokens[$last]['line']);
84+
$sep = ' | ';
8485

8586
echo \PHP_EOL;
8687
echo \str_pad('Ptr', $ptrPadding, ' ', \STR_PAD_BOTH),
87-
' :: ', \str_pad('Ln', ($linePadding + 1), ' ', \STR_PAD_BOTH),
88-
' :: ', \str_pad('Col', 4, ' ', \STR_PAD_BOTH),
89-
' :: ', 'Cond',
90-
' :: ', \str_pad('Token Type', 26), // Longest token type name is 26 chars.
91-
' :: [len]: Content', \PHP_EOL;
88+
$sep, \str_pad('Ln', ($linePadding + 1), ' ', \STR_PAD_BOTH),
89+
$sep, \str_pad('Col', 4, ' ', \STR_PAD_BOTH),
90+
$sep, 'Cond',
91+
$sep, \str_pad('Token Type', 26), // Longest token type name is 26 chars.
92+
$sep, '[len]: Content', \PHP_EOL;
9293

9394
echo \str_repeat('-', ($ptrPadding + $linePadding + 35 + 16 + 18)), \PHP_EOL;
9495

@@ -111,18 +112,18 @@ public function process(File $phpcsFile, $stackPtr)
111112
$content = \str_replace("\t", '\t', $content);
112113
}
113114
if (isset($token['orig_content'])) {
114-
$content .= ' :: Orig: ' . \str_replace("\t", '\t', $token['orig_content']);
115+
$content .= $sep . 'Orig: ' . \str_replace("\t", '\t', $token['orig_content']);
115116
}
116117
}
117118

118119
$conditionCount = \count($token['conditions']);
119120

120121
echo \str_pad($ptr, $ptrPadding, ' ', \STR_PAD_LEFT),
121-
' :: L', \str_pad($token['line'], $linePadding, '0', \STR_PAD_LEFT),
122-
' :: C', \str_pad($token['column'], 3, ' ', \STR_PAD_LEFT),
123-
' :: CC', \str_pad($conditionCount, 2, ' ', \STR_PAD_LEFT),
124-
' :: ', \str_pad($token['type'], 26), // Longest token type name is 26 chars.
125-
' :: [', $token['length'], ']: ', $content, \PHP_EOL;
122+
$sep, 'L', \str_pad($token['line'], $linePadding, '0', \STR_PAD_LEFT),
123+
$sep, 'C', \str_pad($token['column'], 3, ' ', \STR_PAD_LEFT),
124+
$sep, 'CC', \str_pad($conditionCount, 2, ' ', \STR_PAD_LEFT),
125+
$sep, \str_pad($token['type'], 26), // Longest token type name is 26 chars.
126+
$sep, '[', $token['length'], ']: ', $content, \PHP_EOL;
126127
}
127128

128129
// Only do this once per file.

PHPCSDebug/Tests/Debug/TokenListUnitTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ public function testOutput()
4545
$this->assertNotEmpty($output);
4646

4747
$expected = "\n";
48-
$expected .= 'Ptr :: Ln :: Col :: Cond :: Token Type :: [len]: Content' . "\n";
48+
$expected .= 'Ptr | Ln | Col | Cond | Token Type | [len]: Content' . "\n";
4949
$expected .= '-------------------------------------------------------------------------' . "\n";
50-
$expected .= ' 0 :: L1 :: C 1 :: CC 0 :: T_OPEN_TAG :: [5]: <?php' . "\n\n";
51-
$expected .= ' 1 :: L2 :: C 1 :: CC 0 :: T_WHITESPACE :: [0]: ' . "\n\n";
52-
$expected .= ' 2 :: L3 :: C 1 :: CC 0 :: T_FUNCTION :: [8]: function' . "\n";
53-
$expected .= ' 3 :: L3 :: C 9 :: CC 0 :: T_WHITESPACE :: [0]: ' . "\n\n";
50+
$expected .= ' 0 | L1 | C 1 | CC 0 | T_OPEN_TAG | [5]: <?php' . "\n\n";
51+
$expected .= ' 1 | L2 | C 1 | CC 0 | T_WHITESPACE | [0]: ' . "\n\n";
52+
$expected .= ' 2 | L3 | C 1 | CC 0 | T_FUNCTION | [8]: function' . "\n";
53+
$expected .= ' 3 | L3 | C 9 | CC 0 | T_WHITESPACE | [0]: ' . "\n\n";
5454

5555
$this->assertSame($expected, $output);
5656
}

0 commit comments

Comments
 (0)