Skip to content

Commit 1dd1809

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

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

.github/workflows/Tests.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
- 8.0
1818
- 8.1
1919
- 8.2
20+
- 8.3
21+
- 8.4
2022
dependencies:
2123
- hi
2224
- lo

src/Byte/ByteFormatter.php

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 1 deletion
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)