Skip to content

Commit

Permalink
fix psalm errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Baptouuuu committed Jan 16, 2025
1 parent dbf8df0 commit a94f4fb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Accumulate.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function current(): mixed
/** @psalm-suppress UnusedMethodCall */
$this->pop();

/** @var S */
return \current($this->values);
}

Expand Down
5 changes: 4 additions & 1 deletion src/Sequence/Aggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ public function __invoke(callable $map): \Generator

/** @psalm-suppress ImpureMethodCall */
while ($this->values->valid()) {
/** @psalm-suppress ImpureFunctionCall */
/**
* @psalm-suppress PossiblyNullArgument
* @psalm-suppress ImpureFunctionCall
*/
$aggregate = $this->walk($map($n2, $n1), $void);

foreach ($aggregate as $element) {
Expand Down
1 change: 1 addition & 0 deletions src/Sequence/Lazy.php
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@ public function dropWhile(callable $condition): self
/**
* @psalm-suppress ImpureMethodCall
* @psalm-suppress ImpureFunctionCall
* @psalm-suppress PossiblyNullArgument
*/
if (!$condition($generator->current())) {
/** @psalm-suppress ImpureMethodCall */
Expand Down
1 change: 1 addition & 0 deletions src/Sequence/Primitive.php
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ public function dropWhile(callable $condition): self
/**
* @psalm-suppress ImpureMethodCall
* @psalm-suppress ImpureFunctionCall
* @psalm-suppress PossiblyNullArgument
*/
if (!$condition($iterator->current())) {
/** @psalm-suppress ImpureMethodCall */
Expand Down
6 changes: 6 additions & 0 deletions src/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,12 @@ public function pregSplit(string|\Stringable $regex, int $limit = -1): Sequence
{
/** @psalm-suppress ArgumentTypeCoercion */
$strings = \preg_split((string) $regex, $this->value, $limit);

if ($strings === false) {
/** @psalm-suppress ImpureFunctionCall */
throw new InvalidRegex('', \preg_last_error());
}

/** @var Sequence<self> */
$sequence = Sequence::of();

Expand Down

0 comments on commit a94f4fb

Please sign in to comment.