Skip to content

Commit

Permalink
refactor: fix param types
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Oct 25, 2023
1 parent 8cc7bac commit e7323f3
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions system/CLI/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ public static function table(array $tbody, array $thead = [])

foreach ($tableRows[$row] as $col) {
// Sets the size of this column in the current row
$allColsLengths[$row][$column] = static::strlen($col);
$allColsLengths[$row][$column] = static::strlen((string) $col);

// If the current column does not have a value among the larger ones
// or the value of this is greater than the existing one
Expand All @@ -1088,7 +1088,7 @@ public static function table(array $tbody, array $thead = [])
$column = 0;

foreach ($tableRows[$row] as $col) {
$diff = $maxColsLengths[$column] - static::strlen($col);
$diff = $maxColsLengths[$column] - static::strlen((string) $col);

if ($diff !== 0) {
$tableRows[$row][$column] .= str_repeat(' ', $diff);
Expand All @@ -1108,7 +1108,7 @@ public static function table(array $tbody, array $thead = [])
$cols = '+';

foreach ($tableRows[$row] as $col) {
$cols .= str_repeat('-', static::strlen($col) + 2) . '+';
$cols .= str_repeat('-', static::strlen((string) $col) + 2) . '+';
}
$table .= $cols . PHP_EOL;
}
Expand Down
2 changes: 1 addition & 1 deletion system/Database/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ protected function matchSimpleBinds(string $sql, array $binds, int $bindCount, i
$escapedValue = '(' . implode(',', $escapedValue) . ')';
}

$sql = substr_replace($sql, $escapedValue, $matches[0][$c][1], $ml);
$sql = substr_replace($sql, (string) $escapedValue, $matches[0][$c][1], $ml);
} while ($c !== 0);

return $sql;
Expand Down
2 changes: 2 additions & 0 deletions system/Format/XMLFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ protected function normalizeXMLTag($key)
'\\x{FDF0}-\\x{FFFD}\\x{10000}-\\x{EFFFF}';
$validName = $startChar . '\\.\\d\\x{B7}\\x{300}-\\x{36F}\\x{203F}-\\x{2040}';

$key = (string) $key;

$key = trim($key);
$key = preg_replace("/[^{$validName}-]+/u", '', $key);
$key = preg_replace("/^[^{$startChar}]+/u", 'item$0', $key);
Expand Down
2 changes: 1 addition & 1 deletion system/Helpers/number_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function number_to_size($num, int $precision = 1, ?string $locale = null)
// Strip any formatting & ensure numeric input
try {
// @phpstan-ignore-next-line
$num = 0 + str_replace(',', '', $num);
$num = 0 + str_replace(',', '', (string) $num);
} catch (ErrorException $ee) {
// Catch "Warning: A non-numeric value encountered"
return false;
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Commands/ClearDebugbarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function createDummyDebugbarJson(): void

// create 10 dummy debugbar json files
for ($i = 0; $i < 10; $i++) {
$path = str_replace($time, $time - $i, $path);
$path = str_replace((string) $time, (string) ($time - $i), $path);
file_put_contents($path, "{}\n");

$time -= $i;
Expand Down

0 comments on commit e7323f3

Please sign in to comment.