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
|
|
|
public static function create( |
34
|
|
|
bool $exposeGlobalConstants = false, |
35
|
|
|
bool $exposeGlobalClasses = false, |
36
|
|
|
bool $exposeGlobalFunctions = false, |
37
|
|
|
?NamespaceRegistry $excludedNamespaces = null, |
38
|
|
|
// Does not contain the list of excluded symbols which go to the |
39
|
|
|
// Reflector (which has no notion of namespaces) |
40
|
|
|
?NamespaceRegistry $exposedNamespaces = null, |
41
|
|
|
SymbolRegistry $exposedClasses = null, |
42
|
|
|
SymbolRegistry $exposedFunctions = null, |
43
|
|
|
SymbolRegistry $exposedConstants = null |
44
|
|
|
): self { |
45
|
|
|
return new self( |
46
|
|
|
$exposeGlobalConstants, |
47
|
|
|
$exposeGlobalClasses, |
48
|
|
|
$exposeGlobalFunctions, |
49
|
|
|
$excludedNamespaces ?? NamespaceRegistry::create(), |
50
|
|
|
$exposedNamespaces ?? NamespaceRegistry::create(), |
51
|
|
|
$exposedClasses ?? SymbolRegistry::create(), |
52
|
|
|
$exposedFunctions ?? SymbolRegistry::create(), |
53
|
|
|
$exposedConstants ?? SymbolRegistry::createForConstants(), |
54
|
|
|
); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
private function __construct( |
58
|
|
|
bool $exposeGlobalConstants, |
59
|
|
|
bool $exposeGlobalClasses, |
60
|
|
|
bool $exposeGlobalFunctions, |
61
|
|
|
NamespaceRegistry $excludedNamespaces, |
62
|
|
|
NamespaceRegistry $exposedNamespaces, |
63
|
|
|
SymbolRegistry $exposedClasses, |
64
|
|
|
SymbolRegistry $exposedFunctions, |
65
|
|
|
SymbolRegistry $exposedConstants |
66
|
|
|
) { |
67
|
|
|
$this->exposeGlobalConstants = $exposeGlobalConstants; |
68
|
|
|
$this->exposeGlobalClasses = $exposeGlobalClasses; |
69
|
|
|
$this->exposeGlobalFunctions = $exposeGlobalFunctions; |
70
|
|
|
$this->excludedNamespaces = $excludedNamespaces; |
71
|
|
|
$this->exposedNamespaces = $exposedNamespaces; |
72
|
|
|
$this->exposedClasses = $exposedClasses; |
73
|
|
|
$this->exposedFunctions = $exposedFunctions; |
74
|
|
|
$this->exposedConstants = $exposedConstants; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function shouldExposeGlobalConstants(): bool |
78
|
|
|
{ |
79
|
|
|
return $this->exposeGlobalConstants; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function shouldExposeGlobalClasses(): bool |
83
|
|
|
{ |
84
|
|
|
return $this->exposeGlobalClasses; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function shouldExposeGlobalFunctions(): bool |
88
|
|
|
{ |
89
|
|
|
return $this->exposeGlobalFunctions; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function getExcludedNamespaces(): NamespaceRegistry |
93
|
|
|
{ |
94
|
|
|
return $this->excludedNamespaces; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function getExposedNamespaces(): NamespaceRegistry |
98
|
|
|
{ |
99
|
|
|
return $this->exposedNamespaces; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function getExposedClasses(): SymbolRegistry |
103
|
|
|
{ |
104
|
|
|
return $this->exposedClasses; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function getExposedFunctions(): SymbolRegistry |
108
|
|
|
{ |
109
|
|
|
return $this->exposedFunctions; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function getExposedConstants(): SymbolRegistry |
113
|
|
|
{ |
114
|
|
|
return $this->exposedConstants; |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|