Skip to content

Commit

Permalink
QA: stricter type handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed Sep 9, 2024
1 parent cf1a5bd commit 23ae7d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions PHPCSDebug/Sniffs/Debug/TokenListSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function process(File $phpcsFile, $stackPtr)
$tokens = $phpcsFile->getTokens();
$last = ($phpcsFile->numTokens - 1);

$ptrPadding = \max(3, \strlen($last));
$ptrPadding = \max(3, \strlen((string) $last));
$linePadding = \strlen($tokens[$last]['line']);
$sep = ' | ';

Expand Down Expand Up @@ -132,7 +132,7 @@ public function process(File $phpcsFile, $stackPtr)
$sep, 'L', \str_pad($token['line'], $linePadding, '0', \STR_PAD_LEFT),
$sep, 'C', \str_pad($token['column'], 3, ' ', \STR_PAD_LEFT),
$sep, 'CC', \str_pad($token['level'], 2, ' ', \STR_PAD_LEFT),
$sep, '(', \str_pad($parenthesesCount, 2, ' ', \STR_PAD_LEFT), ')',
$sep, '(', \str_pad((string) $parenthesesCount, 2, ' ', \STR_PAD_LEFT), ')',
$sep, \str_pad($token['type'], 26), // Longest token type name is 26 chars.
$sep, '[', \str_pad($token['length'], 3, ' ', \STR_PAD_LEFT), ']:',
($onlyEol === false ? ' ' : ''), $content, \PHP_EOL;
Expand Down
9 changes: 5 additions & 4 deletions Scripts/CheckSniffCompleteness.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,18 +364,19 @@ public function isComplete()

$current = ($i + 1);
if (($current % 60) === 0 || $current === $sniffCount) {
$padding = \strlen($sniffCount);
$padding = \strlen((string) $sniffCount);

$filling = '';
if ($current === $sniffCount) {
$lines = \ceil($current / 60);
if ($lines > 1) {
$filling = \str_repeat(' ', (($lines * 60) - $sniffCount));
$filling = \str_repeat(' ', (int) (($lines * 60) - $sniffCount));
}
}

echo $filling, ' ', \str_pad($current, $padding, ' ', \STR_PAD_LEFT), ' / ', $sniffCount,
' (', \str_pad(\round(($current / $sniffCount) * 100), 3, ' ', \STR_PAD_LEFT), '%)', \PHP_EOL;
echo $filling, ' ', \str_pad((string) $current, $padding, ' ', \STR_PAD_LEFT), ' / ', $sniffCount,
' (', \str_pad((string) \round(($current / $sniffCount) * 100), 3, ' ', \STR_PAD_LEFT), '%)',
\PHP_EOL;
}
}
}
Expand Down

0 comments on commit 23ae7d6

Please sign in to comment.