fix: cast floor to int to ensure int return type

There are no valid cases in the contexts where this function is used where the float will be greater than the range of the int (which is why the `min` functionr returns `mixed`)
This commit is contained in:
Roardom
2025-12-02 07:38:54 +00:00
parent d93a7b0cdd
commit 52e9c53f13
2 changed files with 1 additions and 7 deletions

View File

@@ -103,7 +103,7 @@ class SystemInformation
protected function formatBytes(int|float $bytes, int $precision = 2): string
{
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1_024));
$pow = (int) floor(($bytes ? log($bytes) : 0) / log(1_024));
$pow = min($pow, (\count(self::UNITS)) - 1);
// Uncomment one of the following alternatives
$bytes /= 1_024 ** $pow;

View File

@@ -210,12 +210,6 @@ parameters:
count: 1
path: app/Helpers/CacheUser.php
-
message: '#^Possibly invalid array key type float\|int\.$#'
identifier: offsetAccess.invalidOffset
count: 1
path: app/Helpers/SystemInformation.php
-
message: '#^Method App\\Http\\Controllers\\API\\BaseController\:\:sendError\(\) has parameter \$code with no type specified\.$#'
identifier: missingType.parameter