Skip to content

Commit

Permalink
Added support for PHP 8.4.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilge committed Nov 24, 2024
1 parent b89895b commit eeafe32
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/Tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ jobs:
- 8.0
- 8.1
- 8.2
- 8.3
- 8.4
dependencies:
- hi
- lo

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
Expand All @@ -35,7 +37,7 @@ jobs:

- name: Cache dependencies
id: composer-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: vendor
key: php-${{ matrix.php }}-${{ matrix.dependencies }}-${{ hashFiles('composer.json') }}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"scriptfusion/static-class": "^1"
},
"require-dev": {
"phpunit/phpunit": "^9",
"phpunit/phpunit": "^9.6.21",
"mockery/mockery": "^1.4"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/Byte/ByteFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ByteFormatter
*
* @param UnitDecorator|null $unitDecorator Optional. Unit decorator.
*/
public function __construct(UnitDecorator $unitDecorator = null)
public function __construct(?UnitDecorator $unitDecorator = null)
{
$this
->setUnitDecorator($unitDecorator ?: new SymbolDecorator)
Expand All @@ -45,7 +45,7 @@ public function __construct(UnitDecorator $unitDecorator = null)
*
* @return string Formatted bytes.
*/
public function format(int|float $bytes, int $precision = null): string
public function format(int|float $bytes, ?int $precision = null): string
{
// Use default precision when not specified.
$precision === null && $precision = $this->getPrecision();
Expand Down
4 changes: 3 additions & 1 deletion test/Integration/Byte/ByteFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public function provideBinaryIntegers(): array
[0x80000, '512K'],
[0x80001, '512K'],
[0x801FF, '512K'],
[0x80200, '513K'],
// Rounding error fixed in 8.4.1.
// See: https://github.com/php/php-src/blob/9ee607823eae02996f4d2f17d778041b76ec3e19/UPGRADING#L728-L734
[0x80200, version_compare(PHP_VERSION, '8.4.0') > 0 ? '512K' : '513K'],
[0x80201, '513K'],
[0x80233, '513K'],
[0x803FF, '513K'],
Expand Down

0 comments on commit eeafe32

Please sign in to comment.