1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* For the full copyright and license information, please view |
5
|
|
|
* the LICENSE file that was distributed with this source code. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
declare(strict_types=1); |
9
|
|
|
|
10
|
|
|
namespace loophp\iterators; |
11
|
|
|
|
12
|
|
|
use Generator; |
13
|
|
|
use Iterator; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @template TKey |
17
|
|
|
* @template T |
18
|
|
|
* |
19
|
|
|
* @implements Iterator<TKey, T> |
20
|
|
|
*/ |
21
|
|
|
final class ClosureIterator implements Iterator |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var callable(mixed): iterable<TKey, T> |
25
|
|
|
*/ |
26
|
|
|
private $callable; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var Generator<TKey, T, mixed, void> |
30
|
|
|
*/ |
31
|
|
|
private Generator $generator; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param callable(mixed): iterable<TKey, T> $callable |
35
|
|
|
* @param iterable<int, mixed> $parameters |
36
|
|
|
*/ |
37
|
9 |
|
public function __construct(callable $callable, private iterable $parameters = []) |
38
|
|
|
{ |
39
|
9 |
|
$this->callable = $callable; |
40
|
9 |
|
$this->generator = $this->getGenerator(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @return T |
45
|
|
|
*/ |
46
|
7 |
|
public function current(): mixed |
47
|
|
|
{ |
48
|
7 |
|
return $this->generator->current(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return TKey |
|
|
|
|
53
|
|
|
*/ |
54
|
3 |
|
public function key(): mixed |
55
|
|
|
{ |
56
|
3 |
|
return $this->generator->key(); |
57
|
|
|
} |
58
|
|
|
|
59
|
6 |
|
public function next(): void |
60
|
|
|
{ |
61
|
6 |
|
$this->generator->next(); |
62
|
|
|
} |
63
|
|
|
|
64
|
3 |
|
public function rewind(): void |
65
|
|
|
{ |
66
|
3 |
|
$this->generator = $this->getGenerator(); |
67
|
|
|
} |
68
|
|
|
|
69
|
5 |
|
public function valid(): bool |
70
|
|
|
{ |
71
|
5 |
|
return $this->generator->valid(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @return Generator<TKey, T, mixed, void> |
76
|
|
|
*/ |
77
|
9 |
|
private function getGenerator(): Generator |
78
|
|
|
{ |
79
|
9 |
|
yield from ($this->callable)(...$this->parameters); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
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