1 | <?php |
||
27 | class ClassDeclaration extends NamedDeclaration implements ReplaceableInterface |
||
28 | { |
||
29 | use CommentTrait; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private $extends = ''; |
||
35 | |||
36 | /** |
||
37 | * @var array |
||
38 | */ |
||
39 | private $interfaces = []; |
||
40 | |||
41 | /** |
||
42 | * Class traits. |
||
43 | * |
||
44 | * @var array |
||
45 | */ |
||
46 | private $traits = []; |
||
47 | |||
48 | /** |
||
49 | * @var ConstantAggregator |
||
50 | */ |
||
51 | private $constants = null; |
||
52 | |||
53 | /** |
||
54 | * @var PropertyAggregator |
||
55 | */ |
||
56 | private $properties = null; |
||
57 | |||
58 | /** |
||
59 | * @var MethodAggregator |
||
60 | */ |
||
61 | private $methods = null; |
||
62 | |||
63 | /** |
||
64 | * @param string $name |
||
65 | * @param string $extends |
||
66 | * @param array $interfaces |
||
67 | * @param string $comment |
||
68 | * |
||
69 | * @throws ReactorException When name is invalid. |
||
70 | */ |
||
71 | public function __construct( |
||
90 | |||
91 | /** |
||
92 | * {@inheritdoc} |
||
93 | */ |
||
94 | public function setName(string $name): ClassDeclaration |
||
98 | |||
99 | /** |
||
100 | * @param string $class Class name. |
||
101 | * |
||
102 | * @return self |
||
103 | */ |
||
104 | public function setExtends($class): ClassDeclaration |
||
110 | |||
111 | /** |
||
112 | * @return string |
||
113 | */ |
||
114 | public function getExtends(): string |
||
118 | |||
119 | /** |
||
120 | * @param string $interface |
||
121 | * |
||
122 | * @return bool |
||
123 | */ |
||
124 | public function hasInterface(string $interface): bool |
||
130 | |||
131 | /** |
||
132 | * Declare class interfaces. |
||
133 | * |
||
134 | * @param array $interfaces |
||
135 | * |
||
136 | * @return self |
||
137 | */ |
||
138 | public function setInterfaces(array $interfaces): ClassDeclaration |
||
147 | |||
148 | /** |
||
149 | * @param string $interface |
||
150 | * |
||
151 | * @return self |
||
152 | */ |
||
153 | public function addInterface(string $interface): ClassDeclaration |
||
159 | |||
160 | /** |
||
161 | * @param string $interface |
||
162 | * |
||
163 | * @return self |
||
164 | */ |
||
165 | public function removeInterface(string $interface): ClassDeclaration |
||
171 | |||
172 | /** |
||
173 | * Declared interfaces. |
||
174 | * |
||
175 | * @return array |
||
176 | */ |
||
177 | public function getInterfaces(): array |
||
181 | |||
182 | /** |
||
183 | * @param string $class |
||
184 | * |
||
185 | * @return bool |
||
186 | */ |
||
187 | public function hasTrait(string $class): bool |
||
193 | |||
194 | /** |
||
195 | * Declare class traits. |
||
196 | * |
||
197 | * @param array $traits |
||
198 | * |
||
199 | * @return self |
||
200 | */ |
||
201 | public function setTraits(array $traits): ClassDeclaration |
||
210 | |||
211 | /** |
||
212 | * @param string $class |
||
213 | * |
||
214 | * @return self |
||
215 | */ |
||
216 | public function addTrait(string $class): ClassDeclaration |
||
222 | |||
223 | /** |
||
224 | * @param string $class |
||
225 | * |
||
226 | * @return self |
||
227 | */ |
||
228 | public function removeTrait(string $class): ClassDeclaration |
||
234 | |||
235 | /** |
||
236 | * @return array |
||
237 | */ |
||
238 | public function getUses(): array |
||
242 | |||
243 | /** |
||
244 | * @return ConstantAggregator|ConstantDeclaration[] |
||
245 | */ |
||
246 | public function getConstants(): ConstantAggregator |
||
250 | |||
251 | /** |
||
252 | * @param string $name |
||
253 | * |
||
254 | * @return ConstantDeclaration |
||
255 | */ |
||
256 | public function constant(string $name): ConstantDeclaration |
||
260 | |||
261 | /** |
||
262 | * @return PropertyAggregator|PropertyDeclaration[] |
||
263 | */ |
||
264 | public function getProperties(): PropertyAggregator |
||
268 | |||
269 | /** |
||
270 | * @param string $name |
||
271 | * |
||
272 | * @return PropertyDeclaration |
||
273 | */ |
||
274 | public function property(string $name): PropertyDeclaration |
||
278 | |||
279 | /** |
||
280 | * @return MethodAggregator|MethodDeclaration[] |
||
281 | */ |
||
282 | public function getMethods(): MethodAggregator |
||
286 | |||
287 | /** |
||
288 | * @param string $name |
||
289 | * |
||
290 | * @return MethodDeclaration |
||
291 | */ |
||
292 | public function method(string $name): MethodDeclaration |
||
296 | |||
297 | /** |
||
298 | * {@inheritdoc} |
||
299 | * |
||
300 | * @return self |
||
301 | */ |
||
302 | public function replace($search, $replace): ClassDeclaration |
||
310 | |||
311 | /** |
||
312 | * @param int $indentLevel |
||
313 | * |
||
314 | * @return string |
||
315 | */ |
||
316 | public function render(int $indentLevel = 0): string |
||
348 | |||
349 | /** |
||
350 | * @param int $indentLevel |
||
351 | * |
||
352 | * @return string |
||
353 | */ |
||
354 | private function renderTraits(int $indentLevel = 0): string |
||
363 | |||
364 | /** |
||
365 | * @param int $indentLevel |
||
366 | * |
||
367 | * @return string |
||
368 | */ |
||
369 | protected function renderBody(int $indentLevel): string |
||
390 | } |