1 | <?php |
||
17 | trait ConstantsPart { |
||
18 | |||
19 | /** @var Map */ |
||
20 | private $constants; |
||
21 | |||
22 | 52 | private function initConstants() { |
|
25 | |||
26 | /** |
||
27 | * Sets a collection of constants |
||
28 | * |
||
29 | * @param array|PhpConstant[] $constants |
||
30 | * @return $this |
||
31 | */ |
||
32 | 1 | public function setConstants(array $constants) { |
|
50 | |||
51 | /** |
||
52 | * Adds a constant |
||
53 | * |
||
54 | * @param string|PhpConstant $nameOrConstant constant name or instance |
||
55 | * @param string $value |
||
56 | * @param bool $isExpression whether the value is an expression or not |
||
57 | * @return $this |
||
58 | */ |
||
59 | 8 | public function setConstant($nameOrConstant, string $value = null, bool $isExpression = false) { |
|
72 | |||
73 | /** |
||
74 | * Removes a constant |
||
75 | * |
||
76 | * @param string|PhpConstant $nameOrConstant constant name |
||
77 | * @throws \InvalidArgumentException If the constant cannot be found |
||
78 | * @return $this |
||
79 | */ |
||
80 | 2 | public function removeConstant($nameOrConstant) { |
|
93 | |||
94 | /** |
||
95 | * Checks whether a constant exists |
||
96 | * |
||
97 | * @param string|PhpConstant $nameOrConstant |
||
98 | * @return bool |
||
99 | */ |
||
100 | 2 | public function hasConstant($nameOrConstant): bool { |
|
107 | |||
108 | /** |
||
109 | * Returns a constant. |
||
110 | * |
||
111 | * @param string|PhpConstant $nameOrConstant |
||
112 | * @throws \InvalidArgumentException If the constant cannot be found |
||
113 | * @return PhpConstant |
||
114 | */ |
||
115 | 6 | public function getConstant($nameOrConstant): PhpConstant { |
|
126 | |||
127 | /** |
||
128 | * Returns all constants |
||
129 | * |
||
130 | * @return Map |
||
131 | */ |
||
132 | 16 | public function getConstants(): Map { |
|
135 | |||
136 | /** |
||
137 | * Returns all constant names |
||
138 | * |
||
139 | * @return Set |
||
140 | */ |
||
141 | 1 | public function getConstantNames(): Set { |
|
144 | |||
145 | /** |
||
146 | * Clears all constants |
||
147 | * |
||
148 | * @return $this |
||
149 | */ |
||
150 | 1 | public function clearConstants() { |
|
155 | } |
||
156 |