diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index 32411d507ebc..6903054af1ee 100644 --- a/system/CLI/CLI.php +++ b/system/CLI/CLI.php @@ -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 @@ -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); @@ -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; } diff --git a/system/Database/Query.php b/system/Database/Query.php index 8bf03b32430e..ebd9c279bdef 100644 --- a/system/Database/Query.php +++ b/system/Database/Query.php @@ -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; diff --git a/system/Format/XMLFormatter.php b/system/Format/XMLFormatter.php index 3d0383cc3f13..c85eae5feffe 100644 --- a/system/Format/XMLFormatter.php +++ b/system/Format/XMLFormatter.php @@ -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); diff --git a/system/Helpers/number_helper.php b/system/Helpers/number_helper.php index 1220373329e2..d88d7b961f4c 100644 --- a/system/Helpers/number_helper.php +++ b/system/Helpers/number_helper.php @@ -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; diff --git a/tests/system/Commands/ClearDebugbarTest.php b/tests/system/Commands/ClearDebugbarTest.php index c0b5681b7861..d55988996ee8 100644 --- a/tests/system/Commands/ClearDebugbarTest.php +++ b/tests/system/Commands/ClearDebugbarTest.php @@ -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;