Skip to content

Commit 8787f66

Browse files
authored
Merge pull request #17 from Innmind/php-84
Add PHP 8.4 support
2 parents 4503a1b + 233c026 commit 8787f66

14 files changed

+36
-16
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [Unreleased]
4+
5+
### Fixed
6+
7+
- Support for PHP `8.4`
8+
39
## 5.11.0 - 2024-12-01
410

511
### Added

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
}
3131
},
3232
"require-dev": {
33-
"vimeo/psalm": "~5.6",
33+
"vimeo/psalm": "~5.6|dev-master",
3434
"innmind/black-box": "^5.5.1",
3535
"innmind/coding-standard": "~2.0"
3636
},

fixtures/Sequence.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ final class Sequence
1818
*
1919
* @return Set<Structure<I>>
2020
*/
21-
public static function of(Set $set, Set\Integers $sizes = null): Set
21+
public static function of(Set $set, ?Set\Integers $sizes = null): Set
2222
{
2323
// this is not optimal but it allows to avoid a BC break
2424
$sizes ??= Set\Integers::between(0, 100);

fixtures/Set.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class Set
2121
*
2222
* @return Set<Structure<I>>
2323
*/
24-
public static function of(DataSet $set, DataSet\Integers $sizes = null): DataSet
24+
public static function of(DataSet $set, ?DataSet\Integers $sizes = null): DataSet
2525
{
2626
// this is not optimal but it allows to avoid a BC break
2727
$sizes ??= DataSet\Integers::between(0, 100);

src/Accumulate.php

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function current(): mixed
3838
/** @psalm-suppress UnusedMethodCall */
3939
$this->pop();
4040

41+
/** @var S */
4142
return \current($this->values);
4243
}
4344

src/Map/DoubleIndex.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class DoubleIndex implements Implementation
2626
/**
2727
* @param Sequence\Implementation<Pair<T, S>> $pairs
2828
*/
29-
public function __construct(Sequence\Implementation $pairs = null)
29+
public function __construct(?Sequence\Implementation $pairs = null)
3030
{
3131
/** @var Sequence\Implementation<Pair<T, S>> */
3232
$this->pairs = $pairs ?? new Sequence\Primitive;

src/Map/ObjectKeys.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class ObjectKeys implements Implementation
2222
{
2323
private \SplObjectStorage $values;
2424

25-
public function __construct(\SplObjectStorage $values = null)
25+
public function __construct(?\SplObjectStorage $values = null)
2626
{
2727
$this->values = $values ?? new \SplObjectStorage;
2828
}

src/Monoid/Append.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class Append implements Monoid
2222
*
2323
* @return self<C>
2424
*/
25-
public static function of(string $class = null): self
25+
public static function of(?string $class = null): self
2626
{
2727
/** @var self<C> */
2828
return new self;

src/Monoid/MergeMap.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class MergeMap implements Monoid
2525
*
2626
* @return self<A, B>
2727
*/
28-
public static function of(string $key = null, string $value = null): self
28+
public static function of(?string $key = null, ?string $value = null): self
2929
{
3030
/** @var self<A, B> */
3131
return new self;

src/Monoid/MergeSet.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class MergeSet implements Monoid
2222
*
2323
* @return self<C>
2424
*/
25-
public static function of(string $class = null): self
25+
public static function of(?string $class = null): self
2626
{
2727
/** @var self<C> */
2828
return new self;

src/Sequence/Aggregate.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ public function __invoke(callable $map): \Generator
5858

5959
/** @psalm-suppress ImpureMethodCall */
6060
while ($this->values->valid()) {
61-
/** @psalm-suppress ImpureFunctionCall */
61+
/**
62+
* @psalm-suppress PossiblyNullArgument
63+
* @psalm-suppress ImpureFunctionCall
64+
*/
6265
$aggregate = $this->walk($map($n2, $n1), $void);
6366

6467
foreach ($aggregate as $element) {

src/Sequence/Lazy.php

+1
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ public function dropWhile(callable $condition): self
860860
/**
861861
* @psalm-suppress ImpureMethodCall
862862
* @psalm-suppress ImpureFunctionCall
863+
* @psalm-suppress PossiblyNullArgument
863864
*/
864865
if (!$condition($generator->current())) {
865866
/** @psalm-suppress ImpureMethodCall */

src/Sequence/Primitive.php

+1
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ public function dropWhile(callable $condition): self
609609
/**
610610
* @psalm-suppress ImpureMethodCall
611611
* @psalm-suppress ImpureFunctionCall
612+
* @psalm-suppress PossiblyNullArgument
612613
*/
613614
if (!$condition($iterator->current())) {
614615
/** @psalm-suppress ImpureMethodCall */

src/Str.php

+15-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ final class Str implements \Stringable
1313
private string $value;
1414
private Str\Encoding $encoding;
1515

16-
private function __construct(string $value, Str\Encoding $encoding = null)
16+
private function __construct(string $value, ?Str\Encoding $encoding = null)
1717
{
1818
$this->value = $value;
1919
$this->encoding = $encoding ?? Str\Encoding::utf8;
@@ -27,7 +27,7 @@ public function __toString(): string
2727
/**
2828
* @psalm-pure
2929
*/
30-
public static function of(string $value, Str\Encoding $encoding = null): self
30+
public static function of(string $value, ?Str\Encoding $encoding = null): self
3131
{
3232
return new self($value, $encoding);
3333
}
@@ -75,7 +75,7 @@ public function maybe(callable $filter): Maybe
7575
*
7676
* @return Sequence<self>
7777
*/
78-
public function split(string $delimiter = null): Sequence
78+
public function split(?string $delimiter = null): Sequence
7979
{
8080
if (\is_null($delimiter) || $delimiter === '') {
8181
return $this->chunk();
@@ -279,12 +279,20 @@ public function words(string|\Stringable $charlist = ''): Map
279279
/**
280280
* Split the string using a regular expression
281281
*
282+
* @throws InvalidRegex If the split didn't work
283+
*
282284
* @return Sequence<self>
283285
*/
284286
public function pregSplit(string|\Stringable $regex, int $limit = -1): Sequence
285287
{
286288
/** @psalm-suppress ArgumentTypeCoercion */
287289
$strings = \preg_split((string) $regex, $this->value, $limit);
290+
291+
if ($strings === false) {
292+
/** @psalm-suppress ImpureFunctionCall */
293+
throw new InvalidRegex('', \preg_last_error());
294+
}
295+
288296
/** @var Sequence<self> */
289297
$sequence = Sequence::of();
290298

@@ -348,7 +356,7 @@ public function pregReplace(
348356
*
349357
* @param 0|positive-int $length
350358
*/
351-
public function substring(int $start, int $length = null): self
359+
public function substring(int $start, ?int $length = null): self
352360
{
353361
if ($this->empty()) {
354362
return $this;
@@ -462,7 +470,7 @@ public function equals(self $string): bool
462470
/**
463471
* Trim the string
464472
*/
465-
public function trim(string $mask = null): self
473+
public function trim(?string $mask = null): self
466474
{
467475
return new self(
468476
$mask === null ? \trim($this->value) : \trim($this->value, $mask),
@@ -473,7 +481,7 @@ public function trim(string $mask = null): self
473481
/**
474482
* Trim the right side of the string
475483
*/
476-
public function rightTrim(string $mask = null): self
484+
public function rightTrim(?string $mask = null): self
477485
{
478486
return new self(
479487
$mask === null ? \rtrim($this->value) : \rtrim($this->value, $mask),
@@ -484,7 +492,7 @@ public function rightTrim(string $mask = null): self
484492
/**
485493
* Trim the left side of the string
486494
*/
487-
public function leftTrim(string $mask = null): self
495+
public function leftTrim(?string $mask = null): self
488496
{
489497
return new self(
490498
$mask === null ? \ltrim($this->value) : \ltrim($this->value, $mask),

0 commit comments

Comments
 (0)