Passed
Pull Request — master (#565)
by Théo
02:31
created

SymbolsRegistry::count()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the humbug/php-scoper package.
7
 *
8
 * Copyright (c) 2017 Théo FIDRY <[email protected]>,
9
 *                    Pádraic Brady <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace Humbug\PhpScoper\Symbol;
16
17
use Countable;
18
use PhpParser\Node\Name\FullyQualified;
19
use function array_values;
20
use function count;
21
22
final class SymbolsRegistry implements Countable
23
{
24
    /**
25
     * @var array<string, array{string, string}>
26
     */
27
    private array $recordedFunctions;
28
29
    /**
30
     * @var array<string, array{string, string}>
31
     */
32
    private array $recordedClasses;
33
34
    public function recordFunction(FullyQualified $original, FullyQualified $alias): void
35
    {
36
        $this->recordedFunctions[(string) $original] = [(string) $original, (string) $alias];
37
    }
38
39
    /**
40
     * @return list<string>
0 ignored issues
show
Bug introduced by
The type Humbug\PhpScoper\Symbol\list 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...
41
     */
42
    public function getRecordedFunctions(): array
43
    {
44
        return array_values($this->recordedFunctions);
0 ignored issues
show
Bug Best Practice introduced by
The expression return array_values($this->recordedFunctions) returns the type array which is incompatible with the documented return type Humbug\PhpScoper\Symbol\list.
Loading history...
45
    }
46
47
    public function recordClass(FullyQualified $original, FullyQualified $alias): void
48
    {
49
        $this->recordedClasses[(string) $original] = [(string) $original, (string) $alias];
50
    }
51
52
    /**
53
     * @return list<string>
54
     */
55
    public function getRecordedClasses(): array
56
    {
57
        return array_values($this->recordedClasses);
0 ignored issues
show
Bug Best Practice introduced by
The expression return array_values($this->recordedClasses) returns the type array which is incompatible with the documented return type Humbug\PhpScoper\Symbol\list.
Loading history...
58
    }
59
60
    public function count(): int
61
    {
62
        return count($this->recordedFunctions) + count($this->recordedClasses);
63
    }
64
}
65