Skip to content

Commit

Permalink
fix failing jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasMeschke committed Nov 18, 2024
1 parent a9862ec commit a186c0f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
10 changes: 3 additions & 7 deletions system/Files/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public function getSize()
/**
* Retrieve the file size by unit, calculated in IEC standards with 1024 as base value.
*
* @param FileSizeUnit $unit
* @phpstan-param positive-int $precision
* @return false|int|string
*/
Expand All @@ -85,7 +84,6 @@ public function getSizeByUnitBinary(FileSizeUnit $unit = FileSizeUnit::B, int $p
/**
* Retrieve the file size by unit, calculated in metric standards with 1000 as base value.
*
* @param FileSizeUnit $unit
* @phpstan-param positive-int $precision
* @return false|int|string
*/
Expand Down Expand Up @@ -222,12 +220,10 @@ public function getDestination(string $destination, string $delimiter = '_', int
protected function getSizeByUnitInternal(int $fileSizeBase, FileSizeUnit $unit, int $precision)
{
$exponent = $unit->value;
$divider = $fileSizeBase ** $exponent;
$divider = $fileSizeBase ** $exponent;
$size = $this->getSize() / $divider;

$size = $this->getSize() / $divider;

if($unit !== FileSizeUnit::B)
{
if($unit !== FileSizeUnit::B) {
$size = number_format($size, $precision);
}

Expand Down
4 changes: 2 additions & 2 deletions system/Files/FileSizeUnit.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

namespace CodeIgniter\Files;

enum FileSizeUnit : int
enum FileSizeUnit: int
{
case B = 0;
case KB = 1;
case MB = 2;
case GB = 3;
case TB = 4;
}
}
2 changes: 1 addition & 1 deletion tests/system/Files/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function testGetDestination(): void
}

/**
* @return array<string, list<int>>
* @return array<string, array<int, CodeIgniter\Files\FileSizeUnit>>

Check failure on line 173 in tests/system/Files/FileTest.php

View workflow job for this annotation

GitHub Actions / Psalm Analysis

UndefinedDocblockClass

tests/system/Files/FileTest.php:173:16: UndefinedDocblockClass: Docblock-defined class, interface or enum named CodeIgniter\Files\CodeIgniter\Files\FileSizeUnit does not exist (see https://psalm.dev/200)
*/
public static function provideGetSizeData()

Check failure on line 175 in tests/system/Files/FileTest.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Method CodeIgniter\Files\FileTest::provideGetSizeData() has invalid return type CodeIgniter\Files\CodeIgniter\Files\FileSizeUnit.
{
Expand Down

0 comments on commit a186c0f

Please sign in to comment.