ParallelRunner::setBootstrap()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace hanneskod\readmetester\Runner;
6
7
use hanneskod\readmetester\Attribute\Isolate;
8
use hanneskod\readmetester\Example\ExampleObj;
0 ignored issues
show
Bug introduced by
The type hanneskod\readmetester\Example\ExampleObj 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...
9
use hanneskod\readmetester\Example\ExampleStoreInterface;
10
11
use function Amp\Promise\wait;
12
use function Amp\ParallelFunctions\parallelMap;
13
14
final class ParallelRunner implements RunnerInterface
15
{
16
    private string $bootstrap = '';
17
18
    public function setBootstrap(string $filename): void
19
    {
20
        $this->bootstrap = $filename;
21
    }
22
23
    public function run(ExampleStoreInterface $exampleStore): iterable
24
    {
25
        $examples = $exampleStore->getExamples();
26
27
        if ($examples instanceof \Traversable) {
28
            $examples = iterator_to_array($examples, false);
29
        }
30
31
        // @phpstan-ignore-next-line
32
        return wait(
33
            parallelMap(
34
                $examples,
0 ignored issues
show
Bug introduced by
It seems like $examples can also be of type iterable; however, parameter $array of Amp\ParallelFunctions\parallelMap() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

34
                /** @scrutinizer ignore-type */ $examples,
Loading history...
35
                function (ExampleObj $example): OutcomeInterface {
36
                    $runner = new EvalRunner();
37
                    $runner->setBootstrap($this->bootstrap);
38
                    return $runner->runExample($example);
39
                }
40
            )
41
        );
42
    }
43
}
44