Passed
Pull Request — master (#38)
by Sergei
05:23 queued 02:36
created

TokenizerClassifier::getAvailableDeclarations()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 11
ccs 7
cts 7
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Classifier;
6
7
/**
8
 * `TokenizerClassifier` is a classifier that finds classes, interfaces, traits and enums using PHP tokenizer.
9
 */
10
final class TokenizerClassifier extends AbstractClassifier
11
{
12
    /**
13
     * @psalm-suppress UnresolvableInclude
14
     *
15
     * @return array<array-key, class-string|trait-string>
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<array-key, class-string|trait-string> at position 2 could not be parsed: Unknown type name 'array-key' at position 2 in array<array-key, class-string|trait-string>.
Loading history...
16
     */
17 17
    protected function getAvailableDeclarations(): iterable
18
    {
19 17
        $files = $this->getFiles();
20 17
        $declarations = [];
21
22 17
        foreach ($files as $file) {
23 17
            $reflectionFile = new ReflectionFile($file->getPathname());
24 17
            array_push($declarations, ...$reflectionFile->getDeclarations());
25
        }
26
27 17
        return $declarations;
28
    }
29
}
30