|
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\Symbol\SymbolRegistry; |
|
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
|
|
|
private SymbolRegistry $exposedClasses; |
|
30
|
|
|
private SymbolRegistry $exposedFunctions; |
|
31
|
|
|
private SymbolRegistry $exposedConstants; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var string[] |
|
35
|
|
|
*/ |
|
36
|
|
|
private array $excludedClassNames; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var string[] |
|
40
|
|
|
*/ |
|
41
|
|
|
private array $excludedFunctionNames; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @var string[] |
|
45
|
|
|
*/ |
|
46
|
|
|
private array $excludedConstantNames; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @param string[] $excludedClassNames |
|
50
|
|
|
* @param string[] $excludedFunctionNames |
|
51
|
|
|
* @param string[] $excludedConstantNames |
|
52
|
|
|
*/ |
|
53
|
|
|
public static function create( |
|
54
|
|
|
bool $exposeGlobalConstants = false, |
|
55
|
|
|
bool $exposeGlobalClasses = false, |
|
56
|
|
|
bool $exposeGlobalFunctions = false, |
|
57
|
|
|
?NamespaceRegistry $excludedNamespaces = null, |
|
58
|
|
|
// Does not contain the list of excluded symbols which go to the |
|
59
|
|
|
// Reflector (which has no notion of namespaces) |
|
60
|
|
|
?NamespaceRegistry $exposedNamespaces = null, |
|
61
|
|
|
SymbolRegistry $exposedClasses = null, |
|
62
|
|
|
SymbolRegistry $exposedFunctions = null, |
|
63
|
|
|
SymbolRegistry $exposedConstants = null, |
|
64
|
|
|
array $excludedClassNames = [], |
|
65
|
|
|
array $excludedFunctionNames = [], |
|
66
|
|
|
array $excludedConstantNames = [] |
|
67
|
|
|
): self { |
|
68
|
|
|
return new self( |
|
69
|
|
|
$exposeGlobalConstants, |
|
70
|
|
|
$exposeGlobalClasses, |
|
71
|
|
|
$exposeGlobalFunctions, |
|
72
|
|
|
$excludedNamespaces ?? NamespaceRegistry::create(), |
|
73
|
|
|
$exposedNamespaces ?? NamespaceRegistry::create(), |
|
74
|
|
|
$exposedClasses ?? SymbolRegistry::create(), |
|
75
|
|
|
$exposedFunctions ?? SymbolRegistry::create(), |
|
76
|
|
|
$exposedConstants ?? SymbolRegistry::createForConstants(), |
|
77
|
|
|
$excludedClassNames, |
|
78
|
|
|
$excludedFunctionNames, |
|
79
|
|
|
$excludedConstantNames, |
|
80
|
|
|
); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param string[] $excludedClassNames |
|
85
|
|
|
* @param string[] $excludedFunctionNames |
|
86
|
|
|
* @param string[] $excludedConstantNames |
|
87
|
|
|
*/ |
|
88
|
|
|
private function __construct( |
|
89
|
|
|
bool $exposeGlobalConstants, |
|
90
|
|
|
bool $exposeGlobalClasses, |
|
91
|
|
|
bool $exposeGlobalFunctions, |
|
92
|
|
|
NamespaceRegistry $excludedNamespaces, |
|
93
|
|
|
NamespaceRegistry $exposedNamespaces, |
|
94
|
|
|
SymbolRegistry $exposedClasses, |
|
95
|
|
|
SymbolRegistry $exposedFunctions, |
|
96
|
|
|
SymbolRegistry $exposedConstants, |
|
97
|
|
|
array $excludedClassNames, |
|
98
|
|
|
array $excludedFunctionNames, |
|
99
|
|
|
array $excludedConstantNames |
|
100
|
|
|
) { |
|
101
|
|
|
$this->exposeGlobalConstants = $exposeGlobalConstants; |
|
102
|
|
|
$this->exposeGlobalClasses = $exposeGlobalClasses; |
|
103
|
|
|
$this->exposeGlobalFunctions = $exposeGlobalFunctions; |
|
104
|
|
|
$this->excludedNamespaces = $excludedNamespaces; |
|
105
|
|
|
$this->exposedNamespaces = $exposedNamespaces; |
|
106
|
|
|
$this->exposedClasses = $exposedClasses; |
|
107
|
|
|
$this->exposedFunctions = $exposedFunctions; |
|
108
|
|
|
$this->exposedConstants = $exposedConstants; |
|
109
|
|
|
$this->excludedClassNames = $excludedClassNames; |
|
110
|
|
|
$this->excludedFunctionNames = $excludedFunctionNames; |
|
111
|
|
|
$this->excludedConstantNames = $excludedConstantNames; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
public function shouldExposeGlobalConstants(): bool |
|
115
|
|
|
{ |
|
116
|
|
|
return $this->exposeGlobalConstants; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
public function shouldExposeGlobalClasses(): bool |
|
120
|
|
|
{ |
|
121
|
|
|
return $this->exposeGlobalClasses; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
public function shouldExposeGlobalFunctions(): bool |
|
125
|
|
|
{ |
|
126
|
|
|
return $this->exposeGlobalFunctions; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
public function getExcludedNamespaces(): NamespaceRegistry |
|
130
|
|
|
{ |
|
131
|
|
|
return $this->excludedNamespaces; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
public function getExposedNamespaces(): NamespaceRegistry |
|
135
|
|
|
{ |
|
136
|
|
|
return $this->exposedNamespaces; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
public function getExposedClasses(): SymbolRegistry |
|
140
|
|
|
{ |
|
141
|
|
|
return $this->exposedClasses; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
public function getExposedFunctions(): SymbolRegistry |
|
145
|
|
|
{ |
|
146
|
|
|
return $this->exposedFunctions; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
public function getExposedConstants(): SymbolRegistry |
|
150
|
|
|
{ |
|
151
|
|
|
return $this->exposedConstants; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* @return string[] |
|
156
|
|
|
*/ |
|
157
|
|
|
public function getExcludedClassNames(): array |
|
158
|
|
|
{ |
|
159
|
|
|
return $this->excludedClassNames; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* @return string[] |
|
164
|
|
|
*/ |
|
165
|
|
|
public function getExcludedFunctionNames(): array |
|
166
|
|
|
{ |
|
167
|
|
|
return $this->excludedFunctionNames; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* @return string[] |
|
172
|
|
|
*/ |
|
173
|
|
|
public function getExcludedConstantNames(): array |
|
174
|
|
|
{ |
|
175
|
|
|
return $this->excludedConstantNames; |
|
176
|
|
|
} |
|
177
|
|
|
} |
|
178
|
|
|
|