Skip to content

Commit

Permalink
refactor: Minor SA annotations update.
Browse files Browse the repository at this point in the history
We are now above 97% !
  • Loading branch information
drupol committed Feb 3, 2022
1 parent 8a3a05a commit 35bf8c2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/Operation/Distinct.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace loophp\collection\Operation;

use ArrayIterator;
use Closure;
use Generator;

Expand Down Expand Up @@ -42,15 +43,15 @@ public function __invoke(): Closure
* @return Closure(iterable<TKey, T>): Generator<TKey, T>
*/
static function (callable $accessorCallback) use ($comparatorCallback): Closure {
/** @var array<int, array{0: TKey, 1: T}> $stack */
$stack = [];
/** @var ArrayIterator<int, array{0: TKey, 1: T}> $stack */
$stack = new ArrayIterator();

$filter = (new Filter())()(
/**
* @param T $value
* @param TKey $key
*/
static function ($value, $key) use ($comparatorCallback, $accessorCallback, &$stack): bool {
static function ($value, $key) use ($comparatorCallback, $accessorCallback, $stack): bool {
$matchWhenNot = static fn (): bool => true;
$matcher =
/**
Expand All @@ -64,7 +65,7 @@ static function ($value, $key) use ($comparatorCallback, $accessorCallback, &$st
return false;
}

$stack[] = [$key, $value];
$stack->append([$key, $value]);

return true;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Operation/Dump.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public function __invoke(): Closure
*/
static fn (?Closure $callback = null): Closure =>
/**
* @param iterable<TKey, T> $iterable
*
* @return Generator<TKey, T>
*/
static function (iterable $iterable) use ($name, $size, $callback): Generator {
Expand Down
9 changes: 5 additions & 4 deletions src/Operation/Duplicate.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace loophp\collection\Operation;

use ArrayIterator;
use Closure;
use Generator;

Expand Down Expand Up @@ -42,15 +43,15 @@ public function __invoke(): Closure
* @return Closure(iterable<TKey, T>): Generator<TKey, T>
*/
static function (callable $accessorCallback) use ($comparatorCallback): Closure {
/** @var array<int, array{0: TKey, 1: T}> $stack */
$stack = [];
/** @var ArrayIterator<int, array{0: TKey, 1: T}> $stack */
$stack = new ArrayIterator();

$filter = (new Filter())()(
/**
* @param T $value
* @param TKey $key
*/
static function ($value, $key) use ($comparatorCallback, $accessorCallback, &$stack): bool {
static function ($value, $key) use ($comparatorCallback, $accessorCallback, $stack): bool {
$matchWhenNot = static fn (): bool => true;
$matcher =
/**
Expand All @@ -64,7 +65,7 @@ static function ($value, $key) use ($comparatorCallback, $accessorCallback, &$st
return true;
}

$stack[] = [$key, $value];
$stack->append([$key, $value]);

return false;
}
Expand Down

0 comments on commit 35bf8c2

Please sign in to comment.