Skip to content

Commit eeafe32

Browse files
committed
Added support for PHP 8.4.
1 parent b89895b commit eeafe32

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

.github/workflows/Tests.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ jobs:
1717
- 8.0
1818
- 8.1
1919
- 8.2
20+
- 8.3
21+
- 8.4
2022
dependencies:
2123
- hi
2224
- lo
2325

2426
steps:
25-
- uses: actions/checkout@v3
27+
- uses: actions/checkout@v4
2628

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

3638
- name: Cache dependencies
3739
id: composer-cache
38-
uses: actions/cache@v3
40+
uses: actions/cache@v4
3941
with:
4042
path: vendor
4143
key: php-${{ matrix.php }}-${{ matrix.dependencies }}-${{ hashFiles('composer.json') }}

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"scriptfusion/static-class": "^1"
1919
},
2020
"require-dev": {
21-
"phpunit/phpunit": "^9",
21+
"phpunit/phpunit": "^9.6.21",
2222
"mockery/mockery": "^1.4"
2323
},
2424
"scripts": {

src/Byte/ByteFormatter.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ByteFormatter
2929
*
3030
* @param UnitDecorator|null $unitDecorator Optional. Unit decorator.
3131
*/
32-
public function __construct(UnitDecorator $unitDecorator = null)
32+
public function __construct(?UnitDecorator $unitDecorator = null)
3333
{
3434
$this
3535
->setUnitDecorator($unitDecorator ?: new SymbolDecorator)
@@ -45,7 +45,7 @@ public function __construct(UnitDecorator $unitDecorator = null)
4545
*
4646
* @return string Formatted bytes.
4747
*/
48-
public function format(int|float $bytes, int $precision = null): string
48+
public function format(int|float $bytes, ?int $precision = null): string
4949
{
5050
// Use default precision when not specified.
5151
$precision === null && $precision = $this->getPrecision();

test/Integration/Byte/ByteFormatterTest.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ public function provideBinaryIntegers(): array
3333
[0x80000, '512K'],
3434
[0x80001, '512K'],
3535
[0x801FF, '512K'],
36-
[0x80200, '513K'],
36+
// Rounding error fixed in 8.4.1.
37+
// See: https://github.com/php/php-src/blob/9ee607823eae02996f4d2f17d778041b76ec3e19/UPGRADING#L728-L734
38+
[0x80200, version_compare(PHP_VERSION, '8.4.0') > 0 ? '512K' : '513K'],
3739
[0x80201, '513K'],
3840
[0x80233, '513K'],
3941
[0x803FF, '513K'],

0 commit comments

Comments
 (0)