Skip to content

Commit ed8e596

Browse files
authored
Merge pull request #156 from PHPCSStandards/feature/stricter-type-handling
QA: stricter type handling
2 parents cf1a5bd + 23ae7d6 commit ed8e596

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

PHPCSDebug/Sniffs/Debug/TokenListSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function process(File $phpcsFile, $stackPtr)
8282
$tokens = $phpcsFile->getTokens();
8383
$last = ($phpcsFile->numTokens - 1);
8484

85-
$ptrPadding = \max(3, \strlen($last));
85+
$ptrPadding = \max(3, \strlen((string) $last));
8686
$linePadding = \strlen($tokens[$last]['line']);
8787
$sep = ' | ';
8888

@@ -132,7 +132,7 @@ public function process(File $phpcsFile, $stackPtr)
132132
$sep, 'L', \str_pad($token['line'], $linePadding, '0', \STR_PAD_LEFT),
133133
$sep, 'C', \str_pad($token['column'], 3, ' ', \STR_PAD_LEFT),
134134
$sep, 'CC', \str_pad($token['level'], 2, ' ', \STR_PAD_LEFT),
135-
$sep, '(', \str_pad($parenthesesCount, 2, ' ', \STR_PAD_LEFT), ')',
135+
$sep, '(', \str_pad((string) $parenthesesCount, 2, ' ', \STR_PAD_LEFT), ')',
136136
$sep, \str_pad($token['type'], 26), // Longest token type name is 26 chars.
137137
$sep, '[', \str_pad($token['length'], 3, ' ', \STR_PAD_LEFT), ']:',
138138
($onlyEol === false ? ' ' : ''), $content, \PHP_EOL;

Scripts/CheckSniffCompleteness.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,18 +364,19 @@ public function isComplete()
364364

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

369369
$filling = '';
370370
if ($current === $sniffCount) {
371371
$lines = \ceil($current / 60);
372372
if ($lines > 1) {
373-
$filling = \str_repeat(' ', (($lines * 60) - $sniffCount));
373+
$filling = \str_repeat(' ', (int) (($lines * 60) - $sniffCount));
374374
}
375375
}
376376

377-
echo $filling, ' ', \str_pad($current, $padding, ' ', \STR_PAD_LEFT), ' / ', $sniffCount,
378-
' (', \str_pad(\round(($current / $sniffCount) * 100), 3, ' ', \STR_PAD_LEFT), '%)', \PHP_EOL;
377+
echo $filling, ' ', \str_pad((string) $current, $padding, ' ', \STR_PAD_LEFT), ' / ', $sniffCount,
378+
' (', \str_pad((string) \round(($current / $sniffCount) * 100), 3, ' ', \STR_PAD_LEFT), '%)',
379+
\PHP_EOL;
379380
}
380381
}
381382
}

0 commit comments

Comments
 (0)