loophp /
collection
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace loophp\collection\Operation; |
||
| 6 | |||
| 7 | use ArrayIterator; |
||
| 8 | use Closure; |
||
| 9 | use Generator; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * @immutable |
||
| 13 | * |
||
| 14 | * @template TKey |
||
| 15 | * @template T |
||
| 16 | */ |
||
| 17 | final class Duplicate extends AbstractOperation |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @template U |
||
| 21 | * |
||
| 22 | * @return Closure(callable(U): Closure(U): bool): Closure(callable(T, TKey): U): Closure(iterable<TKey, T>): Generator<TKey, T> |
||
| 23 | */ |
||
| 24 | 10 | public function __invoke(): Closure |
|
| 25 | { |
||
| 26 | 10 | return |
|
| 27 | /** |
||
| 28 | * @param callable(U): (Closure(U): bool) $comparatorCallback |
||
| 29 | * |
||
| 30 | * @return Closure(callable(T, TKey): U): Closure(iterable<TKey, T>): Generator<TKey, T> |
||
| 31 | */ |
||
| 32 | 10 | static fn (callable $comparatorCallback): Closure => |
|
| 33 | /** |
||
| 34 | * @param callable(T, TKey): U $accessorCallback |
||
| 35 | * |
||
| 36 | * @return Closure(iterable<TKey, T>): Generator<TKey, T> |
||
| 37 | */ |
||
| 38 | 10 | static function (callable $accessorCallback) use ($comparatorCallback): Closure { |
|
| 39 | /** @var ArrayIterator<int, array{0: TKey, 1: T}> $stack */ |
||
| 40 | 10 | $stack = new ArrayIterator(); |
|
| 41 | |||
| 42 | 10 | return (new Filter())()( |
|
| 43 | /** |
||
| 44 | * @param T $value |
||
| 45 | * @param TKey $key |
||
|
0 ignored issues
–
show
|
|||
| 46 | */ |
||
| 47 | 10 | static function (mixed $value, mixed $key) use ($comparatorCallback, $accessorCallback, $stack): bool { |
|
| 48 | 10 | $every = (new Every())()( |
|
| 49 | /** |
||
| 50 | * @param array{0: TKey, 1: T} $keyValuePair |
||
| 51 | */ |
||
| 52 | 10 | static fn (int $index, array $keyValuePair): bool => !$comparatorCallback($accessorCallback($value, $key))($accessorCallback($keyValuePair[1], $keyValuePair[0])) |
|
| 53 | 10 | )($stack); |
|
| 54 | |||
| 55 | 10 | if (false === $every->current()) { |
|
| 56 | 10 | return true; |
|
| 57 | } |
||
| 58 | |||
| 59 | 10 | $stack->append([$key, $value]); |
|
| 60 | |||
| 61 | 10 | return false; |
|
| 62 | 10 | } |
|
| 63 | 10 | ); |
|
| 64 | 10 | }; |
|
| 65 | } |
||
| 66 | } |
||
| 67 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths