Passed
Push — master ( 885f37...6a8ce6 )
by Théo
02:06
created

SymbolsConfiguration::getExposedConstantNames()   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
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
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\Configuration;
16
17
use Humbug\PhpScoper\Symbol\NamespaceRegistry;
18
use function array_unique;
19
20
final class SymbolsConfiguration
21
{
22
    private bool $exposeGlobalConstants;
23
    private bool $exposeGlobalClasses;
24
    private bool $exposeGlobalFunctions;
25
26
    private NamespaceRegistry $excludedNamespaces;
27
    private NamespaceRegistry $exposedNamespaces;
28
29
    /**
30
     * @var list<string>
0 ignored issues
show
Bug introduced by
The type Humbug\PhpScoper\Configuration\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...
31
     */
32
    private array $exposedClassNames;
33
34
    /**
35
     * @var list<string>
36
     */
37
    private array $exposedClassRegexes;
38
39
    /**
40
     * @var list<string>
41
     */
42
    private array $exposedFunctionNames;
43
44
    /**
45
     * @var list<string>
46
     */
47
    private array $exposedFunctionRegexes;
48
49
    /**
50
     * @var list<string>
51
     */
52
    private array $exposedConstantNames;
53
54
    /**
55
     * @var list<string>
56
     */
57
    private array $exposedConstantRegexes;
58
59
    /**
60
     * @param string[] $exposedClassNames
61
     * @param string[] $exposedClassRegexes
62
     * @param string[] $exposedFunctionNames
63
     * @param string[] $exposedFunctionRegexes
64
     * @param string[] $exposedConstantNames
65
     * @param string[] $exposedConstantRegexes
66
     */
67
    public static function create(
68
        bool $exposeGlobalConstants = false,
69
        bool $exposeGlobalClasses = false,
70
        bool $exposeGlobalFunctions = false,
71
        ?NamespaceRegistry $excludedNamespaces = null,
72
        // Does not contain the list of excluded symbols which go to the
73
        // Reflector (which has no notion of namespaces)
74
        ?NamespaceRegistry $exposedNamespaces = null,
75
        array $exposedClassNames = [],
76
        array $exposedClassRegexes = [],
77
        array $exposedFunctionNames = [],
78
        array $exposedFunctionRegexes = [],
79
        array $exposedConstantNames = [],
80
        array $exposedConstantRegexes = []
81
    ): self {
82
        return new self(
83
            $exposeGlobalConstants,
84
            $exposeGlobalClasses,
85
            $exposeGlobalFunctions,
86
            $excludedNamespaces ?? NamespaceRegistry::create(),
87
            $exposedNamespaces ?? NamespaceRegistry::create(),
88
            array_unique($exposedClassNames),
89
            array_unique($exposedClassRegexes),
90
            array_unique($exposedFunctionNames),
91
            array_unique($exposedFunctionRegexes),
92
            array_unique($exposedConstantNames),
93
            array_unique($exposedConstantRegexes),
94
        );
95
    }
96
97
    /**
98
     * @param list<string> $exposedClassNames
99
     * @param list<string> $exposedClassRegexes
100
     * @param list<string> $exposedFunctionNames
101
     * @param list<string> $exposedFunctionRegexes
102
     * @param list<string> $exposedConstantNames
103
     * @param list<string> $exposedConstantRegexes
104
     */
105
    private function __construct(
106
        bool $exposeGlobalConstants,
107
        bool $exposeGlobalClasses,
108
        bool $exposeGlobalFunctions,
109
        NamespaceRegistry $excludedNamespaces,
110
        NamespaceRegistry $exposedNamespaces,
111
        array $exposedClassNames,
112
        array $exposedClassRegexes,
113
        array $exposedFunctionNames,
114
        array $exposedFunctionRegexes,
115
        array $exposedConstantNames,
116
        array $exposedConstantRegexes
117
    ) {
118
        $this->exposeGlobalConstants = $exposeGlobalConstants;
119
        $this->exposeGlobalClasses = $exposeGlobalClasses;
120
        $this->exposeGlobalFunctions = $exposeGlobalFunctions;
121
        $this->excludedNamespaces = $excludedNamespaces;
122
        $this->exposedNamespaces = $exposedNamespaces;
123
        $this->exposedClassNames = $exposedClassNames;
0 ignored issues
show
Documentation Bug introduced by
It seems like $exposedClassNames of type array is incompatible with the declared type Humbug\PhpScoper\Configuration\list of property $exposedClassNames.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
124
        $this->exposedClassRegexes = $exposedClassRegexes;
0 ignored issues
show
Documentation Bug introduced by
It seems like $exposedClassRegexes of type array is incompatible with the declared type Humbug\PhpScoper\Configuration\list of property $exposedClassRegexes.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
125
        $this->exposedFunctionNames = $exposedFunctionNames;
0 ignored issues
show
Documentation Bug introduced by
It seems like $exposedFunctionNames of type array is incompatible with the declared type Humbug\PhpScoper\Configuration\list of property $exposedFunctionNames.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
126
        $this->exposedFunctionRegexes = $exposedFunctionRegexes;
0 ignored issues
show
Documentation Bug introduced by
It seems like $exposedFunctionRegexes of type array is incompatible with the declared type Humbug\PhpScoper\Configuration\list of property $exposedFunctionRegexes.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
127
        $this->exposedConstantNames = $exposedConstantNames;
0 ignored issues
show
Documentation Bug introduced by
It seems like $exposedConstantNames of type array is incompatible with the declared type Humbug\PhpScoper\Configuration\list of property $exposedConstantNames.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
128
        $this->exposedConstantRegexes = $exposedConstantRegexes;
0 ignored issues
show
Documentation Bug introduced by
It seems like $exposedConstantRegexes of type array is incompatible with the declared type Humbug\PhpScoper\Configuration\list of property $exposedConstantRegexes.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
129
    }
130
131
    public function shouldExposeGlobalConstants(): bool
132
    {
133
        return $this->exposeGlobalConstants;
134
    }
135
136
    public function shouldExposeGlobalClasses(): bool
137
    {
138
        return $this->exposeGlobalClasses;
139
    }
140
141
    public function shouldExposeGlobalFunctions(): bool
142
    {
143
        return $this->exposeGlobalFunctions;
144
    }
145
146
    public function getExcludedNamespaces(): NamespaceRegistry
147
    {
148
        return $this->excludedNamespaces;
149
    }
150
151
    public function getExposedNamespaces(): NamespaceRegistry
152
    {
153
        return $this->exposedNamespaces;
154
    }
155
156
    /**
157
     * @return list<string>
158
     */
159
    public function getExposedClassNames(): array
160
    {
161
        return $this->exposedClassNames;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->exposedClassNames returns the type array which is incompatible with the documented return type Humbug\PhpScoper\Configuration\list.
Loading history...
162
    }
163
164
    /**
165
     * @return list<string>
166
     */
167
    public function getExposedClassRegexes(): array
168
    {
169
        return $this->exposedClassRegexes;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->exposedClassRegexes returns the type array which is incompatible with the documented return type Humbug\PhpScoper\Configuration\list.
Loading history...
170
    }
171
172
    /**
173
     * @return list<string>
174
     */
175
    public function getExposedFunctionNames(): array
176
    {
177
        return $this->exposedFunctionNames;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->exposedFunctionNames returns the type array which is incompatible with the documented return type Humbug\PhpScoper\Configuration\list.
Loading history...
178
    }
179
180
    /**
181
     * @return list<string>
182
     */
183
    public function getExposedFunctionRegexes(): array
184
    {
185
        return $this->exposedFunctionRegexes;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->exposedFunctionRegexes returns the type array which is incompatible with the documented return type Humbug\PhpScoper\Configuration\list.
Loading history...
186
    }
187
188
    /**
189
     * @return list<string>
190
     */
191
    public function getExposedConstantNames(): array
192
    {
193
        return $this->exposedConstantNames;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->exposedConstantNames returns the type array which is incompatible with the documented return type Humbug\PhpScoper\Configuration\list.
Loading history...
194
    }
195
196
    /**
197
     * @return list<string>
198
     */
199
    public function getExposedConstantRegexes(): array
200
    {
201
        return $this->exposedConstantRegexes;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->exposedConstantRegexes returns the type array which is incompatible with the documented return type Humbug\PhpScoper\Configuration\list.
Loading history...
202
    }
203
}
204