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.
Completed
Push — master ( dafe17...50c13d )
by Cees-Jan
16s
created

functions.php ➔ listClassesInDirectories()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 15
ccs 8
cts 8
cp 1
crap 2
rs 9.7666
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace WyriHaximus;
4
5
use Roave\BetterReflection\BetterReflection;
6
use Roave\BetterReflection\Reflector\ClassReflector;
7
use Roave\BetterReflection\SourceLocator\Type\AggregateSourceLocator;
8
use Roave\BetterReflection\SourceLocator\Type\AutoloadSourceLocator;
9
use Roave\BetterReflection\SourceLocator\Type\DirectoriesSourceLocator;
10
11
/**
12
 * get a list of all classes in the given directories.
13
 *
14
 * Based on: https://github.com/Roave/BetterReflection/blob/396a07c9d276cb9ffba581b24b2dadbb542d542e/demo/parsing-whole-directory/example2.php.
15
 *
16
 * @param string[] $directories
17
 *
18
 * @return iterable
19
 */
20
function listClassesInDirectories(string ...$directories): iterable
21
{
22 2
    $sourceLocator = new AggregateSourceLocator([
23 2
        new DirectoriesSourceLocator(
24 2
            $directories,
0 ignored issues
show
Documentation introduced by
$directories is of type array<integer,array<integer,string>>, but the function expects a array<integer,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...
25 2
            (new BetterReflection())->astLocator()
26
        ),
27
        // ↓ required to autoload parent classes/interface from another directory than /src (e.g. /vendor)
28 2
        new AutoloadSourceLocator((new BetterReflection())->astLocator()),
29
    ]);
30
31 2
    foreach ((new ClassReflector($sourceLocator))->getAllClasses() as $class) {
32 2
        yield $class->getName();
33
    }
34 2
}
35
36
/**
37
 * get a list of all classes in the given direcotory.
38
 *
39
 * @param string $directory
40
 *
41
 * @return iterable
42
 */
43
function listClassesInDirectory(string $directory): iterable
44
{
45 1
    yield from listClassesInDirectories($directory);
46
}
47