Issues (85)

src/Operation/Reject.php (2 issues)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace loophp\collection\Operation;
6
7
use Closure;
8
use Generator;
9
use loophp\collection\Utils\CallbacksArrayReducer;
10
use loophp\iterators\FilterIterableAggregate;
11
12
/**
13
 * @immutable
14
 *
15
 * @template TKey
16
 * @template T
17
 */
18
final class Reject extends AbstractOperation
19
{
20
    /**
21
     * @return Closure(callable(T, TKey, iterable<TKey, T>): bool ...): Closure(iterable<TKey, T>): Generator<TKey, T>
22
     */
23 10
    public function __invoke(): Closure
24
    {
25 10
        return
26
            /**
27
             * @param callable(T, TKey, iterable<TKey, T>): bool ...$callbacks
28
             *
29
             * @return Closure(iterable<TKey, T>): Generator<TKey, T>
30
             */
31 10
            static fn (callable ...$callbacks): Closure =>
32
                /**
33
                 * @param iterable<TKey, T> $iterable
34
                 *
35
                 * @return Generator<TKey, T>
36
                 */
37 10
                static function (iterable $iterable) use ($callbacks): Generator {
38 10
                    $defaultCallback =
39
                        /**
40
                         * @param T $value
41
                         *
42
                         * @return T
43
                         */
44 10
                        static fn (mixed $value): mixed => $value;
45
46 10
                    $callback = [] === $callbacks ?
0 ignored issues
show
The assignment to $callback is dead and can be removed.
Loading history...
47 2
                        $defaultCallback :
48 8
                        CallbacksArrayReducer::or()($callbacks);
49
50 10
                    $callback =
51
                        /**
52
                         * @param T $current
53
                         * @param TKey $key
0 ignored issues
show
The type loophp\collection\Operation\TKey was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
54
                         * @param iterable<TKey, T> $iterable
55
                         */
56 10
                        static fn (mixed $current, mixed $key, mixed $iterable): bool => !(bool) $callback($current, $key, $iterable);
57
58 10
                    yield from new FilterIterableAggregate($iterable, $callback);
59 10
                };
60
    }
61
}
62