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 Humbug\PhpScoper\Whitelist; |
19
|
|
|
use function array_unique; |
20
|
|
|
|
21
|
|
|
final class SymbolsConfiguration |
22
|
|
|
{ |
23
|
|
|
private bool $exposeGlobalConstants; |
24
|
|
|
private bool $exposeGlobalClasses; |
25
|
|
|
private bool $exposeGlobalFunctions; |
26
|
|
|
|
27
|
|
|
private NamespaceRegistry $excludedNamespaces; |
28
|
|
|
private NamespaceRegistry $exposedNamespaces; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var list<string> |
|
|
|
|
32
|
|
|
*/ |
33
|
|
|
private array $exposedClassNames; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var list<string> |
37
|
|
|
*/ |
38
|
|
|
private array $exposedClassRegexes; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var list<string> |
42
|
|
|
*/ |
43
|
|
|
private array $exposedFunctionNames; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var list<string> |
47
|
|
|
*/ |
48
|
|
|
private array $exposedFunctionRegexes; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var list<string> |
52
|
|
|
*/ |
53
|
|
|
private array $exposedConstantNames; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var list<string> |
57
|
|
|
*/ |
58
|
|
|
private array $exposedConstantRegexes; |
59
|
|
|
|
60
|
|
|
public static function fromWhitelist(Whitelist $whitelist): self |
61
|
|
|
{ |
62
|
|
|
$exposedSymbols = $whitelist->getExposedSymbols(); |
63
|
|
|
$exposedSymbolsPatterns = $whitelist->getExposedSymbolsPatterns(); |
64
|
|
|
|
65
|
|
|
return self::create( |
66
|
|
|
$whitelist->exposeGlobalConstants(), |
67
|
|
|
$whitelist->exposeGlobalClasses(), |
68
|
|
|
$whitelist->exposeGlobalFunctions(), |
69
|
|
|
$whitelist->getExcludedNamespaces(), |
70
|
|
|
null, |
71
|
|
|
$exposedSymbols, |
72
|
|
|
$exposedSymbolsPatterns, |
73
|
|
|
$exposedSymbols, |
74
|
|
|
$exposedSymbolsPatterns, |
75
|
|
|
$whitelist->getExposedConstants(), |
76
|
|
|
$exposedSymbolsPatterns, |
77
|
|
|
); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @param string[] $exposedClassNames |
82
|
|
|
* @param string[] $exposedClassRegexes |
83
|
|
|
* @param string[] $exposedFunctionNames |
84
|
|
|
* @param string[] $exposedFunctionRegexes |
85
|
|
|
* @param string[] $exposedConstantNames |
86
|
|
|
* @param string[] $exposedConstantRegexes |
87
|
|
|
*/ |
88
|
|
|
public static function create( |
89
|
|
|
bool $exposeGlobalConstants = true, |
90
|
|
|
bool $exposeGlobalClasses = true, |
91
|
|
|
bool $exposeGlobalFunctions = true, |
92
|
|
|
?NamespaceRegistry $excludedNamespaces = null, |
93
|
|
|
// Does not contain the list of excluded symbols which go to the |
94
|
|
|
// Reflector (which has no notion of namespaces) |
95
|
|
|
?NamespaceRegistry $exposedNamespaces = null, |
96
|
|
|
array $exposedClassNames = [], |
97
|
|
|
array $exposedClassRegexes = [], |
98
|
|
|
array $exposedFunctionNames = [], |
99
|
|
|
array $exposedFunctionRegexes = [], |
100
|
|
|
array $exposedConstantNames = [], |
101
|
|
|
array $exposedConstantRegexes = [] |
102
|
|
|
): self { |
103
|
|
|
return new self( |
104
|
|
|
$exposeGlobalConstants, |
105
|
|
|
$exposeGlobalClasses, |
106
|
|
|
$exposeGlobalFunctions, |
107
|
|
|
$excludedNamespaces ?? NamespaceRegistry::create(), |
108
|
|
|
$exposedNamespaces ?? NamespaceRegistry::create(), |
109
|
|
|
array_unique($exposedClassNames), |
110
|
|
|
array_unique($exposedClassRegexes), |
111
|
|
|
array_unique($exposedFunctionNames), |
112
|
|
|
array_unique($exposedFunctionRegexes), |
113
|
|
|
array_unique($exposedConstantNames), |
114
|
|
|
array_unique($exposedConstantRegexes), |
115
|
|
|
); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @param list<string> $exposedClassNames |
120
|
|
|
* @param list<string> $exposedClassRegexes |
121
|
|
|
* @param list<string> $exposedFunctionNames |
122
|
|
|
* @param list<string> $exposedFunctionRegexes |
123
|
|
|
* @param list<string> $exposedConstantNames |
124
|
|
|
* @param list<string> $exposedConstantRegexes |
125
|
|
|
*/ |
126
|
|
|
private function __construct( |
127
|
|
|
bool $exposeGlobalConstants, |
128
|
|
|
bool $exposeGlobalClasses, |
129
|
|
|
bool $exposeGlobalFunctions, |
130
|
|
|
NamespaceRegistry $excludedNamespaces, |
131
|
|
|
NamespaceRegistry $exposedNamespaces, |
132
|
|
|
array $exposedClassNames, |
133
|
|
|
array $exposedClassRegexes, |
134
|
|
|
array $exposedFunctionNames, |
135
|
|
|
array $exposedFunctionRegexes, |
136
|
|
|
array $exposedConstantNames, |
137
|
|
|
array $exposedConstantRegexes |
138
|
|
|
) { |
139
|
|
|
$this->exposeGlobalConstants = $exposeGlobalConstants; |
140
|
|
|
$this->exposeGlobalClasses = $exposeGlobalClasses; |
141
|
|
|
$this->exposeGlobalFunctions = $exposeGlobalFunctions; |
142
|
|
|
$this->excludedNamespaces = $excludedNamespaces; |
143
|
|
|
$this->exposedNamespaces = $exposedNamespaces; |
144
|
|
|
$this->exposedClassNames = $exposedClassNames; |
|
|
|
|
145
|
|
|
$this->exposedClassRegexes = $exposedClassRegexes; |
|
|
|
|
146
|
|
|
$this->exposedFunctionNames = $exposedFunctionNames; |
|
|
|
|
147
|
|
|
$this->exposedFunctionRegexes = $exposedFunctionRegexes; |
|
|
|
|
148
|
|
|
$this->exposedConstantNames = $exposedConstantNames; |
|
|
|
|
149
|
|
|
$this->exposedConstantRegexes = $exposedConstantRegexes; |
|
|
|
|
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
public function shouldExposeGlobalConstants(): bool |
153
|
|
|
{ |
154
|
|
|
return $this->exposeGlobalConstants; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
public function shouldExposeGlobalClasses(): bool |
158
|
|
|
{ |
159
|
|
|
return $this->exposeGlobalClasses; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
public function shouldExposeGlobalFunctions(): bool |
163
|
|
|
{ |
164
|
|
|
return $this->exposeGlobalFunctions; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
public function getExcludedNamespaces(): NamespaceRegistry |
168
|
|
|
{ |
169
|
|
|
return $this->excludedNamespaces; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
public function getExposedNamespaces(): NamespaceRegistry |
173
|
|
|
{ |
174
|
|
|
return $this->exposedNamespaces; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @return list<string> |
179
|
|
|
*/ |
180
|
|
|
public function getExposedClassNames(): array |
181
|
|
|
{ |
182
|
|
|
return $this->exposedClassNames; |
|
|
|
|
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @return list<string> |
187
|
|
|
*/ |
188
|
|
|
public function getExposedClassRegexes(): array |
189
|
|
|
{ |
190
|
|
|
return $this->exposedClassRegexes; |
|
|
|
|
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* @return list<string> |
195
|
|
|
*/ |
196
|
|
|
public function getExposedFunctionNames(): array |
197
|
|
|
{ |
198
|
|
|
return $this->exposedFunctionNames; |
|
|
|
|
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @return list<string> |
203
|
|
|
*/ |
204
|
|
|
public function getExposedFunctionRegexes(): array |
205
|
|
|
{ |
206
|
|
|
return $this->exposedFunctionRegexes; |
|
|
|
|
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* @return list<string> |
211
|
|
|
*/ |
212
|
|
|
public function getExposedConstantNames(): array |
213
|
|
|
{ |
214
|
|
|
return $this->exposedConstantNames; |
|
|
|
|
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* @return list<string> |
219
|
|
|
*/ |
220
|
|
|
public function getExposedConstantRegexes(): array |
221
|
|
|
{ |
222
|
|
|
return $this->exposedConstantRegexes; |
|
|
|
|
223
|
|
|
} |
224
|
|
|
} |
225
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths