GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Mapping::gather()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 3.0032

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 13
cts 14
cp 0.9286
rs 9.6333
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 3.0032
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Tools\CommandBus;
4
5
use PackageVersions\Versions;
6
use function WyriHaximus\iteratorOrArrayToArray;
7
use WyriHaximus\Tactician\CommandHandler\Mapper;
8
9
/**
10
 * @internal
11
 */
12
final class Mapping
13
{
14 2
    public static function resolve(iterable $directories, ?string $cacheFile): iterable
15
    {
16 2
        if ($cacheFile !== null && \file_exists($cacheFile)) {
17
            try {
18
                return Cache::read($cacheFile);
19
            } catch (\Throwable $et) {
20
                // void
21
            }
22
        }
23
24 2
        $commandToHandlerMap = self::gather($directories);
25
26 2
        if ($cacheFile !== null && \is_dir(\dirname($cacheFile))) {
27
            $commandToHandlerMap = iteratorOrArrayToArray($commandToHandlerMap);
28
            Cache::write($cacheFile, $commandToHandlerMap);
29
        }
30
31 2
        return $commandToHandlerMap;
32
    }
33
34 2
    private static function gather(iterable $directories): iterable
35
    {
36 2
        $mapperVersion = \version_compare(
37 2
            \explode(
38 2
                '@',
39 2
                Versions::getVersion('wyrihaximus/tactician-command-handler-mapper')
40 2
            )[0],
41 2
            '2.0.0',
42 2
            '<'
43
        );
44
45 2
        foreach ($directories as $path => $namespace) {
46 1
            $args = [$path];
47 1
            if ($mapperVersion) {
48
                $args[] = $namespace;
49
            }
50 1
            yield from Mapper::map(...$args);
0 ignored issues
show
Documentation introduced by
$args is of type array<integer,?>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
51
        }
52 2
    }
53
}
54