Skip to content

Commit 597101b

Browse files
committed
refactor: fix parameter types
1 parent 01ccd7d commit 597101b

File tree

17 files changed

+45
-37
lines changed

17 files changed

+45
-37
lines changed

system/CLI/CLI.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ public static function table(array $tbody, array $thead = [])
10661066

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

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

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

10911091
if ($diff !== 0) {
10921092
$tableRows[$row][$column] .= str_repeat(' ', $diff);
@@ -1106,7 +1106,7 @@ public static function table(array $tbody, array $thead = [])
11061106
$cols = '+';
11071107

11081108
foreach ($tableRows[$row] as $col) {
1109-
$cols .= str_repeat('-', static::strlen($col) + 2) . '+';
1109+
$cols .= str_repeat('-', static::strlen((string) $col) + 2) . '+';
11101110
}
11111111
$table .= $cols . PHP_EOL;
11121112
}

system/Cache/ResponseCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function generateCacheKey($request): string
8383
? $uri->getQuery(is_array($this->cacheQueryString) ? ['only' => $this->cacheQueryString] : [])
8484
: '';
8585

86-
return md5($uri->setFragment('')->setQuery($query));
86+
return md5((string) $uri->setFragment('')->setQuery($query));
8787
}
8888

8989
/**

system/CodeIgniter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ protected function generateCacheName(Cache $config): string
744744
? $uri->getQuery(is_array($config->cacheQueryString) ? ['only' => $config->cacheQueryString] : [])
745745
: '';
746746

747-
return md5($uri->setFragment('')->setQuery($query));
747+
return md5((string) $uri->setFragment('')->setQuery($query));
748748
}
749749

750750
/**

system/Database/BasePreparedQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public function execute(...$data)
175175
// Let others do something with this query
176176
Events::trigger('DBQuery', $query);
177177

178-
if ($this->db->isWriteType($query)) {
178+
if ($this->db->isWriteType((string) $query)) {
179179
return true;
180180
}
181181

system/Database/Query.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ protected function matchSimpleBinds(string $sql, array $binds, int $bindCount, i
357357
$escapedValue = '(' . implode(',', $escapedValue) . ')';
358358
}
359359

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

363363
return $sql;

system/Entity/Cast/DatetimeCast.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static function get($value, array $params = [])
3838
}
3939

4040
if (is_numeric($value)) {
41-
return Time::createFromTimestamp($value);
41+
return Time::createFromTimestamp((int) $value);
4242
}
4343

4444
if (is_string($value)) {

system/Format/XMLFormatter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ protected function normalizeXMLTag($key)
9191
'\\x{FDF0}-\\x{FFFD}\\x{10000}-\\x{EFFFF}';
9292
$validName = $startChar . '\\.\\d\\x{B7}\\x{300}-\\x{36F}\\x{203F}-\\x{2040}';
9393

94+
$key = (string) $key;
95+
9496
$key = trim($key);
9597
$key = preg_replace("/[^{$validName}-]+/u", '', $key);
9698
$key = preg_replace("/^[^{$startChar}]+/u", 'item$0', $key);

system/HTTP/Files/FileCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ protected function createFileObject(array $array)
185185
$array['tmp_name'] ?? null,
186186
$array['name'] ?? null,
187187
$array['type'] ?? null,
188-
$array['size'] ?? null,
188+
($array['size'] ?? null) === null ? null : (int) $array['size'],
189189
$array['error'] ?? null,
190190
$array['full_path'] ?? null
191191
);

system/HTTP/ResponseInterface.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,15 @@ public function sendBody();
320320
* Accepts an arbitrary number of binds (up to 7) or an associative
321321
* array in the first parameter containing all the values.
322322
*
323-
* @param array|string $name Cookie name or array containing binds
324-
* @param string $value Cookie value
325-
* @param int $expire Cookie expiration time in seconds
326-
* @param string $domain Cookie domain (e.g.: '.yourdomain.com')
327-
* @param string $path Cookie path (default: '/')
328-
* @param string $prefix Cookie name prefix
329-
* @param bool $secure Whether to only transfer cookies via SSL
330-
* @param bool $httponly Whether only make the cookie accessible via HTTP (no javascript)
331-
* @param string|null $samesite
323+
* @param array|Cookie|string $name Cookie name / array containing binds / Cookie object
324+
* @param string $value Cookie value
325+
* @param int $expire Cookie expiration time in seconds
326+
* @param string $domain Cookie domain (e.g.: '.yourdomain.com')
327+
* @param string $path Cookie path (default: '/')
328+
* @param string $prefix Cookie name prefix
329+
* @param bool $secure Whether to only transfer cookies via SSL
330+
* @param bool $httponly Whether only make the cookie accessible via HTTP (no javascript)
331+
* @param string|null $samesite
332332
*
333333
* @return $this
334334
*/

system/Helpers/number_helper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function number_to_size($num, int $precision = 1, ?string $locale = null)
2424
// Strip any formatting & ensure numeric input
2525
try {
2626
// @phpstan-ignore-next-line
27-
$num = 0 + str_replace(',', '', $num);
27+
$num = 0 + str_replace(',', '', (string) $num);
2828
} catch (ErrorException $ee) {
2929
// Catch "Warning: A non-numeric value encountered"
3030
return false;
@@ -142,7 +142,7 @@ function format_number(float $num, int $precision = 1, ?string $locale = null, a
142142

143143
// Try to format it per the locale
144144
if ($type === NumberFormatter::CURRENCY) {
145-
$formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, $options['fraction']);
145+
$formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, (float) $options['fraction']);
146146
$output = $formatter->formatCurrency($num, $options['currency']);
147147
} else {
148148
// In order to specify a precision, we'll have to modify

0 commit comments

Comments
 (0)