1use std::fmt::Debug;
2
3use serde::Serialize;
4use strum::Display;
5
6use mago_span::HasSpan;
7use mago_span::Span;
8
9use crate::ast::Program;
10use crate::ast::ast::*;
11
12#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Serialize, PartialOrd, Ord, Display)]
13#[serde(tag = "type", content = "value")]
14#[repr(u8)]
15#[non_exhaustive]
16pub enum NodeKind {
17 Program,
18 ConstantAccess,
19 Access,
20 ClassConstantAccess,
21 NullSafePropertyAccess,
22 PropertyAccess,
23 StaticPropertyAccess,
24 Argument,
25 ArgumentList,
26 PartialArgument,
27 PartialArgumentList,
28 NamedArgument,
29 NamedPlaceholderArgument,
30 PlaceholderArgument,
31 PositionalArgument,
32 VariadicPlaceholderArgument,
33 Array,
34 ArrayAccess,
35 ArrayAppend,
36 ArrayElement,
37 KeyValueArrayElement,
38 LegacyArray,
39 List,
40 MissingArrayElement,
41 ValueArrayElement,
42 VariadicArrayElement,
43 Attribute,
44 AttributeList,
45 Block,
46 Call,
47 FunctionCall,
48 MethodCall,
49 NullSafeMethodCall,
50 StaticMethodCall,
51 PartialApplication,
52 FunctionPartialApplication,
53 MethodPartialApplication,
54 StaticMethodPartialApplication,
55 ClassLikeConstant,
56 ClassLikeConstantItem,
57 EnumCase,
58 EnumCaseBackedItem,
59 EnumCaseItem,
60 EnumCaseUnitItem,
61 Extends,
62 Implements,
63 ClassLikeConstantSelector,
64 ClassLikeMember,
65 ClassLikeMemberExpressionSelector,
66 ClassLikeMemberSelector,
67 Method,
68 MethodAbstractBody,
69 MethodBody,
70 HookedProperty,
71 PlainProperty,
72 Property,
73 PropertyAbstractItem,
74 PropertyConcreteItem,
75 PropertyHook,
76 PropertyHookAbstractBody,
77 PropertyHookBody,
78 PropertyHookConcreteBody,
79 PropertyHookConcreteExpressionBody,
80 PropertyHookList,
81 PropertyItem,
82 TraitUse,
83 TraitUseAbsoluteMethodReference,
84 TraitUseAbstractSpecification,
85 TraitUseAdaptation,
86 TraitUseAliasAdaptation,
87 TraitUseConcreteSpecification,
88 TraitUseMethodReference,
89 TraitUsePrecedenceAdaptation,
90 TraitUseSpecification,
91 AnonymousClass,
92 Class,
93 Enum,
94 EnumBackingTypeHint,
95 Interface,
96 Trait,
97 Clone,
98 Constant,
99 ConstantItem,
100 Construct,
101 DieConstruct,
102 EmptyConstruct,
103 EvalConstruct,
104 ExitConstruct,
105 IncludeConstruct,
106 IncludeOnceConstruct,
107 IssetConstruct,
108 PrintConstruct,
109 RequireConstruct,
110 RequireOnceConstruct,
111 If,
112 IfBody,
113 IfColonDelimitedBody,
114 IfColonDelimitedBodyElseClause,
115 IfColonDelimitedBodyElseIfClause,
116 IfStatementBody,
117 IfStatementBodyElseClause,
118 IfStatementBodyElseIfClause,
119 Match,
120 MatchArm,
121 MatchDefaultArm,
122 MatchExpressionArm,
123 Switch,
124 SwitchBody,
125 SwitchBraceDelimitedBody,
126 SwitchCase,
127 SwitchCaseSeparator,
128 SwitchColonDelimitedBody,
129 SwitchDefaultCase,
130 SwitchExpressionCase,
131 Declare,
132 DeclareBody,
133 DeclareColonDelimitedBody,
134 DeclareItem,
135 EchoTag,
136 Echo,
137 Expression,
138 Binary,
139 BinaryOperator,
140 UnaryPrefix,
141 UnaryPrefixOperator,
142 UnaryPostfix,
143 UnaryPostfixOperator,
144 Parenthesized,
145 ArrowFunction,
146 Closure,
147 ClosureUseClause,
148 ClosureUseClauseVariable,
149 Function,
150 FunctionLikeParameter,
151 FunctionLikeParameterDefaultValue,
152 FunctionLikeParameterList,
153 FunctionLikeReturnTypeHint,
154 Global,
155 Goto,
156 Label,
157 HaltCompiler,
158 FullyQualifiedIdentifier,
159 Identifier,
160 LocalIdentifier,
161 QualifiedIdentifier,
162 Inline,
163 Instantiation,
164 Keyword,
165 Literal,
166 Pipe,
167 LiteralFloat,
168 LiteralInteger,
169 LiteralString,
170 MagicConstant,
171 Modifier,
172 Namespace,
173 NamespaceBody,
174 NamespaceImplicitBody,
175 Assignment,
176 AssignmentOperator,
177 Conditional,
178 DoWhile,
179 Foreach,
180 ForeachBody,
181 ForeachColonDelimitedBody,
182 ForeachKeyValueTarget,
183 ForeachTarget,
184 ForeachValueTarget,
185 For,
186 ForBody,
187 ForColonDelimitedBody,
188 While,
189 WhileBody,
190 WhileColonDelimitedBody,
191 Break,
192 Continue,
193 Return,
194 Static,
195 StaticAbstractItem,
196 StaticConcreteItem,
197 StaticItem,
198 Try,
199 TryCatchClause,
200 TryFinallyClause,
201 MaybeTypedUseItem,
202 MixedUseItemList,
203 TypedUseItemList,
204 TypedUseItemSequence,
205 Use,
206 UseItem,
207 UseItemAlias,
208 UseItemSequence,
209 UseItems,
210 UseType,
211 Yield,
212 YieldFrom,
213 YieldPair,
214 YieldValue,
215 Statement,
216 ExpressionStatement,
217 BracedExpressionStringPart,
218 DocumentString,
219 InterpolatedString,
220 LiteralStringPart,
221 ShellExecuteString,
222 CompositeString,
223 StringPart,
224 ClosingTag,
225 FullOpeningTag,
226 OpeningTag,
227 ShortOpeningTag,
228 Terminator,
229 Throw,
230 Hint,
231 IntersectionHint,
232 NullableHint,
233 ParenthesizedHint,
234 UnionHint,
235 Unset,
236 DirectVariable,
237 IndirectVariable,
238 NestedVariable,
239 Variable,
240}
241
242#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Serialize, PartialOrd, Ord, Display)]
243#[serde(tag = "type", content = "value")]
244#[repr(u8)]
245#[non_exhaustive]
246pub enum Node<'ast, 'arena> {
247 Program(&'ast Program<'arena>),
248 Access(&'ast Access<'arena>),
249 ConstantAccess(&'ast ConstantAccess<'arena>),
250 ClassConstantAccess(&'ast ClassConstantAccess<'arena>),
251 NullSafePropertyAccess(&'ast NullSafePropertyAccess<'arena>),
252 PropertyAccess(&'ast PropertyAccess<'arena>),
253 StaticPropertyAccess(&'ast StaticPropertyAccess<'arena>),
254 Argument(&'ast Argument<'arena>),
255 ArgumentList(&'ast ArgumentList<'arena>),
256 PartialArgument(&'ast PartialArgument<'arena>),
257 PartialArgumentList(&'ast PartialArgumentList<'arena>),
258 NamedArgument(&'ast NamedArgument<'arena>),
259 NamedPlaceholderArgument(&'ast NamedPlaceholderArgument<'arena>),
260 PlaceholderArgument(&'ast PlaceholderArgument),
261 PositionalArgument(&'ast PositionalArgument<'arena>),
262 VariadicPlaceholderArgument(&'ast VariadicPlaceholderArgument),
263 Array(&'ast Array<'arena>),
264 ArrayAccess(&'ast ArrayAccess<'arena>),
265 ArrayAppend(&'ast ArrayAppend<'arena>),
266 ArrayElement(&'ast ArrayElement<'arena>),
267 KeyValueArrayElement(&'ast KeyValueArrayElement<'arena>),
268 LegacyArray(&'ast LegacyArray<'arena>),
269 List(&'ast List<'arena>),
270 MissingArrayElement(&'ast MissingArrayElement),
271 ValueArrayElement(&'ast ValueArrayElement<'arena>),
272 VariadicArrayElement(&'ast VariadicArrayElement<'arena>),
273 Attribute(&'ast Attribute<'arena>),
274 AttributeList(&'ast AttributeList<'arena>),
275 Block(&'ast Block<'arena>),
276 Call(&'ast Call<'arena>),
277 FunctionCall(&'ast FunctionCall<'arena>),
278 MethodCall(&'ast MethodCall<'arena>),
279 NullSafeMethodCall(&'ast NullSafeMethodCall<'arena>),
280 StaticMethodCall(&'ast StaticMethodCall<'arena>),
281 PartialApplication(&'ast PartialApplication<'arena>),
282 FunctionPartialApplication(&'ast FunctionPartialApplication<'arena>),
283 MethodPartialApplication(&'ast MethodPartialApplication<'arena>),
284 StaticMethodPartialApplication(&'ast StaticMethodPartialApplication<'arena>),
285 ClassLikeConstant(&'ast ClassLikeConstant<'arena>),
286 ClassLikeConstantItem(&'ast ClassLikeConstantItem<'arena>),
287 EnumCase(&'ast EnumCase<'arena>),
288 EnumCaseBackedItem(&'ast EnumCaseBackedItem<'arena>),
289 EnumCaseItem(&'ast EnumCaseItem<'arena>),
290 EnumCaseUnitItem(&'ast EnumCaseUnitItem<'arena>),
291 Extends(&'ast Extends<'arena>),
292 Implements(&'ast Implements<'arena>),
293 ClassLikeConstantSelector(&'ast ClassLikeConstantSelector<'arena>),
294 ClassLikeMember(&'ast ClassLikeMember<'arena>),
295 ClassLikeMemberExpressionSelector(&'ast ClassLikeMemberExpressionSelector<'arena>),
296 ClassLikeMemberSelector(&'ast ClassLikeMemberSelector<'arena>),
297 Method(&'ast Method<'arena>),
298 MethodAbstractBody(&'ast MethodAbstractBody),
299 MethodBody(&'ast MethodBody<'arena>),
300 HookedProperty(&'ast HookedProperty<'arena>),
301 PlainProperty(&'ast PlainProperty<'arena>),
302 Property(&'ast Property<'arena>),
303 PropertyAbstractItem(&'ast PropertyAbstractItem<'arena>),
304 PropertyConcreteItem(&'ast PropertyConcreteItem<'arena>),
305 PropertyHook(&'ast PropertyHook<'arena>),
306 PropertyHookAbstractBody(&'ast PropertyHookAbstractBody),
307 PropertyHookBody(&'ast PropertyHookBody<'arena>),
308 PropertyHookConcreteBody(&'ast PropertyHookConcreteBody<'arena>),
309 PropertyHookConcreteExpressionBody(&'ast PropertyHookConcreteExpressionBody<'arena>),
310 PropertyHookList(&'ast PropertyHookList<'arena>),
311 PropertyItem(&'ast PropertyItem<'arena>),
312 TraitUse(&'ast TraitUse<'arena>),
313 TraitUseAbsoluteMethodReference(&'ast TraitUseAbsoluteMethodReference<'arena>),
314 TraitUseAbstractSpecification(&'ast TraitUseAbstractSpecification<'arena>),
315 TraitUseAdaptation(&'ast TraitUseAdaptation<'arena>),
316 TraitUseAliasAdaptation(&'ast TraitUseAliasAdaptation<'arena>),
317 TraitUseConcreteSpecification(&'ast TraitUseConcreteSpecification<'arena>),
318 TraitUseMethodReference(&'ast TraitUseMethodReference<'arena>),
319 TraitUsePrecedenceAdaptation(&'ast TraitUsePrecedenceAdaptation<'arena>),
320 TraitUseSpecification(&'ast TraitUseSpecification<'arena>),
321 AnonymousClass(&'ast AnonymousClass<'arena>),
322 Class(&'ast Class<'arena>),
323 Enum(&'ast Enum<'arena>),
324 EnumBackingTypeHint(&'ast EnumBackingTypeHint<'arena>),
325 Interface(&'ast Interface<'arena>),
326 Trait(&'ast Trait<'arena>),
327 Clone(&'ast Clone<'arena>),
328 Constant(&'ast Constant<'arena>),
329 ConstantItem(&'ast ConstantItem<'arena>),
330 Construct(&'ast Construct<'arena>),
331 DieConstruct(&'ast DieConstruct<'arena>),
332 EmptyConstruct(&'ast EmptyConstruct<'arena>),
333 EvalConstruct(&'ast EvalConstruct<'arena>),
334 ExitConstruct(&'ast ExitConstruct<'arena>),
335 IncludeConstruct(&'ast IncludeConstruct<'arena>),
336 IncludeOnceConstruct(&'ast IncludeOnceConstruct<'arena>),
337 IssetConstruct(&'ast IssetConstruct<'arena>),
338 PrintConstruct(&'ast PrintConstruct<'arena>),
339 RequireConstruct(&'ast RequireConstruct<'arena>),
340 RequireOnceConstruct(&'ast RequireOnceConstruct<'arena>),
341 If(&'ast If<'arena>),
342 IfBody(&'ast IfBody<'arena>),
343 IfColonDelimitedBody(&'ast IfColonDelimitedBody<'arena>),
344 IfColonDelimitedBodyElseClause(&'ast IfColonDelimitedBodyElseClause<'arena>),
345 IfColonDelimitedBodyElseIfClause(&'ast IfColonDelimitedBodyElseIfClause<'arena>),
346 IfStatementBody(&'ast IfStatementBody<'arena>),
347 IfStatementBodyElseClause(&'ast IfStatementBodyElseClause<'arena>),
348 IfStatementBodyElseIfClause(&'ast IfStatementBodyElseIfClause<'arena>),
349 Match(&'ast Match<'arena>),
350 MatchArm(&'ast MatchArm<'arena>),
351 MatchDefaultArm(&'ast MatchDefaultArm<'arena>),
352 MatchExpressionArm(&'ast MatchExpressionArm<'arena>),
353 Switch(&'ast Switch<'arena>),
354 SwitchBody(&'ast SwitchBody<'arena>),
355 SwitchBraceDelimitedBody(&'ast SwitchBraceDelimitedBody<'arena>),
356 SwitchCase(&'ast SwitchCase<'arena>),
357 SwitchCaseSeparator(&'ast SwitchCaseSeparator),
358 SwitchColonDelimitedBody(&'ast SwitchColonDelimitedBody<'arena>),
359 SwitchDefaultCase(&'ast SwitchDefaultCase<'arena>),
360 SwitchExpressionCase(&'ast SwitchExpressionCase<'arena>),
361 Declare(&'ast Declare<'arena>),
362 DeclareBody(&'ast DeclareBody<'arena>),
363 DeclareColonDelimitedBody(&'ast DeclareColonDelimitedBody<'arena>),
364 DeclareItem(&'ast DeclareItem<'arena>),
365 EchoTag(&'ast EchoTag<'arena>),
366 Echo(&'ast Echo<'arena>),
367 Expression(&'ast Expression<'arena>),
368 Binary(&'ast Binary<'arena>),
369 BinaryOperator(&'ast BinaryOperator<'arena>),
370 UnaryPrefix(&'ast UnaryPrefix<'arena>),
371 UnaryPrefixOperator(&'ast UnaryPrefixOperator<'arena>),
372 UnaryPostfix(&'ast UnaryPostfix<'arena>),
373 UnaryPostfixOperator(&'ast UnaryPostfixOperator),
374 Parenthesized(&'ast Parenthesized<'arena>),
375 ArrowFunction(&'ast ArrowFunction<'arena>),
376 Closure(&'ast Closure<'arena>),
377 ClosureUseClause(&'ast ClosureUseClause<'arena>),
378 ClosureUseClauseVariable(&'ast ClosureUseClauseVariable<'arena>),
379 Function(&'ast Function<'arena>),
380 FunctionLikeParameter(&'ast FunctionLikeParameter<'arena>),
381 FunctionLikeParameterDefaultValue(&'ast FunctionLikeParameterDefaultValue<'arena>),
382 FunctionLikeParameterList(&'ast FunctionLikeParameterList<'arena>),
383 FunctionLikeReturnTypeHint(&'ast FunctionLikeReturnTypeHint<'arena>),
384 Global(&'ast Global<'arena>),
385 Goto(&'ast Goto<'arena>),
386 Label(&'ast Label<'arena>),
387 HaltCompiler(&'ast HaltCompiler<'arena>),
388 FullyQualifiedIdentifier(&'ast FullyQualifiedIdentifier<'arena>),
389 Identifier(&'ast Identifier<'arena>),
390 LocalIdentifier(&'ast LocalIdentifier<'arena>),
391 QualifiedIdentifier(&'ast QualifiedIdentifier<'arena>),
392 Inline(&'ast Inline<'arena>),
393 Instantiation(&'ast Instantiation<'arena>),
394 Keyword(&'ast Keyword<'arena>),
395 Literal(&'ast Literal<'arena>),
396 LiteralFloat(&'ast LiteralFloat<'arena>),
397 LiteralInteger(&'ast LiteralInteger<'arena>),
398 LiteralString(&'ast LiteralString<'arena>),
399 MagicConstant(&'ast MagicConstant<'arena>),
400 Modifier(&'ast Modifier<'arena>),
401 Namespace(&'ast Namespace<'arena>),
402 NamespaceBody(&'ast NamespaceBody<'arena>),
403 NamespaceImplicitBody(&'ast NamespaceImplicitBody<'arena>),
404 Assignment(&'ast Assignment<'arena>),
405 AssignmentOperator(&'ast AssignmentOperator),
406 Conditional(&'ast Conditional<'arena>),
407 DoWhile(&'ast DoWhile<'arena>),
408 Foreach(&'ast Foreach<'arena>),
409 ForeachBody(&'ast ForeachBody<'arena>),
410 ForeachColonDelimitedBody(&'ast ForeachColonDelimitedBody<'arena>),
411 ForeachKeyValueTarget(&'ast ForeachKeyValueTarget<'arena>),
412 ForeachTarget(&'ast ForeachTarget<'arena>),
413 ForeachValueTarget(&'ast ForeachValueTarget<'arena>),
414 For(&'ast For<'arena>),
415 ForBody(&'ast ForBody<'arena>),
416 ForColonDelimitedBody(&'ast ForColonDelimitedBody<'arena>),
417 While(&'ast While<'arena>),
418 WhileBody(&'ast WhileBody<'arena>),
419 WhileColonDelimitedBody(&'ast WhileColonDelimitedBody<'arena>),
420 Break(&'ast Break<'arena>),
421 Continue(&'ast Continue<'arena>),
422 Return(&'ast Return<'arena>),
423 Static(&'ast Static<'arena>),
424 StaticAbstractItem(&'ast StaticAbstractItem<'arena>),
425 StaticConcreteItem(&'ast StaticConcreteItem<'arena>),
426 StaticItem(&'ast StaticItem<'arena>),
427 Try(&'ast Try<'arena>),
428 TryCatchClause(&'ast TryCatchClause<'arena>),
429 TryFinallyClause(&'ast TryFinallyClause<'arena>),
430 MaybeTypedUseItem(&'ast MaybeTypedUseItem<'arena>),
431 MixedUseItemList(&'ast MixedUseItemList<'arena>),
432 TypedUseItemList(&'ast TypedUseItemList<'arena>),
433 TypedUseItemSequence(&'ast TypedUseItemSequence<'arena>),
434 Use(&'ast Use<'arena>),
435 UseItem(&'ast UseItem<'arena>),
436 UseItemAlias(&'ast UseItemAlias<'arena>),
437 UseItemSequence(&'ast UseItemSequence<'arena>),
438 UseItems(&'ast UseItems<'arena>),
439 UseType(&'ast UseType<'arena>),
440 Yield(&'ast Yield<'arena>),
441 YieldFrom(&'ast YieldFrom<'arena>),
442 YieldPair(&'ast YieldPair<'arena>),
443 YieldValue(&'ast YieldValue<'arena>),
444 Statement(&'ast Statement<'arena>),
445 ExpressionStatement(&'ast ExpressionStatement<'arena>),
446 BracedExpressionStringPart(&'ast BracedExpressionStringPart<'arena>),
447 DocumentString(&'ast DocumentString<'arena>),
448 InterpolatedString(&'ast InterpolatedString<'arena>),
449 LiteralStringPart(&'ast LiteralStringPart<'arena>),
450 ShellExecuteString(&'ast ShellExecuteString<'arena>),
451 CompositeString(&'ast CompositeString<'arena>),
452 StringPart(&'ast StringPart<'arena>),
453 ClosingTag(&'ast ClosingTag),
454 FullOpeningTag(&'ast FullOpeningTag<'arena>),
455 OpeningTag(&'ast OpeningTag<'arena>),
456 ShortOpeningTag(&'ast ShortOpeningTag),
457 Terminator(&'ast Terminator<'arena>),
458 Throw(&'ast Throw<'arena>),
459 Hint(&'ast Hint<'arena>),
460 IntersectionHint(&'ast IntersectionHint<'arena>),
461 NullableHint(&'ast NullableHint<'arena>),
462 ParenthesizedHint(&'ast ParenthesizedHint<'arena>),
463 UnionHint(&'ast UnionHint<'arena>),
464 Unset(&'ast Unset<'arena>),
465 DirectVariable(&'ast DirectVariable<'arena>),
466 IndirectVariable(&'ast IndirectVariable<'arena>),
467 NestedVariable(&'ast NestedVariable<'arena>),
468 Variable(&'ast Variable<'arena>),
469 Pipe(&'ast Pipe<'arena>),
470}
471
472impl<'ast, 'arena> Node<'ast, 'arena> {
473 #[inline]
474 pub fn filter_map<F, T: 'ast>(&self, f: F) -> Vec<T>
475 where
476 F: Fn(&Node<'ast, 'arena>) -> Option<T>,
477 {
478 self.filter_map_internal(&f)
479 }
480
481 #[inline]
482 fn filter_map_internal<F, T: 'ast>(&self, f: &F) -> Vec<T>
483 where
484 F: Fn(&Node<'ast, 'arena>) -> Option<T>,
485 {
486 let mut result = vec![];
487 for child in self.children() {
488 result.extend(child.filter_map_internal(f));
489 }
490
491 if let Some(child) = f(self) {
492 result.push(child);
493 }
494
495 result
496 }
497
498 #[inline]
499 pub const fn is_declaration(&self) -> bool {
500 matches!(
501 self,
502 Self::Class(_) | Self::Interface(_) | Self::Trait(_) | Self::Enum(_) | Self::Function(_) | Self::Method(_)
503 )
504 }
505
506 #[inline]
507 pub const fn is_statement(&self) -> bool {
508 matches!(
509 self,
510 Self::Statement(_)
511 | Self::OpeningTag(_)
512 | Self::FullOpeningTag(_)
513 | Self::ShortOpeningTag(_)
514 | Self::ClosingTag(_)
515 | Self::Inline(_)
516 | Self::Namespace(_)
517 | Self::Use(_)
518 | Self::Class(_)
519 | Self::Interface(_)
520 | Self::Trait(_)
521 | Self::Enum(_)
522 | Self::Block(_)
523 | Self::Constant(_)
524 | Self::Function(_)
525 | Self::Declare(_)
526 | Self::Goto(_)
527 | Self::Label(_)
528 | Self::Try(_)
529 | Self::Foreach(_)
530 | Self::For(_)
531 | Self::While(_)
532 | Self::DoWhile(_)
533 | Self::Continue(_)
534 | Self::Break(_)
535 | Self::Switch(_)
536 | Self::If(_)
537 | Self::Return(_)
538 | Self::ExpressionStatement(_)
539 | Self::Echo(_)
540 | Self::EchoTag(_)
541 | Self::Global(_)
542 | Self::Static(_)
543 | Self::HaltCompiler(_)
544 | Self::Unset(_)
545 )
546 }
547
548 #[inline]
549 pub const fn kind(&self) -> NodeKind {
550 match &self {
551 Self::Program(_) => NodeKind::Program,
552 Self::Access(_) => NodeKind::Access,
553 Self::ConstantAccess(_) => NodeKind::ConstantAccess,
554 Self::ClassConstantAccess(_) => NodeKind::ClassConstantAccess,
555 Self::NullSafePropertyAccess(_) => NodeKind::NullSafePropertyAccess,
556 Self::PropertyAccess(_) => NodeKind::PropertyAccess,
557 Self::StaticPropertyAccess(_) => NodeKind::StaticPropertyAccess,
558 Self::Argument(_) => NodeKind::Argument,
559 Self::ArgumentList(_) => NodeKind::ArgumentList,
560 Self::PartialArgument(_) => NodeKind::PartialArgument,
561 Self::PartialArgumentList(_) => NodeKind::PartialArgumentList,
562 Self::NamedArgument(_) => NodeKind::NamedArgument,
563 Self::NamedPlaceholderArgument(_) => NodeKind::NamedPlaceholderArgument,
564 Self::PlaceholderArgument(_) => NodeKind::PlaceholderArgument,
565 Self::PositionalArgument(_) => NodeKind::PositionalArgument,
566 Self::VariadicPlaceholderArgument(_) => NodeKind::VariadicPlaceholderArgument,
567 Self::Array(_) => NodeKind::Array,
568 Self::ArrayAccess(_) => NodeKind::ArrayAccess,
569 Self::ArrayAppend(_) => NodeKind::ArrayAppend,
570 Self::ArrayElement(_) => NodeKind::ArrayElement,
571 Self::KeyValueArrayElement(_) => NodeKind::KeyValueArrayElement,
572 Self::LegacyArray(_) => NodeKind::LegacyArray,
573 Self::List(_) => NodeKind::List,
574 Self::MissingArrayElement(_) => NodeKind::MissingArrayElement,
575 Self::ValueArrayElement(_) => NodeKind::ValueArrayElement,
576 Self::VariadicArrayElement(_) => NodeKind::VariadicArrayElement,
577 Self::Attribute(_) => NodeKind::Attribute,
578 Self::AttributeList(_) => NodeKind::AttributeList,
579 Self::Block(_) => NodeKind::Block,
580 Self::Call(_) => NodeKind::Call,
581 Self::FunctionCall(_) => NodeKind::FunctionCall,
582 Self::MethodCall(_) => NodeKind::MethodCall,
583 Self::NullSafeMethodCall(_) => NodeKind::NullSafeMethodCall,
584 Self::StaticMethodCall(_) => NodeKind::StaticMethodCall,
585 Self::PartialApplication(_) => NodeKind::PartialApplication,
586 Self::FunctionPartialApplication(_) => NodeKind::FunctionPartialApplication,
587 Self::MethodPartialApplication(_) => NodeKind::MethodPartialApplication,
588 Self::StaticMethodPartialApplication(_) => NodeKind::StaticMethodPartialApplication,
589 Self::ClassLikeConstant(_) => NodeKind::ClassLikeConstant,
590 Self::ClassLikeConstantItem(_) => NodeKind::ClassLikeConstantItem,
591 Self::EnumCase(_) => NodeKind::EnumCase,
592 Self::EnumCaseBackedItem(_) => NodeKind::EnumCaseBackedItem,
593 Self::EnumCaseItem(_) => NodeKind::EnumCaseItem,
594 Self::EnumCaseUnitItem(_) => NodeKind::EnumCaseUnitItem,
595 Self::Extends(_) => NodeKind::Extends,
596 Self::Implements(_) => NodeKind::Implements,
597 Self::ClassLikeConstantSelector(_) => NodeKind::ClassLikeConstantSelector,
598 Self::ClassLikeMember(_) => NodeKind::ClassLikeMember,
599 Self::ClassLikeMemberExpressionSelector(_) => NodeKind::ClassLikeMemberExpressionSelector,
600 Self::ClassLikeMemberSelector(_) => NodeKind::ClassLikeMemberSelector,
601 Self::Method(_) => NodeKind::Method,
602 Self::MethodAbstractBody(_) => NodeKind::MethodAbstractBody,
603 Self::MethodBody(_) => NodeKind::MethodBody,
604 Self::HookedProperty(_) => NodeKind::HookedProperty,
605 Self::PlainProperty(_) => NodeKind::PlainProperty,
606 Self::Property(_) => NodeKind::Property,
607 Self::PropertyAbstractItem(_) => NodeKind::PropertyAbstractItem,
608 Self::PropertyConcreteItem(_) => NodeKind::PropertyConcreteItem,
609 Self::PropertyHook(_) => NodeKind::PropertyHook,
610 Self::PropertyHookAbstractBody(_) => NodeKind::PropertyHookAbstractBody,
611 Self::PropertyHookBody(_) => NodeKind::PropertyHookBody,
612 Self::PropertyHookConcreteBody(_) => NodeKind::PropertyHookConcreteBody,
613 Self::PropertyHookConcreteExpressionBody(_) => NodeKind::PropertyHookConcreteExpressionBody,
614 Self::PropertyHookList(_) => NodeKind::PropertyHookList,
615 Self::PropertyItem(_) => NodeKind::PropertyItem,
616 Self::TraitUse(_) => NodeKind::TraitUse,
617 Self::TraitUseAbsoluteMethodReference(_) => NodeKind::TraitUseAbsoluteMethodReference,
618 Self::TraitUseAbstractSpecification(_) => NodeKind::TraitUseAbstractSpecification,
619 Self::TraitUseAdaptation(_) => NodeKind::TraitUseAdaptation,
620 Self::TraitUseAliasAdaptation(_) => NodeKind::TraitUseAliasAdaptation,
621 Self::TraitUseConcreteSpecification(_) => NodeKind::TraitUseConcreteSpecification,
622 Self::TraitUseMethodReference(_) => NodeKind::TraitUseMethodReference,
623 Self::TraitUsePrecedenceAdaptation(_) => NodeKind::TraitUsePrecedenceAdaptation,
624 Self::TraitUseSpecification(_) => NodeKind::TraitUseSpecification,
625 Self::AnonymousClass(_) => NodeKind::AnonymousClass,
626 Self::Class(_) => NodeKind::Class,
627 Self::Enum(_) => NodeKind::Enum,
628 Self::EnumBackingTypeHint(_) => NodeKind::EnumBackingTypeHint,
629 Self::Interface(_) => NodeKind::Interface,
630 Self::Trait(_) => NodeKind::Trait,
631 Self::Clone(_) => NodeKind::Clone,
632 Self::Constant(_) => NodeKind::Constant,
633 Self::ConstantItem(_) => NodeKind::ConstantItem,
634 Self::Construct(_) => NodeKind::Construct,
635 Self::DieConstruct(_) => NodeKind::DieConstruct,
636 Self::EmptyConstruct(_) => NodeKind::EmptyConstruct,
637 Self::EvalConstruct(_) => NodeKind::EvalConstruct,
638 Self::ExitConstruct(_) => NodeKind::ExitConstruct,
639 Self::IncludeConstruct(_) => NodeKind::IncludeConstruct,
640 Self::IncludeOnceConstruct(_) => NodeKind::IncludeOnceConstruct,
641 Self::IssetConstruct(_) => NodeKind::IssetConstruct,
642 Self::PrintConstruct(_) => NodeKind::PrintConstruct,
643 Self::RequireConstruct(_) => NodeKind::RequireConstruct,
644 Self::RequireOnceConstruct(_) => NodeKind::RequireOnceConstruct,
645 Self::If(_) => NodeKind::If,
646 Self::IfBody(_) => NodeKind::IfBody,
647 Self::IfColonDelimitedBody(_) => NodeKind::IfColonDelimitedBody,
648 Self::IfColonDelimitedBodyElseClause(_) => NodeKind::IfColonDelimitedBodyElseClause,
649 Self::IfColonDelimitedBodyElseIfClause(_) => NodeKind::IfColonDelimitedBodyElseIfClause,
650 Self::IfStatementBody(_) => NodeKind::IfStatementBody,
651 Self::IfStatementBodyElseClause(_) => NodeKind::IfStatementBodyElseClause,
652 Self::IfStatementBodyElseIfClause(_) => NodeKind::IfStatementBodyElseIfClause,
653 Self::Match(_) => NodeKind::Match,
654 Self::MatchArm(_) => NodeKind::MatchArm,
655 Self::MatchDefaultArm(_) => NodeKind::MatchDefaultArm,
656 Self::MatchExpressionArm(_) => NodeKind::MatchExpressionArm,
657 Self::Switch(_) => NodeKind::Switch,
658 Self::SwitchBody(_) => NodeKind::SwitchBody,
659 Self::SwitchBraceDelimitedBody(_) => NodeKind::SwitchBraceDelimitedBody,
660 Self::SwitchCase(_) => NodeKind::SwitchCase,
661 Self::SwitchCaseSeparator(_) => NodeKind::SwitchCaseSeparator,
662 Self::SwitchColonDelimitedBody(_) => NodeKind::SwitchColonDelimitedBody,
663 Self::SwitchDefaultCase(_) => NodeKind::SwitchDefaultCase,
664 Self::SwitchExpressionCase(_) => NodeKind::SwitchExpressionCase,
665 Self::Declare(_) => NodeKind::Declare,
666 Self::DeclareBody(_) => NodeKind::DeclareBody,
667 Self::DeclareColonDelimitedBody(_) => NodeKind::DeclareColonDelimitedBody,
668 Self::DeclareItem(_) => NodeKind::DeclareItem,
669 Self::Echo(_) => NodeKind::Echo,
670 Self::Expression(_) => NodeKind::Expression,
671 Self::Binary(_) => NodeKind::Binary,
672 Self::BinaryOperator(_) => NodeKind::BinaryOperator,
673 Self::UnaryPrefix(_) => NodeKind::UnaryPrefix,
674 Self::UnaryPrefixOperator(_) => NodeKind::UnaryPrefixOperator,
675 Self::UnaryPostfix(_) => NodeKind::UnaryPostfix,
676 Self::UnaryPostfixOperator(_) => NodeKind::UnaryPostfixOperator,
677 Self::Parenthesized(_) => NodeKind::Parenthesized,
678 Self::ArrowFunction(_) => NodeKind::ArrowFunction,
679 Self::Closure(_) => NodeKind::Closure,
680 Self::ClosureUseClause(_) => NodeKind::ClosureUseClause,
681 Self::ClosureUseClauseVariable(_) => NodeKind::ClosureUseClauseVariable,
682 Self::Function(_) => NodeKind::Function,
683 Self::FunctionLikeParameter(_) => NodeKind::FunctionLikeParameter,
684 Self::FunctionLikeParameterDefaultValue(_) => NodeKind::FunctionLikeParameterDefaultValue,
685 Self::FunctionLikeParameterList(_) => NodeKind::FunctionLikeParameterList,
686 Self::FunctionLikeReturnTypeHint(_) => NodeKind::FunctionLikeReturnTypeHint,
687 Self::Global(_) => NodeKind::Global,
688 Self::Goto(_) => NodeKind::Goto,
689 Self::Label(_) => NodeKind::Label,
690 Self::HaltCompiler(_) => NodeKind::HaltCompiler,
691 Self::FullyQualifiedIdentifier(_) => NodeKind::FullyQualifiedIdentifier,
692 Self::Identifier(_) => NodeKind::Identifier,
693 Self::LocalIdentifier(_) => NodeKind::LocalIdentifier,
694 Self::QualifiedIdentifier(_) => NodeKind::QualifiedIdentifier,
695 Self::Inline(_) => NodeKind::Inline,
696 Self::Instantiation(_) => NodeKind::Instantiation,
697 Self::Keyword(_) => NodeKind::Keyword,
698 Self::Literal(_) => NodeKind::Literal,
699 Self::LiteralFloat(_) => NodeKind::LiteralFloat,
700 Self::LiteralInteger(_) => NodeKind::LiteralInteger,
701 Self::LiteralString(_) => NodeKind::LiteralString,
702 Self::MagicConstant(_) => NodeKind::MagicConstant,
703 Self::Modifier(_) => NodeKind::Modifier,
704 Self::Namespace(_) => NodeKind::Namespace,
705 Self::NamespaceBody(_) => NodeKind::NamespaceBody,
706 Self::NamespaceImplicitBody(_) => NodeKind::NamespaceImplicitBody,
707 Self::Assignment(_) => NodeKind::Assignment,
708 Self::AssignmentOperator(_) => NodeKind::AssignmentOperator,
709 Self::Conditional(_) => NodeKind::Conditional,
710 Self::DoWhile(_) => NodeKind::DoWhile,
711 Self::Foreach(_) => NodeKind::Foreach,
712 Self::ForeachBody(_) => NodeKind::ForeachBody,
713 Self::ForeachColonDelimitedBody(_) => NodeKind::ForeachColonDelimitedBody,
714 Self::ForeachKeyValueTarget(_) => NodeKind::ForeachKeyValueTarget,
715 Self::ForeachTarget(_) => NodeKind::ForeachTarget,
716 Self::ForeachValueTarget(_) => NodeKind::ForeachValueTarget,
717 Self::For(_) => NodeKind::For,
718 Self::ForBody(_) => NodeKind::ForBody,
719 Self::ForColonDelimitedBody(_) => NodeKind::ForColonDelimitedBody,
720 Self::While(_) => NodeKind::While,
721 Self::WhileBody(_) => NodeKind::WhileBody,
722 Self::WhileColonDelimitedBody(_) => NodeKind::WhileColonDelimitedBody,
723 Self::Break(_) => NodeKind::Break,
724 Self::Continue(_) => NodeKind::Continue,
725 Self::Return(_) => NodeKind::Return,
726 Self::Static(_) => NodeKind::Static,
727 Self::StaticAbstractItem(_) => NodeKind::StaticAbstractItem,
728 Self::StaticConcreteItem(_) => NodeKind::StaticConcreteItem,
729 Self::StaticItem(_) => NodeKind::StaticItem,
730 Self::Try(_) => NodeKind::Try,
731 Self::TryCatchClause(_) => NodeKind::TryCatchClause,
732 Self::TryFinallyClause(_) => NodeKind::TryFinallyClause,
733 Self::MaybeTypedUseItem(_) => NodeKind::MaybeTypedUseItem,
734 Self::MixedUseItemList(_) => NodeKind::MixedUseItemList,
735 Self::TypedUseItemList(_) => NodeKind::TypedUseItemList,
736 Self::TypedUseItemSequence(_) => NodeKind::TypedUseItemSequence,
737 Self::Use(_) => NodeKind::Use,
738 Self::UseItem(_) => NodeKind::UseItem,
739 Self::UseItemAlias(_) => NodeKind::UseItemAlias,
740 Self::UseItemSequence(_) => NodeKind::UseItemSequence,
741 Self::UseItems(_) => NodeKind::UseItems,
742 Self::UseType(_) => NodeKind::UseType,
743 Self::Yield(_) => NodeKind::Yield,
744 Self::YieldFrom(_) => NodeKind::YieldFrom,
745 Self::YieldPair(_) => NodeKind::YieldPair,
746 Self::YieldValue(_) => NodeKind::YieldValue,
747 Self::Statement(_) => NodeKind::Statement,
748 Self::ExpressionStatement(_) => NodeKind::ExpressionStatement,
749 Self::BracedExpressionStringPart(_) => NodeKind::BracedExpressionStringPart,
750 Self::DocumentString(_) => NodeKind::DocumentString,
751 Self::InterpolatedString(_) => NodeKind::InterpolatedString,
752 Self::LiteralStringPart(_) => NodeKind::LiteralStringPart,
753 Self::ShellExecuteString(_) => NodeKind::ShellExecuteString,
754 Self::CompositeString(_) => NodeKind::CompositeString,
755 Self::StringPart(_) => NodeKind::StringPart,
756 Self::ClosingTag(_) => NodeKind::ClosingTag,
757 Self::EchoTag(_) => NodeKind::EchoTag,
758 Self::FullOpeningTag(_) => NodeKind::FullOpeningTag,
759 Self::OpeningTag(_) => NodeKind::OpeningTag,
760 Self::ShortOpeningTag(_) => NodeKind::ShortOpeningTag,
761 Self::Terminator(_) => NodeKind::Terminator,
762 Self::Throw(_) => NodeKind::Throw,
763 Self::Hint(_) => NodeKind::Hint,
764 Self::IntersectionHint(_) => NodeKind::IntersectionHint,
765 Self::NullableHint(_) => NodeKind::NullableHint,
766 Self::ParenthesizedHint(_) => NodeKind::ParenthesizedHint,
767 Self::UnionHint(_) => NodeKind::UnionHint,
768 Self::Unset(_) => NodeKind::Unset,
769 Self::DirectVariable(_) => NodeKind::DirectVariable,
770 Self::IndirectVariable(_) => NodeKind::IndirectVariable,
771 Self::NestedVariable(_) => NodeKind::NestedVariable,
772 Self::Variable(_) => NodeKind::Variable,
773 Self::Pipe(_) => NodeKind::Pipe,
774 }
775 }
776
777 #[inline]
778 pub fn children(&self) -> Vec<Node<'ast, 'arena>> {
779 match &self {
780 Node::Program(node) => {
781 let mut children = vec![];
782 for node in node.statements.as_slice() {
783 children.push(Node::Statement(node));
784 }
785
786 children
787 }
788 Node::Access(node) => match &node {
789 Access::Property(node) => vec![Node::PropertyAccess(node)],
790 Access::NullSafeProperty(node) => vec![Node::NullSafePropertyAccess(node)],
791 Access::StaticProperty(node) => vec![Node::StaticPropertyAccess(node)],
792 Access::ClassConstant(node) => vec![Node::ClassConstantAccess(node)],
793 },
794 Node::ConstantAccess(node) => {
795 vec![Node::Identifier(&node.name)]
796 }
797 Node::ClassConstantAccess(node) => {
798 vec![Node::Expression(node.class), Node::ClassLikeConstantSelector(&node.constant)]
799 }
800 Node::NullSafePropertyAccess(node) => {
801 vec![Node::Expression(node.object), Node::ClassLikeMemberSelector(&node.property)]
802 }
803 Node::PropertyAccess(node) => {
804 vec![Node::Expression(node.object), Node::ClassLikeMemberSelector(&node.property)]
805 }
806 Node::StaticPropertyAccess(node) => {
807 vec![Node::Expression(node.class), Node::Variable(&node.property)]
808 }
809 Node::Argument(node) => match &node {
810 Argument::Named(node) => vec![Node::NamedArgument(node)],
811 Argument::Positional(node) => vec![Node::PositionalArgument(node)],
812 },
813 Node::ArgumentList(node) => {
814 let mut children = vec![];
815 for node in node.arguments.as_slice() {
816 children.push(Node::Argument(node));
817 }
818
819 children
820 }
821 Node::PartialArgument(node) => match &node {
822 PartialArgument::Named(node) => vec![Node::NamedArgument(node)],
823 PartialArgument::NamedPlaceholder(node) => vec![Node::NamedPlaceholderArgument(node)],
824 PartialArgument::Placeholder(node) => vec![Node::PlaceholderArgument(node)],
825 PartialArgument::Positional(node) => vec![Node::PositionalArgument(node)],
826 PartialArgument::VariadicPlaceholder(node) => vec![Node::VariadicPlaceholderArgument(node)],
827 },
828 Node::PartialArgumentList(node) => {
829 let mut children = vec![];
830 for node in node.arguments.as_slice() {
831 children.push(Node::PartialArgument(node));
832 }
833
834 children
835 }
836 Node::NamedArgument(node) => {
837 vec![Node::LocalIdentifier(&node.name), Node::Expression(&node.value)]
838 }
839 Node::NamedPlaceholderArgument(node) => {
840 vec![Node::LocalIdentifier(&node.name)]
841 }
842 Node::PlaceholderArgument(_) => vec![],
843 Node::PositionalArgument(node) => vec![Node::Expression(&node.value)],
844 Node::VariadicPlaceholderArgument(_) => vec![],
845 Node::Array(node) => {
846 let mut children = vec![];
847 for node in node.elements.as_slice() {
848 children.push(Node::ArrayElement(node));
849 }
850
851 children
852 }
853 Node::ArrayAccess(node) => {
854 vec![Node::Expression(node.array), Node::Expression(node.index)]
855 }
856 Node::ArrayAppend(node) => {
857 vec![Node::Expression(node.array)]
858 }
859 Node::ArrayElement(node) => match &node {
860 ArrayElement::KeyValue(node) => vec![Node::KeyValueArrayElement(node)],
861 ArrayElement::Missing(node) => vec![Node::MissingArrayElement(node)],
862 ArrayElement::Value(node) => vec![Node::ValueArrayElement(node)],
863 ArrayElement::Variadic(node) => vec![Node::VariadicArrayElement(node)],
864 },
865 Node::KeyValueArrayElement(node) => {
866 vec![Node::Expression(node.key), Node::Expression(node.value)]
867 }
868 Node::LegacyArray(node) => Vec::from_iter(node.elements.iter().map(Node::ArrayElement)),
869 Node::List(node) => Vec::from_iter(node.elements.iter().map(Node::ArrayElement)),
870 Node::MissingArrayElement(_) => vec![],
871 Node::ValueArrayElement(node) => vec![Node::Expression(node.value)],
872 Node::VariadicArrayElement(node) => vec![Node::Expression(node.value)],
873 Node::Attribute(node) => {
874 let mut children = vec![Node::Identifier(&node.name)];
875 if let Some(arguments) = &node.argument_list {
876 children.push(Node::ArgumentList(arguments));
877 }
878
879 children
880 }
881 Node::AttributeList(node) => Vec::from_iter(node.attributes.iter().map(Node::Attribute)),
882 Node::Block(node) => Vec::from_iter(node.statements.iter().map(Node::Statement)),
883 Node::Call(node) => match node {
884 Call::Function(node) => vec![Node::FunctionCall(node)],
885 Call::Method(node) => vec![Node::MethodCall(node)],
886 Call::NullSafeMethod(node) => vec![Node::NullSafeMethodCall(node)],
887 Call::StaticMethod(node) => vec![Node::StaticMethodCall(node)],
888 },
889 Node::FunctionCall(node) => {
890 vec![Node::Expression(node.function), Node::ArgumentList(&node.argument_list)]
891 }
892 Node::MethodCall(node) => {
893 vec![
894 Node::Expression(node.object),
895 Node::ClassLikeMemberSelector(&node.method),
896 Node::ArgumentList(&node.argument_list),
897 ]
898 }
899 Node::NullSafeMethodCall(node) => {
900 vec![
901 Node::Expression(node.object),
902 Node::ClassLikeMemberSelector(&node.method),
903 Node::ArgumentList(&node.argument_list),
904 ]
905 }
906 Node::StaticMethodCall(node) => {
907 vec![
908 Node::Expression(node.class),
909 Node::ClassLikeMemberSelector(&node.method),
910 Node::ArgumentList(&node.argument_list),
911 ]
912 }
913 Node::PartialApplication(node) => match node {
914 PartialApplication::Function(node) => vec![Node::FunctionPartialApplication(node)],
915 PartialApplication::Method(node) => vec![Node::MethodPartialApplication(node)],
916 PartialApplication::StaticMethod(node) => vec![Node::StaticMethodPartialApplication(node)],
917 },
918 Node::FunctionPartialApplication(node) => {
919 vec![Node::Expression(node.function), Node::PartialArgumentList(&node.argument_list)]
920 }
921 Node::MethodPartialApplication(node) => {
922 vec![
923 Node::Expression(node.object),
924 Node::ClassLikeMemberSelector(&node.method),
925 Node::PartialArgumentList(&node.argument_list),
926 ]
927 }
928 Node::StaticMethodPartialApplication(node) => {
929 vec![
930 Node::Expression(node.class),
931 Node::ClassLikeMemberSelector(&node.method),
932 Node::PartialArgumentList(&node.argument_list),
933 ]
934 }
935 Node::ClassLikeConstant(node) => {
936 let mut children = vec![];
937 for attr in node.attribute_lists.iter() {
938 children.push(Node::AttributeList(attr));
939 }
940
941 children.extend(node.modifiers.iter().map(Node::Modifier));
942 children.push(Node::Keyword(&node.r#const));
943 if let Some(hint) = &node.hint {
944 children.push(Node::Hint(hint));
945 }
946
947 children.extend(node.items.iter().map(Node::ClassLikeConstantItem));
948 children.push(Node::Terminator(&node.terminator));
949
950 children
951 }
952 Node::ClassLikeConstantItem(node) => {
953 vec![Node::LocalIdentifier(&node.name), Node::Expression(&node.value)]
954 }
955 Node::EnumCase(node) => {
956 let mut children = vec![];
957 for attr in node.attribute_lists.iter() {
958 children.push(Node::AttributeList(attr));
959 }
960
961 children.push(Node::Keyword(&node.case));
962 children.push(Node::EnumCaseItem(&node.item));
963 children.push(Node::Terminator(&node.terminator));
964
965 children
966 }
967 Node::EnumCaseBackedItem(node) => {
968 vec![Node::LocalIdentifier(&node.name), Node::Expression(&node.value)]
969 }
970 Node::EnumCaseItem(node) => match &node {
971 EnumCaseItem::Backed(node) => vec![Node::EnumCaseBackedItem(node)],
972 EnumCaseItem::Unit(node) => vec![Node::EnumCaseUnitItem(node)],
973 },
974 Node::EnumCaseUnitItem(node) => vec![Node::LocalIdentifier(&node.name)],
975 Node::Extends(node) => {
976 let mut children = vec![];
977
978 children.push(Node::Keyword(&node.extends));
979 children.extend(node.types.iter().map(Node::Identifier));
980
981 children
982 }
983 Node::Implements(node) => {
984 let mut children = vec![];
985
986 children.push(Node::Keyword(&node.implements));
987 children.extend(node.types.iter().map(Node::Identifier));
988
989 children
990 }
991 Node::ClassLikeConstantSelector(node) => match node {
992 ClassLikeConstantSelector::Identifier(node) => vec![Node::LocalIdentifier(node)],
993 ClassLikeConstantSelector::Expression(node) => {
994 vec![Node::ClassLikeMemberExpressionSelector(node)]
995 }
996 },
997 Node::ClassLikeMember(node) => match node {
998 ClassLikeMember::TraitUse(node) => vec![Node::TraitUse(node)],
999 ClassLikeMember::Constant(node) => vec![Node::ClassLikeConstant(node)],
1000 ClassLikeMember::Property(node) => vec![Node::Property(node)],
1001 ClassLikeMember::EnumCase(node) => vec![Node::EnumCase(node)],
1002 ClassLikeMember::Method(node) => vec![Node::Method(node)],
1003 },
1004 Node::ClassLikeMemberExpressionSelector(node) => vec![Node::Expression(node.expression)],
1005 Node::ClassLikeMemberSelector(node) => match node {
1006 ClassLikeMemberSelector::Identifier(node) => vec![Node::LocalIdentifier(node)],
1007 ClassLikeMemberSelector::Variable(node) => vec![Node::Variable(node)],
1008 ClassLikeMemberSelector::Expression(node) => {
1009 vec![Node::ClassLikeMemberExpressionSelector(node)]
1010 }
1011 },
1012 Node::Method(node) => {
1013 let mut children: Vec<Node> = vec![];
1014
1015 children.extend(node.attribute_lists.iter().map(Node::AttributeList));
1016 children.extend(node.modifiers.iter().map(Node::Modifier));
1017 children.push(Node::Keyword(&node.function));
1018 children.push(Node::LocalIdentifier(&node.name));
1019 children.push(Node::FunctionLikeParameterList(&node.parameter_list));
1020 children.extend(node.return_type_hint.iter().map(Node::FunctionLikeReturnTypeHint));
1021 children.push(Node::MethodBody(&node.body));
1022
1023 children
1024 }
1025 Node::MethodAbstractBody(_) => vec![],
1026 Node::MethodBody(node) => match node {
1027 MethodBody::Abstract(node) => vec![Node::MethodAbstractBody(node)],
1028 MethodBody::Concrete(node) => vec![Node::Block(node)],
1029 },
1030 Node::HookedProperty(node) => {
1031 let mut children: Vec<Node> = vec![];
1032
1033 children.extend(node.attribute_lists.iter().map(Node::AttributeList));
1034 children.extend(node.var.iter().map(Node::Keyword));
1035 children.extend(node.modifiers.iter().map(Node::Modifier));
1036 children.extend(node.hint.iter().map(Node::Hint));
1037 children.push(Node::PropertyItem(&node.item));
1038 children.push(Node::PropertyHookList(&node.hook_list));
1039
1040 children
1041 }
1042 Node::PlainProperty(node) => {
1043 let mut children: Vec<Node> = vec![];
1044
1045 children.extend(node.attribute_lists.iter().map(Node::AttributeList));
1046 children.extend(node.var.iter().map(Node::Keyword));
1047 children.extend(node.modifiers.iter().map(Node::Modifier));
1048 children.extend(node.hint.iter().map(Node::Hint));
1049 children.extend(node.items.iter().map(Node::PropertyItem));
1050
1051 children
1052 }
1053 Node::Property(node) => match node {
1054 Property::Plain(node) => vec![Node::PlainProperty(node)],
1055 Property::Hooked(node) => vec![Node::HookedProperty(node)],
1056 },
1057 Node::PropertyAbstractItem(node) => {
1058 vec![Node::DirectVariable(&node.variable)]
1059 }
1060 Node::PropertyConcreteItem(node) => {
1061 vec![Node::DirectVariable(&node.variable), Node::Expression(&node.value)]
1062 }
1063 Node::PropertyHook(node) => {
1064 let mut children: Vec<Node> = vec![];
1065
1066 children.extend(node.attribute_lists.iter().map(Node::AttributeList));
1067 children.extend(node.modifiers.iter().map(Node::Modifier));
1068 children.push(Node::LocalIdentifier(&node.name));
1069 children.extend(node.parameter_list.iter().map(Node::FunctionLikeParameterList));
1070 children.push(Node::PropertyHookBody(&node.body));
1071
1072 children
1073 }
1074 Node::PropertyHookAbstractBody(_) => {
1075 vec![]
1076 }
1077 Node::PropertyHookBody(node) => vec![match node {
1078 PropertyHookBody::Abstract(node) => Node::PropertyHookAbstractBody(node),
1079 PropertyHookBody::Concrete(node) => Node::PropertyHookConcreteBody(node),
1080 }],
1081 Node::PropertyHookConcreteBody(node) => vec![match node {
1082 PropertyHookConcreteBody::Expression(node) => Node::PropertyHookConcreteExpressionBody(node),
1083 PropertyHookConcreteBody::Block(node) => Node::Block(node),
1084 }],
1085 Node::PropertyHookConcreteExpressionBody(node) => vec![Node::Expression(&node.expression)],
1086 Node::PropertyHookList(node) => Vec::from_iter(node.hooks.iter().map(Node::PropertyHook)),
1087 Node::PropertyItem(node) => match node {
1088 PropertyItem::Abstract(node) => vec![Node::PropertyAbstractItem(node)],
1089 PropertyItem::Concrete(node) => vec![Node::PropertyConcreteItem(node)],
1090 },
1091 Node::TraitUse(node) => {
1092 let mut children: Vec<Node> = vec![];
1093
1094 children.push(Node::Keyword(&node.r#use));
1095 children.extend(node.trait_names.iter().map(Node::Identifier));
1096 children.push(Node::TraitUseSpecification(&node.specification));
1097
1098 children
1099 }
1100 Node::TraitUseAbsoluteMethodReference(node) => {
1101 vec![Node::Identifier(&node.trait_name), Node::LocalIdentifier(&node.method_name)]
1102 }
1103 Node::TraitUseAbstractSpecification(node) => vec![Node::Terminator(&node.0)],
1104 Node::TraitUseAdaptation(node) => match node {
1105 TraitUseAdaptation::Precedence(adaptation) => {
1106 let mut children = vec![
1107 Node::TraitUseAbsoluteMethodReference(&adaptation.method_reference),
1108 Node::Keyword(&adaptation.insteadof),
1109 ];
1110
1111 children.extend(adaptation.trait_names.iter().map(Node::Identifier));
1112 children.push(Node::Terminator(&adaptation.terminator));
1113
1114 children
1115 }
1116 TraitUseAdaptation::Alias(adaptation) => {
1117 let mut children = vec![
1118 Node::TraitUseMethodReference(&adaptation.method_reference),
1119 Node::Keyword(&adaptation.r#as),
1120 ];
1121
1122 if let Some(visibility) = &adaptation.visibility {
1123 children.push(Node::Modifier(visibility));
1124 }
1125
1126 if let Some(alias) = &adaptation.alias {
1127 children.push(Node::LocalIdentifier(alias));
1128 }
1129
1130 children.push(Node::Terminator(&adaptation.terminator));
1131 children
1132 }
1133 },
1134 Node::TraitUseAliasAdaptation(node) => {
1135 let mut children =
1136 vec![Node::TraitUseMethodReference(&node.method_reference), Node::Keyword(&node.r#as)];
1137
1138 if let Some(visibility) = &node.visibility {
1139 children.push(Node::Modifier(visibility));
1140 }
1141
1142 if let Some(alias) = &node.alias {
1143 children.push(Node::LocalIdentifier(alias));
1144 }
1145
1146 children.push(Node::Terminator(&node.terminator));
1147 children
1148 }
1149 Node::TraitUseConcreteSpecification(node) => {
1150 let mut children = vec![];
1151 for adaptation in node.adaptations.as_slice() {
1152 children.push(Node::TraitUseAdaptation(adaptation));
1153 }
1154
1155 children
1156 }
1157 Node::TraitUseMethodReference(node) => match node {
1158 TraitUseMethodReference::Identifier(identifier) => {
1159 vec![Node::LocalIdentifier(identifier)]
1160 }
1161 TraitUseMethodReference::Absolute(reference) => {
1162 vec![Node::TraitUseAbsoluteMethodReference(reference)]
1163 }
1164 },
1165 Node::TraitUsePrecedenceAdaptation(node) => {
1166 let mut children =
1167 vec![Node::TraitUseAbsoluteMethodReference(&node.method_reference), Node::Keyword(&node.insteadof)];
1168
1169 children.extend(node.trait_names.iter().map(Node::Identifier));
1170 children.push(Node::Terminator(&node.terminator));
1171
1172 children
1173 }
1174 Node::TraitUseSpecification(node) => match node {
1175 TraitUseSpecification::Abstract(specification) => {
1176 vec![Node::TraitUseAbstractSpecification(specification)]
1177 }
1178 TraitUseSpecification::Concrete(specification) => {
1179 vec![Node::TraitUseConcreteSpecification(specification)]
1180 }
1181 },
1182 Node::AnonymousClass(node) => {
1183 let mut children = vec![Node::Keyword(&node.new)];
1184 children.extend(node.attribute_lists.iter().map(Node::AttributeList));
1185 children.extend(node.modifiers.iter().map(Node::Modifier));
1186 children.push(Node::Keyword(&node.class));
1187 if let Some(argument_list) = &node.argument_list {
1188 children.push(Node::ArgumentList(argument_list));
1189 }
1190 children.extend(node.extends.iter().map(Node::Extends));
1191 children.extend(node.implements.iter().map(Node::Implements));
1192 children.extend(node.members.iter().map(Node::ClassLikeMember));
1193
1194 children
1195 }
1196 Node::Class(node) => {
1197 let mut children = vec![];
1198 children.extend(node.attribute_lists.iter().map(Node::AttributeList));
1199 children.extend(node.modifiers.iter().map(Node::Modifier));
1200 children.push(Node::Keyword(&node.class));
1201 children.push(Node::LocalIdentifier(&node.name));
1202 children.extend(node.extends.iter().map(Node::Extends));
1203 children.extend(node.implements.iter().map(Node::Implements));
1204 children.extend(node.members.iter().map(Node::ClassLikeMember));
1205
1206 children
1207 }
1208 Node::Enum(node) => {
1209 let mut children = vec![];
1210 children.extend(node.attribute_lists.iter().map(Node::AttributeList));
1211 children.push(Node::Keyword(&node.r#enum));
1212 children.push(Node::LocalIdentifier(&node.name));
1213 children.extend(node.backing_type_hint.iter().map(Node::EnumBackingTypeHint));
1214 children.extend(node.implements.iter().map(Node::Implements));
1215 children.extend(node.members.iter().map(Node::ClassLikeMember));
1216
1217 children
1218 }
1219 Node::EnumBackingTypeHint(node) => {
1220 vec![Node::Hint(&node.hint)]
1221 }
1222 Node::Interface(node) => {
1223 let mut children = vec![];
1224 children.extend(node.attribute_lists.iter().map(Node::AttributeList));
1225 children.push(Node::Keyword(&node.interface));
1226 children.push(Node::LocalIdentifier(&node.name));
1227 children.extend(node.extends.iter().map(Node::Extends));
1228 children.extend(node.members.iter().map(Node::ClassLikeMember));
1229
1230 children
1231 }
1232 Node::Trait(node) => {
1233 let mut children = vec![];
1234 children.extend(node.attribute_lists.iter().map(Node::AttributeList));
1235 children.push(Node::Keyword(&node.r#trait));
1236 children.push(Node::LocalIdentifier(&node.name));
1237 children.extend(node.members.iter().map(Node::ClassLikeMember));
1238
1239 children
1240 }
1241 Node::Clone(node) => {
1242 vec![Node::Keyword(&node.clone), Node::Expression(node.object)]
1243 }
1244 Node::Constant(node) => {
1245 let mut children = vec![];
1246 children.extend(node.attribute_lists.iter().map(Node::AttributeList));
1247 children.push(Node::Keyword(&node.r#const));
1248 children.extend(node.items.iter().map(Node::ConstantItem));
1249 children.push(Node::Terminator(&node.terminator));
1250
1251 children
1252 }
1253 Node::ConstantItem(node) => {
1254 vec![Node::LocalIdentifier(&node.name), Node::Expression(&node.value)]
1255 }
1256 Node::Construct(node) => vec![match node {
1257 Construct::Isset(node) => Node::IssetConstruct(node),
1258 Construct::Empty(node) => Node::EmptyConstruct(node),
1259 Construct::Eval(node) => Node::EvalConstruct(node),
1260 Construct::Include(node) => Node::IncludeConstruct(node),
1261 Construct::IncludeOnce(node) => Node::IncludeOnceConstruct(node),
1262 Construct::Require(node) => Node::RequireConstruct(node),
1263 Construct::RequireOnce(node) => Node::RequireOnceConstruct(node),
1264 Construct::Print(node) => Node::PrintConstruct(node),
1265 Construct::Exit(node) => Node::ExitConstruct(node),
1266 Construct::Die(node) => Node::DieConstruct(node),
1267 }],
1268 Node::IssetConstruct(node) => {
1269 let mut children = vec![Node::Keyword(&node.isset)];
1270 children.extend(node.values.iter().map(Node::Expression));
1271
1272 children
1273 }
1274 Node::EmptyConstruct(node) => {
1275 vec![Node::Keyword(&node.empty), Node::Expression(node.value)]
1276 }
1277 Node::EvalConstruct(node) => {
1278 vec![Node::Keyword(&node.eval), Node::Expression(node.value)]
1279 }
1280 Node::IncludeConstruct(node) => {
1281 vec![Node::Keyword(&node.include), Node::Expression(node.value)]
1282 }
1283 Node::IncludeOnceConstruct(node) => {
1284 vec![Node::Keyword(&node.include_once), Node::Expression(node.value)]
1285 }
1286 Node::RequireConstruct(node) => {
1287 vec![Node::Keyword(&node.require), Node::Expression(node.value)]
1288 }
1289 Node::RequireOnceConstruct(node) => {
1290 vec![Node::Keyword(&node.require_once), Node::Expression(node.value)]
1291 }
1292 Node::PrintConstruct(node) => {
1293 vec![Node::Keyword(&node.print), Node::Expression(node.value)]
1294 }
1295 Node::ExitConstruct(node) => {
1296 let mut children = vec![Node::Keyword(&node.exit)];
1297 if let Some(arguments) = &node.arguments {
1298 children.push(Node::ArgumentList(arguments));
1299 }
1300 children
1301 }
1302 Node::DieConstruct(node) => {
1303 let mut children = vec![Node::Keyword(&node.die)];
1304 if let Some(arguments) = &node.arguments {
1305 children.push(Node::ArgumentList(arguments));
1306 }
1307 children
1308 }
1309 Node::If(node) => {
1310 vec![Node::Keyword(&node.r#if), Node::Expression(node.condition), Node::IfBody(&node.body)]
1311 }
1312 Node::IfBody(node) => match node {
1313 IfBody::Statement(statement_body) => vec![Node::IfStatementBody(statement_body)],
1314 IfBody::ColonDelimited(colon_body) => vec![Node::IfColonDelimitedBody(colon_body)],
1315 },
1316 Node::IfStatementBody(node) => {
1317 let mut children = vec![Node::Statement(node.statement)];
1318
1319 children.extend(node.else_if_clauses.iter().map(Node::IfStatementBodyElseIfClause));
1320 if let Some(else_clause) = &node.else_clause {
1321 children.push(Node::IfStatementBodyElseClause(else_clause));
1322 }
1323
1324 children
1325 }
1326 Node::IfStatementBodyElseIfClause(node) => {
1327 vec![Node::Keyword(&node.elseif), Node::Expression(node.condition), Node::Statement(node.statement)]
1328 }
1329 Node::IfStatementBodyElseClause(node) => {
1330 vec![Node::Keyword(&node.r#else), Node::Statement(node.statement)]
1331 }
1332 Node::IfColonDelimitedBody(node) => {
1333 let mut children = vec![];
1334 for stmt in node.statements.as_slice() {
1335 children.push(Node::Statement(stmt));
1336 }
1337
1338 children.extend(node.else_if_clauses.iter().map(Node::IfColonDelimitedBodyElseIfClause));
1339
1340 if let Some(else_clause) = &node.else_clause {
1341 children.push(Node::IfColonDelimitedBodyElseClause(else_clause));
1342 }
1343
1344 children.push(Node::Keyword(&node.endif));
1345 children.push(Node::Terminator(&node.terminator));
1346
1347 children
1348 }
1349 Node::IfColonDelimitedBodyElseIfClause(node) => {
1350 let mut children = vec![Node::Keyword(&node.elseif), Node::Expression(node.condition)];
1351 children.extend(node.statements.iter().map(Node::Statement));
1352
1353 children
1354 }
1355 Node::IfColonDelimitedBodyElseClause(node) => {
1356 let mut children = vec![Node::Keyword(&node.r#else)];
1357
1358 children.extend(node.statements.iter().map(Node::Statement));
1359
1360 children
1361 }
1362 Node::Match(node) => {
1363 let mut children = vec![Node::Keyword(&node.r#match), Node::Expression(node.expression)];
1364 children.extend(node.arms.iter().map(Node::MatchArm));
1365
1366 children
1367 }
1368 Node::MatchArm(node) => match node {
1369 MatchArm::Expression(expr_arm) => vec![Node::MatchExpressionArm(expr_arm)],
1370 MatchArm::Default(default_arm) => vec![Node::MatchDefaultArm(default_arm)],
1371 },
1372 Node::MatchExpressionArm(node) => {
1373 let mut children = vec![];
1374
1375 children.extend(node.conditions.iter().map(Node::Expression));
1376 children.push(Node::Expression(node.expression));
1377
1378 children
1379 }
1380 Node::MatchDefaultArm(node) => {
1381 vec![Node::Keyword(&node.default), Node::Expression(node.expression)]
1382 }
1383 Node::Switch(node) => {
1384 vec![Node::Keyword(&node.switch), Node::Expression(node.expression), Node::SwitchBody(&node.body)]
1385 }
1386 Node::SwitchBody(node) => match node {
1387 SwitchBody::BraceDelimited(body) => vec![Node::SwitchBraceDelimitedBody(body)],
1388 SwitchBody::ColonDelimited(body) => vec![Node::SwitchColonDelimitedBody(body)],
1389 },
1390 Node::SwitchBraceDelimitedBody(node) => {
1391 let mut children = vec![];
1392
1393 if let Some(terminator) = &node.optional_terminator {
1394 children.push(Node::Terminator(terminator));
1395 }
1396
1397 children.extend(node.cases.iter().map(Node::SwitchCase));
1398
1399 children
1400 }
1401 Node::SwitchColonDelimitedBody(node) => {
1402 let mut children = vec![];
1403
1404 if let Some(terminator) = &node.optional_terminator {
1405 children.push(Node::Terminator(terminator));
1406 }
1407
1408 children.extend(node.cases.iter().map(Node::SwitchCase));
1409 children.push(Node::Keyword(&node.end_switch));
1410 children.push(Node::Terminator(&node.terminator));
1411
1412 children
1413 }
1414 Node::SwitchCase(node) => match node {
1415 SwitchCase::Expression(expression_case) => {
1416 vec![Node::SwitchExpressionCase(expression_case)]
1417 }
1418 SwitchCase::Default(default_case) => vec![Node::SwitchDefaultCase(default_case)],
1419 },
1420 Node::SwitchExpressionCase(node) => {
1421 let mut children = vec![
1422 Node::Keyword(&node.case),
1423 Node::Expression(node.expression),
1424 Node::SwitchCaseSeparator(&node.separator),
1425 ];
1426
1427 children.extend(node.statements.iter().map(Node::Statement));
1428
1429 children
1430 }
1431 Node::SwitchDefaultCase(node) => {
1432 let mut children = vec![Node::Keyword(&node.default), Node::SwitchCaseSeparator(&node.separator)];
1433 children.extend(node.statements.iter().map(Node::Statement));
1434
1435 children
1436 }
1437 Node::SwitchCaseSeparator(_) => vec![],
1438 Node::Declare(node) => {
1439 let mut children = vec![Node::Keyword(&node.declare)];
1440
1441 children.extend(node.items.iter().map(Node::DeclareItem));
1442 children.push(Node::DeclareBody(&node.body));
1443
1444 children
1445 }
1446 Node::DeclareBody(node) => match node {
1447 DeclareBody::Statement(statement) => vec![Node::Statement(statement)],
1448 DeclareBody::ColonDelimited(body) => vec![Node::DeclareColonDelimitedBody(body)],
1449 },
1450 Node::DeclareColonDelimitedBody(node) => {
1451 let mut children = Vec::from_iter(node.statements.iter().map(Node::Statement));
1452
1453 children.push(Node::Keyword(&node.end_declare));
1454 children.push(Node::Terminator(&node.terminator));
1455
1456 children
1457 }
1458 Node::DeclareItem(node) => {
1459 vec![Node::LocalIdentifier(&node.name), Node::Expression(&node.value)]
1460 }
1461 Node::EchoTag(node) => {
1462 let mut children = vec![];
1463 children.extend(node.values.iter().map(Node::Expression));
1464 children.push(Node::Terminator(&node.terminator));
1465
1466 children
1467 }
1468 Node::Echo(node) => {
1469 let mut children = vec![Node::Keyword(&node.echo)];
1470 children.extend(node.values.iter().map(Node::Expression));
1471 children.push(Node::Terminator(&node.terminator));
1472
1473 children
1474 }
1475 Node::Parenthesized(node) => vec![Node::Expression(node.expression)],
1476 Node::Expression(node) => vec![match node {
1477 Expression::Binary(node) => Node::Binary(node),
1478 Expression::UnaryPrefix(node) => Node::UnaryPrefix(node),
1479 Expression::ConstantAccess(node) => Node::ConstantAccess(node),
1480 Expression::UnaryPostfix(node) => Node::UnaryPostfix(node),
1481 Expression::Parenthesized(node) => Node::Parenthesized(node),
1482 Expression::Literal(node) => Node::Literal(node),
1483 Expression::CompositeString(node) => Node::CompositeString(node),
1484 Expression::Assignment(node) => Node::Assignment(node),
1485 Expression::Conditional(node) => Node::Conditional(node),
1486 Expression::Array(node) => Node::Array(node),
1487 Expression::LegacyArray(node) => Node::LegacyArray(node),
1488 Expression::List(node) => Node::List(node),
1489 Expression::ArrayAccess(node) => Node::ArrayAccess(node),
1490 Expression::ArrayAppend(node) => Node::ArrayAppend(node),
1491 Expression::AnonymousClass(node) => Node::AnonymousClass(node),
1492 Expression::Closure(node) => Node::Closure(node),
1493 Expression::ArrowFunction(node) => Node::ArrowFunction(node),
1494 Expression::Variable(node) => Node::Variable(node),
1495 Expression::Identifier(node) => Node::Identifier(node),
1496 Expression::Match(node) => Node::Match(node),
1497 Expression::Yield(node) => Node::Yield(node),
1498 Expression::Construct(node) => Node::Construct(node),
1499 Expression::Throw(node) => Node::Throw(node),
1500 Expression::Clone(node) => Node::Clone(node),
1501 Expression::Call(node) => Node::Call(node),
1502 Expression::PartialApplication(node) => Node::PartialApplication(node),
1503 Expression::Access(node) => Node::Access(node),
1504 Expression::Parent(node) => Node::Keyword(node),
1505 Expression::Static(node) => Node::Keyword(node),
1506 Expression::Self_(node) => Node::Keyword(node),
1507 Expression::Instantiation(node) => Node::Instantiation(node),
1508 Expression::MagicConstant(node) => Node::MagicConstant(node),
1509 Expression::Pipe(node) => Node::Pipe(node),
1510 }],
1511 Node::Binary(node) => {
1512 vec![Node::Expression(node.lhs), Node::BinaryOperator(&node.operator), Node::Expression(node.rhs)]
1513 }
1514 Node::BinaryOperator(operator) => match operator {
1515 BinaryOperator::Addition(_) => vec![],
1516 BinaryOperator::Subtraction(_) => vec![],
1517 BinaryOperator::Multiplication(_) => vec![],
1518 BinaryOperator::Division(_) => vec![],
1519 BinaryOperator::Modulo(_) => vec![],
1520 BinaryOperator::Exponentiation(_) => vec![],
1521 BinaryOperator::BitwiseAnd(_) => vec![],
1522 BinaryOperator::BitwiseOr(_) => vec![],
1523 BinaryOperator::BitwiseXor(_) => vec![],
1524 BinaryOperator::LeftShift(_) => vec![],
1525 BinaryOperator::RightShift(_) => vec![],
1526 BinaryOperator::NullCoalesce(_) => vec![],
1527 BinaryOperator::Equal(_) => vec![],
1528 BinaryOperator::NotEqual(_) => vec![],
1529 BinaryOperator::Identical(_) => vec![],
1530 BinaryOperator::NotIdentical(_) => vec![],
1531 BinaryOperator::AngledNotEqual(_) => vec![],
1532 BinaryOperator::LessThan(_) => vec![],
1533 BinaryOperator::LessThanOrEqual(_) => vec![],
1534 BinaryOperator::GreaterThan(_) => vec![],
1535 BinaryOperator::GreaterThanOrEqual(_) => vec![],
1536 BinaryOperator::Spaceship(_) => vec![],
1537 BinaryOperator::StringConcat(_) => vec![],
1538 BinaryOperator::And(_) => vec![],
1539 BinaryOperator::Or(_) => vec![],
1540 BinaryOperator::Instanceof(keyword) => vec![Node::Keyword(keyword)],
1541 BinaryOperator::LowAnd(keyword) => vec![Node::Keyword(keyword)],
1542 BinaryOperator::LowOr(keyword) => vec![Node::Keyword(keyword)],
1543 BinaryOperator::LowXor(keyword) => vec![Node::Keyword(keyword)],
1544 },
1545 Node::UnaryPrefix(node) => {
1546 vec![Node::UnaryPrefixOperator(&node.operator), Node::Expression(node.operand)]
1547 }
1548 Node::UnaryPostfix(node) => {
1549 vec![Node::Expression(node.operand), Node::UnaryPostfixOperator(&node.operator)]
1550 }
1551 Node::UnaryPrefixOperator(_) | Node::UnaryPostfixOperator(_) => vec![],
1552 Node::ArrowFunction(node) => {
1553 let mut children = vec![];
1554
1555 children.extend(node.attribute_lists.iter().map(Node::AttributeList));
1556 if let Some(r#static) = &node.r#static {
1557 children.push(Node::Keyword(r#static));
1558 }
1559 children.push(Node::Keyword(&node.r#fn));
1560 children.push(Node::FunctionLikeParameterList(&node.parameter_list));
1561 if let Some(return_type_hint) = &node.return_type_hint {
1562 children.push(Node::FunctionLikeReturnTypeHint(return_type_hint));
1563 }
1564 children.push(Node::Expression(node.expression));
1565
1566 children
1567 }
1568 Node::Closure(node) => {
1569 let mut children = vec![];
1570
1571 children.extend(node.attribute_lists.iter().map(Node::AttributeList));
1572 children.push(Node::Keyword(&node.function));
1573 children.push(Node::FunctionLikeParameterList(&node.parameter_list));
1574 if let Some(use_clause) = &node.use_clause {
1575 children.push(Node::ClosureUseClause(use_clause));
1576 }
1577 if let Some(return_type_hint) = &node.return_type_hint {
1578 children.push(Node::FunctionLikeReturnTypeHint(return_type_hint));
1579 }
1580 children.push(Node::Block(&node.body));
1581
1582 children
1583 }
1584 Node::ClosureUseClause(node) => {
1585 let mut children = vec![Node::Keyword(&node.r#use)];
1586 children.extend(node.variables.iter().map(Node::ClosureUseClauseVariable));
1587
1588 children
1589 }
1590 Node::ClosureUseClauseVariable(node) => vec![Node::DirectVariable(&node.variable)],
1591 Node::Function(node) => {
1592 let mut children = vec![];
1593
1594 children.extend(node.attribute_lists.iter().map(Node::AttributeList));
1595 children.push(Node::Keyword(&node.function));
1596 children.push(Node::LocalIdentifier(&node.name));
1597 children.push(Node::FunctionLikeParameterList(&node.parameter_list));
1598 if let Some(return_type_hint) = &node.return_type_hint {
1599 children.push(Node::FunctionLikeReturnTypeHint(return_type_hint));
1600 }
1601
1602 children.push(Node::Block(&node.body));
1603
1604 children
1605 }
1606 Node::FunctionLikeParameterList(node) => {
1607 Vec::from_iter(node.parameters.iter().map(Node::FunctionLikeParameter))
1608 }
1609 Node::FunctionLikeParameter(node) => {
1610 let mut children = vec![];
1611
1612 children.extend(node.attribute_lists.iter().map(Node::AttributeList));
1613 children.extend(node.modifiers.iter().map(Node::Modifier));
1614 if let Some(hint) = &node.hint {
1615 children.push(Node::Hint(hint));
1616 }
1617 children.push(Node::DirectVariable(&node.variable));
1618 if let Some(default_value) = &node.default_value {
1619 children.push(Node::FunctionLikeParameterDefaultValue(default_value));
1620 }
1621
1622 if let Some(hooks) = &node.hooks {
1623 children.push(Node::PropertyHookList(hooks));
1624 }
1625
1626 children
1627 }
1628 Node::FunctionLikeParameterDefaultValue(node) => vec![Node::Expression(&node.value)],
1629 Node::FunctionLikeReturnTypeHint(hint) => vec![Node::Hint(&hint.hint)],
1630 Node::Global(node) => {
1631 let mut children: Vec<Node> = vec![];
1632
1633 children.push(Node::Keyword(&node.r#global));
1634 children.extend(node.variables.iter().map(Node::Variable));
1635
1636 children
1637 }
1638 Node::Goto(node) => {
1639 vec![Node::Keyword(&node.r#goto), Node::LocalIdentifier(&node.label)]
1640 }
1641 Node::Label(node) => {
1642 vec![Node::LocalIdentifier(&node.name)]
1643 }
1644 Node::HaltCompiler(node) => {
1645 vec![Node::Keyword(&node.halt_compiler)]
1646 }
1647 Node::FullyQualifiedIdentifier(_) => vec![],
1648 Node::Identifier(node) => vec![match node {
1649 Identifier::Local(node) => Node::LocalIdentifier(node),
1650 Identifier::Qualified(node) => Node::QualifiedIdentifier(node),
1651 Identifier::FullyQualified(node) => Node::FullyQualifiedIdentifier(node),
1652 }],
1653 Node::LocalIdentifier(_) => vec![],
1654 Node::QualifiedIdentifier(_) => vec![],
1655 Node::Inline(_) => vec![],
1656 Node::Instantiation(node) => {
1657 let mut children = vec![Node::Keyword(&node.new), Node::Expression(node.class)];
1658
1659 if let Some(argument_list) = &node.argument_list {
1660 children.push(Node::ArgumentList(argument_list));
1661 }
1662
1663 children
1664 }
1665 Node::Keyword(_) => vec![],
1666 Node::Literal(node) => vec![match node {
1667 Literal::Float(node) => Node::LiteralFloat(node),
1668 Literal::Integer(node) => Node::LiteralInteger(node),
1669 Literal::String(node) => Node::LiteralString(node),
1670 Literal::True(node) => Node::Keyword(node),
1671 Literal::False(node) => Node::Keyword(node),
1672 Literal::Null(node) => Node::Keyword(node),
1673 }],
1674 Node::LiteralFloat(_) => vec![],
1675 Node::LiteralInteger(_) => vec![],
1676 Node::LiteralString(_) => vec![],
1677 Node::MagicConstant(node) => vec![match node {
1678 MagicConstant::Class(node) => Node::LocalIdentifier(node),
1679 MagicConstant::Directory(node) => Node::LocalIdentifier(node),
1680 MagicConstant::File(node) => Node::LocalIdentifier(node),
1681 MagicConstant::Function(node) => Node::LocalIdentifier(node),
1682 MagicConstant::Line(node) => Node::LocalIdentifier(node),
1683 MagicConstant::Method(node) => Node::LocalIdentifier(node),
1684 MagicConstant::Namespace(node) => Node::LocalIdentifier(node),
1685 MagicConstant::Trait(node) => Node::LocalIdentifier(node),
1686 MagicConstant::Property(node) => Node::LocalIdentifier(node),
1687 }],
1688 Node::Modifier(node) => vec![match node {
1689 Modifier::Abstract(node) => Node::Keyword(node),
1690 Modifier::Final(node) => Node::Keyword(node),
1691 Modifier::Private(node) => Node::Keyword(node),
1692 Modifier::Protected(node) => Node::Keyword(node),
1693 Modifier::Public(node) => Node::Keyword(node),
1694 Modifier::Static(node) => Node::Keyword(node),
1695 Modifier::Readonly(node) => Node::Keyword(node),
1696 Modifier::PrivateSet(node) => Node::Keyword(node),
1697 Modifier::ProtectedSet(node) => Node::Keyword(node),
1698 Modifier::PublicSet(node) => Node::Keyword(node),
1699 }],
1700 Node::Namespace(node) => {
1701 let mut children = vec![Node::Keyword(&node.r#namespace)];
1702
1703 if let Some(name) = &node.name {
1704 children.push(Node::Identifier(name));
1705 }
1706
1707 children.push(Node::NamespaceBody(&node.body));
1708
1709 children
1710 }
1711 Node::NamespaceBody(node) => {
1712 vec![match node {
1713 NamespaceBody::BraceDelimited(node) => Node::Block(node),
1714 NamespaceBody::Implicit(node) => Node::NamespaceImplicitBody(node),
1715 }]
1716 }
1717 Node::NamespaceImplicitBody(node) => {
1718 let mut children = vec![Node::Terminator(&node.terminator)];
1719
1720 children.extend(node.statements.iter().map(Node::Statement));
1721
1722 children
1723 }
1724 Node::Assignment(node) => {
1725 vec![Node::Expression(node.lhs), Node::AssignmentOperator(&node.operator), Node::Expression(node.rhs)]
1726 }
1727 Node::AssignmentOperator(_) => vec![],
1728 Node::Conditional(node) => {
1729 let mut children = vec![Node::Expression(node.condition)];
1730
1731 if let Some(then) = &node.then {
1732 children.push(Node::Expression(then));
1733 }
1734
1735 children.push(Node::Expression(node.r#else));
1736
1737 children
1738 }
1739 Node::DoWhile(node) => vec![
1740 Node::Keyword(&node.r#do),
1741 Node::Statement(node.statement),
1742 Node::Keyword(&node.r#while),
1743 Node::Expression(node.condition),
1744 Node::Terminator(&node.terminator),
1745 ],
1746 Node::Foreach(node) => vec![
1747 Node::Keyword(&node.r#foreach),
1748 Node::Expression(node.expression),
1749 Node::Keyword(&node.r#as),
1750 Node::ForeachTarget(&node.target),
1751 Node::ForeachBody(&node.body),
1752 ],
1753 Node::ForeachBody(node) => vec![match node {
1754 ForeachBody::Statement(node) => Node::Statement(node),
1755 ForeachBody::ColonDelimited(node) => Node::ForeachColonDelimitedBody(node),
1756 }],
1757 Node::ForeachColonDelimitedBody(node) => {
1758 let mut children = Vec::from_iter(node.statements.iter().map(Node::Statement));
1759
1760 children.push(Node::Keyword(&node.end_foreach));
1761 children.push(Node::Terminator(&node.terminator));
1762
1763 children
1764 }
1765 Node::ForeachKeyValueTarget(node) => {
1766 vec![Node::Expression(node.key), Node::Expression(node.value)]
1767 }
1768 Node::ForeachTarget(node) => vec![match node {
1769 ForeachTarget::KeyValue(node) => Node::ForeachKeyValueTarget(node),
1770 ForeachTarget::Value(node) => Node::ForeachValueTarget(node),
1771 }],
1772 Node::ForeachValueTarget(node) => vec![Node::Expression(node.value)],
1773 Node::For(node) => {
1774 let mut children = vec![Node::Keyword(&node.r#for)];
1775
1776 children.extend(node.initializations.iter().map(Node::Expression));
1777 children.extend(node.conditions.iter().map(Node::Expression));
1778 children.extend(node.increments.iter().map(Node::Expression));
1779 children.push(Node::ForBody(&node.body));
1780
1781 children
1782 }
1783 Node::ForBody(node) => match node {
1784 ForBody::Statement(statement) => vec![Node::Statement(statement)],
1785 ForBody::ColonDelimited(body) => vec![Node::ForColonDelimitedBody(body)],
1786 },
1787 Node::ForColonDelimitedBody(node) => {
1788 let mut children = vec![];
1789
1790 children.extend(node.statements.iter().map(Node::Statement));
1791 children.push(Node::Keyword(&node.end_for));
1792 children.push(Node::Terminator(&node.terminator));
1793
1794 children
1795 }
1796 Node::While(node) => {
1797 vec![Node::Keyword(&node.r#while), Node::Expression(node.condition), Node::WhileBody(&node.body)]
1798 }
1799 Node::WhileBody(node) => match node {
1800 WhileBody::Statement(statement) => vec![Node::Statement(statement)],
1801 WhileBody::ColonDelimited(body) => vec![Node::WhileColonDelimitedBody(body)],
1802 },
1803 Node::WhileColonDelimitedBody(node) => {
1804 let mut children = vec![];
1805
1806 children.extend(node.statements.iter().map(Node::Statement));
1807 children.push(Node::Keyword(&node.end_while));
1808 children.push(Node::Terminator(&node.terminator));
1809
1810 children
1811 }
1812 Node::Break(node) => {
1813 let mut children = vec![Node::Keyword(&node.r#break)];
1814
1815 if let Some(level) = &node.level {
1816 children.push(Node::Expression(level));
1817 }
1818
1819 children.push(Node::Terminator(&node.terminator));
1820
1821 children
1822 }
1823 Node::Continue(node) => {
1824 let mut children = vec![Node::Keyword(&node.r#continue)];
1825
1826 if let Some(level) = &node.level {
1827 children.push(Node::Expression(level));
1828 }
1829
1830 children.push(Node::Terminator(&node.terminator));
1831
1832 children
1833 }
1834 Node::Return(node) => {
1835 let mut children = vec![Node::Keyword(&node.r#return)];
1836
1837 if let Some(value) = &node.value {
1838 children.push(Node::Expression(value));
1839 }
1840
1841 children.push(Node::Terminator(&node.terminator));
1842
1843 children
1844 }
1845 Node::Static(node) => {
1846 let mut children = vec![Node::Keyword(&node.r#static)];
1847
1848 children.extend(node.items.iter().map(Node::StaticItem));
1849 children.push(Node::Terminator(&node.terminator));
1850
1851 children
1852 }
1853 Node::StaticItem(node) => vec![match node {
1854 StaticItem::Abstract(item) => Node::StaticAbstractItem(item),
1855 StaticItem::Concrete(item) => Node::StaticConcreteItem(item),
1856 }],
1857 Node::StaticAbstractItem(node) => {
1858 vec![Node::DirectVariable(&node.variable)]
1859 }
1860 Node::StaticConcreteItem(node) => {
1861 vec![Node::DirectVariable(&node.variable), Node::Expression(&node.value)]
1862 }
1863 Node::Try(node) => {
1864 let mut children = vec![];
1865
1866 children.push(Node::Keyword(&node.r#try));
1867 children.push(Node::Block(&node.block));
1868 children.extend(node.catch_clauses.iter().map(Node::TryCatchClause));
1869 if let Some(finally) = &node.finally_clause {
1870 children.push(Node::TryFinallyClause(finally));
1871 }
1872
1873 children
1874 }
1875 Node::TryCatchClause(node) => {
1876 let mut children = vec![Node::Keyword(&node.r#catch), Node::Hint(&node.hint)];
1877 if let Some(variable) = &node.variable {
1878 children.push(Node::DirectVariable(variable));
1879 }
1880 children.push(Node::Block(&node.block));
1881
1882 children
1883 }
1884 Node::TryFinallyClause(node) => {
1885 vec![Node::Keyword(&node.r#finally), Node::Block(&node.block)]
1886 }
1887 Node::MaybeTypedUseItem(node) => {
1888 let mut children = vec![];
1889 if let Some(r#type) = &node.r#type {
1890 children.push(Node::UseType(r#type));
1891 }
1892
1893 children.push(Node::UseItem(&node.item));
1894
1895 children
1896 }
1897 Node::MixedUseItemList(node) => {
1898 let mut children = vec![Node::Identifier(&node.namespace)];
1899
1900 children.extend(node.items.iter().map(Node::MaybeTypedUseItem));
1901
1902 children
1903 }
1904 Node::TypedUseItemList(node) => {
1905 let mut children = vec![Node::UseType(&node.r#type), Node::Identifier(&node.namespace)];
1906
1907 children.extend(node.items.iter().map(Node::UseItem));
1908
1909 children
1910 }
1911 Node::TypedUseItemSequence(node) => {
1912 let mut children = vec![Node::UseType(&node.r#type)];
1913
1914 children.extend(node.items.iter().map(Node::UseItem));
1915 children
1916 }
1917 Node::Use(node) => {
1918 vec![Node::Keyword(&node.r#use), Node::UseItems(&node.items), Node::Terminator(&node.terminator)]
1919 }
1920 Node::UseItem(node) => {
1921 let mut result = vec![Node::Identifier(&node.name)];
1922
1923 if let Some(alias) = &node.alias {
1924 result.push(Node::UseItemAlias(alias));
1925 }
1926
1927 result
1928 }
1929 Node::UseItemAlias(node) => {
1930 vec![Node::Keyword(&node.r#as), Node::LocalIdentifier(&node.identifier)]
1931 }
1932 Node::UseItemSequence(node) => {
1933 let mut children = vec![];
1934 for item in node.items.iter() {
1935 children.push(Node::UseItem(item));
1936 }
1937
1938 children
1939 }
1940 Node::UseItems(node) => vec![match node {
1941 UseItems::Sequence(node) => Node::UseItemSequence(node),
1942 UseItems::TypedList(node) => Node::TypedUseItemList(node),
1943 UseItems::MixedList(node) => Node::MixedUseItemList(node),
1944 UseItems::TypedSequence(node) => Node::TypedUseItemSequence(node),
1945 }],
1946 Node::UseType(node) => vec![match node {
1947 UseType::Const(node) => Node::Keyword(node),
1948 UseType::Function(node) => Node::Keyword(node),
1949 }],
1950 Node::Yield(node) => vec![match node {
1951 Yield::Value(node) => Node::YieldValue(node),
1952 Yield::Pair(node) => Node::YieldPair(node),
1953 Yield::From(node) => Node::YieldFrom(node),
1954 }],
1955 Node::YieldFrom(node) => {
1956 vec![Node::Keyword(&node.r#yield), Node::Keyword(&node.from), Node::Expression(node.iterator)]
1957 }
1958 Node::YieldPair(node) => {
1959 vec![Node::Keyword(&node.r#yield), Node::Expression(node.key), Node::Expression(node.value)]
1960 }
1961 Node::YieldValue(node) => match &node.value {
1962 Some(value) => vec![Node::Keyword(&node.r#yield), Node::Expression(value)],
1963 None => vec![Node::Keyword(&node.r#yield)],
1964 },
1965 Node::Statement(node) => match &node {
1966 Statement::OpeningTag(node) => vec![Node::OpeningTag(node)],
1967 Statement::ClosingTag(node) => vec![Node::ClosingTag(node)],
1968 Statement::Inline(node) => vec![Node::Inline(node)],
1969 Statement::Namespace(node) => vec![Node::Namespace(node)],
1970 Statement::Use(node) => vec![Node::Use(node)],
1971 Statement::Class(node) => vec![Node::Class(node)],
1972 Statement::Interface(node) => vec![Node::Interface(node)],
1973 Statement::Trait(node) => vec![Node::Trait(node)],
1974 Statement::Enum(node) => vec![Node::Enum(node)],
1975 Statement::Block(node) => vec![Node::Block(node)],
1976 Statement::Constant(node) => vec![Node::Constant(node)],
1977 Statement::Function(node) => vec![Node::Function(node)],
1978 Statement::Declare(node) => vec![Node::Declare(node)],
1979 Statement::Goto(node) => vec![Node::Goto(node)],
1980 Statement::Label(node) => vec![Node::Label(node)],
1981 Statement::Try(node) => vec![Node::Try(node)],
1982 Statement::Foreach(node) => vec![Node::Foreach(node)],
1983 Statement::For(node) => vec![Node::For(node)],
1984 Statement::While(node) => vec![Node::While(node)],
1985 Statement::DoWhile(node) => vec![Node::DoWhile(node)],
1986 Statement::Continue(node) => vec![Node::Continue(node)],
1987 Statement::Break(node) => vec![Node::Break(node)],
1988 Statement::Switch(node) => vec![Node::Switch(node)],
1989 Statement::If(node) => vec![Node::If(node)],
1990 Statement::Return(node) => vec![Node::Return(node)],
1991 Statement::Expression(node) => vec![Node::ExpressionStatement(node)],
1992 Statement::EchoTag(node) => vec![Node::EchoTag(node)],
1993 Statement::Echo(node) => vec![Node::Echo(node)],
1994 Statement::Global(node) => vec![Node::Global(node)],
1995 Statement::Static(node) => vec![Node::Static(node)],
1996 Statement::HaltCompiler(node) => vec![Node::HaltCompiler(node)],
1997 Statement::Unset(node) => vec![Node::Unset(node)],
1998 Statement::Noop(_) => vec![],
1999 },
2000 Node::ExpressionStatement(node) => {
2001 vec![Node::Expression(node.expression), Node::Terminator(&node.terminator)]
2002 }
2003 Node::BracedExpressionStringPart(node) => vec![Node::Expression(node.expression)],
2004 Node::DocumentString(node) => {
2005 let mut children = vec![];
2006 for part in node.parts.as_slice() {
2007 children.push(Node::StringPart(part));
2008 }
2009
2010 children
2011 }
2012 Node::InterpolatedString(node) => {
2013 let mut children = vec![];
2014 for part in node.parts.as_slice() {
2015 children.push(Node::StringPart(part));
2016 }
2017
2018 children
2019 }
2020 Node::LiteralStringPart(_) => vec![],
2021 Node::ShellExecuteString(node) => {
2022 let mut children = vec![];
2023 for part in node.parts.as_slice() {
2024 children.push(Node::StringPart(part));
2025 }
2026
2027 children
2028 }
2029 Node::CompositeString(node) => vec![match node {
2030 CompositeString::ShellExecute(node) => Node::ShellExecuteString(node),
2031 CompositeString::Interpolated(node) => Node::InterpolatedString(node),
2032 CompositeString::Document(node) => Node::DocumentString(node),
2033 }],
2034 Node::StringPart(node) => vec![match node {
2035 StringPart::Literal(node) => Node::LiteralStringPart(node),
2036 StringPart::Expression(node) => Node::Expression(node),
2037 StringPart::BracedExpression(node) => Node::BracedExpressionStringPart(node),
2038 }],
2039 Node::ClosingTag(_) => vec![],
2040 Node::FullOpeningTag(_) => vec![],
2041 Node::OpeningTag(node) => match node {
2042 OpeningTag::Full(node) => vec![Node::FullOpeningTag(node)],
2043 OpeningTag::Short(node) => vec![Node::ShortOpeningTag(node)],
2044 },
2045 Node::ShortOpeningTag(_) => vec![],
2046 Node::Terminator(node) => match node {
2047 Terminator::Semicolon(_) => vec![],
2048 Terminator::ClosingTag(closing_tag) => vec![Node::ClosingTag(closing_tag)],
2049 Terminator::TagPair(closing_tag, opening_tag) => {
2050 vec![Node::ClosingTag(closing_tag), Node::OpeningTag(opening_tag)]
2051 }
2052 },
2053 Node::Throw(node) => vec![Node::Keyword(&node.throw), Node::Expression(node.exception)],
2054 Node::Hint(node) => match &node {
2055 Hint::Identifier(identifier) => vec![Node::Identifier(identifier)],
2056 Hint::Parenthesized(parenthesized_hint) => {
2057 vec![Node::ParenthesizedHint(parenthesized_hint)]
2058 }
2059 Hint::Nullable(nullable_hint) => vec![Node::NullableHint(nullable_hint)],
2060 Hint::Union(union_hint) => vec![Node::UnionHint(union_hint)],
2061 Hint::Intersection(intersection_hint) => vec![Node::IntersectionHint(intersection_hint)],
2062 Hint::Null(keyword)
2063 | Hint::True(keyword)
2064 | Hint::False(keyword)
2065 | Hint::Array(keyword)
2066 | Hint::Callable(keyword)
2067 | Hint::Static(keyword)
2068 | Hint::Self_(keyword)
2069 | Hint::Parent(keyword) => vec![Node::Keyword(keyword)],
2070 Hint::Void(local_identifier)
2071 | Hint::Never(local_identifier)
2072 | Hint::Float(local_identifier)
2073 | Hint::Bool(local_identifier)
2074 | Hint::Integer(local_identifier)
2075 | Hint::String(local_identifier)
2076 | Hint::Object(local_identifier)
2077 | Hint::Mixed(local_identifier)
2078 | Hint::Iterable(local_identifier) => vec![Node::LocalIdentifier(local_identifier)],
2079 },
2080 Node::IntersectionHint(node) => vec![Node::Hint(node.left), Node::Hint(node.right)],
2081 Node::NullableHint(node) => vec![Node::Hint(node.hint)],
2082 Node::ParenthesizedHint(node) => vec![Node::Hint(node.hint)],
2083 Node::UnionHint(node) => vec![Node::Hint(node.left), Node::Hint(node.right)],
2084 Node::Unset(node) => {
2085 let mut children = vec![Node::Keyword(&node.unset)];
2086 children.extend(node.values.iter().map(Node::Expression));
2087 children.push(Node::Terminator(&node.terminator));
2088
2089 children
2090 }
2091 Node::DirectVariable(_) => vec![],
2092 Node::IndirectVariable(node) => vec![Node::Expression(node.expression)],
2093 Node::NestedVariable(node) => {
2094 vec![Node::Variable(node.variable)]
2095 }
2096 Node::Variable(node) => match node {
2097 Variable::Direct(node) => vec![Node::DirectVariable(node)],
2098 Variable::Indirect(node) => vec![Node::IndirectVariable(node)],
2099 Variable::Nested(node) => vec![Node::NestedVariable(node)],
2100 },
2101 Node::Pipe(pipe) => {
2102 vec![Node::Expression(pipe.input), Node::Expression(pipe.callable)]
2103 }
2104 }
2105 }
2106}
2107
2108impl HasSpan for Node<'_, '_> {
2109 fn span(&self) -> Span {
2110 match self {
2111 Self::Program(node) => node.span(),
2112 Self::Access(node) => node.span(),
2113 Self::ConstantAccess(node) => node.span(),
2114 Self::ClassConstantAccess(node) => node.span(),
2115 Self::NullSafePropertyAccess(node) => node.span(),
2116 Self::PropertyAccess(node) => node.span(),
2117 Self::StaticPropertyAccess(node) => node.span(),
2118 Self::Argument(node) => node.span(),
2119 Self::ArgumentList(node) => node.span(),
2120 Self::PartialArgument(node) => node.span(),
2121 Self::PartialArgumentList(node) => node.span(),
2122 Self::NamedArgument(node) => node.span(),
2123 Self::NamedPlaceholderArgument(node) => node.span(),
2124 Self::PlaceholderArgument(node) => node.span(),
2125 Self::PositionalArgument(node) => node.span(),
2126 Self::VariadicPlaceholderArgument(node) => node.span(),
2127 Self::Array(node) => node.span(),
2128 Self::ArrayAccess(node) => node.span(),
2129 Self::ArrayAppend(node) => node.span(),
2130 Self::ArrayElement(node) => node.span(),
2131 Self::KeyValueArrayElement(node) => node.span(),
2132 Self::LegacyArray(node) => node.span(),
2133 Self::List(node) => node.span(),
2134 Self::MissingArrayElement(node) => node.span(),
2135 Self::ValueArrayElement(node) => node.span(),
2136 Self::VariadicArrayElement(node) => node.span(),
2137 Self::Attribute(node) => node.span(),
2138 Self::AttributeList(node) => node.span(),
2139 Self::Block(node) => node.span(),
2140 Self::Call(node) => node.span(),
2141 Self::FunctionCall(node) => node.span(),
2142 Self::MethodCall(node) => node.span(),
2143 Self::NullSafeMethodCall(node) => node.span(),
2144 Self::StaticMethodCall(node) => node.span(),
2145 Self::PartialApplication(node) => node.span(),
2146 Self::FunctionPartialApplication(node) => node.span(),
2147 Self::MethodPartialApplication(node) => node.span(),
2148 Self::StaticMethodPartialApplication(node) => node.span(),
2149 Self::ClassLikeConstant(node) => node.span(),
2150 Self::ClassLikeConstantItem(node) => node.span(),
2151 Self::EnumCase(node) => node.span(),
2152 Self::EnumCaseBackedItem(node) => node.span(),
2153 Self::EnumCaseItem(node) => node.span(),
2154 Self::EnumCaseUnitItem(node) => node.span(),
2155 Self::Extends(node) => node.span(),
2156 Self::Implements(node) => node.span(),
2157 Self::ClassLikeConstantSelector(node) => node.span(),
2158 Self::ClassLikeMember(node) => node.span(),
2159 Self::ClassLikeMemberExpressionSelector(node) => node.span(),
2160 Self::ClassLikeMemberSelector(node) => node.span(),
2161 Self::Method(node) => node.span(),
2162 Self::MethodAbstractBody(node) => node.span(),
2163 Self::MethodBody(node) => node.span(),
2164 Self::HookedProperty(node) => node.span(),
2165 Self::PlainProperty(node) => node.span(),
2166 Self::Property(node) => node.span(),
2167 Self::PropertyAbstractItem(node) => node.span(),
2168 Self::PropertyConcreteItem(node) => node.span(),
2169 Self::PropertyHook(node) => node.span(),
2170 Self::PropertyHookAbstractBody(node) => node.span(),
2171 Self::PropertyHookBody(node) => node.span(),
2172 Self::PropertyHookConcreteBody(node) => node.span(),
2173 Self::PropertyHookConcreteExpressionBody(node) => node.span(),
2174 Self::PropertyHookList(node) => node.span(),
2175 Self::PropertyItem(node) => node.span(),
2176 Self::TraitUse(node) => node.span(),
2177 Self::TraitUseAbsoluteMethodReference(node) => node.span(),
2178 Self::TraitUseAbstractSpecification(node) => node.span(),
2179 Self::TraitUseAdaptation(node) => node.span(),
2180 Self::TraitUseAliasAdaptation(node) => node.span(),
2181 Self::TraitUseConcreteSpecification(node) => node.span(),
2182 Self::TraitUseMethodReference(node) => node.span(),
2183 Self::TraitUsePrecedenceAdaptation(node) => node.span(),
2184 Self::TraitUseSpecification(node) => node.span(),
2185 Self::AnonymousClass(node) => node.span(),
2186 Self::Class(node) => node.span(),
2187 Self::Enum(node) => node.span(),
2188 Self::EnumBackingTypeHint(node) => node.span(),
2189 Self::Interface(node) => node.span(),
2190 Self::Trait(node) => node.span(),
2191 Self::Clone(node) => node.span(),
2192 Self::Constant(node) => node.span(),
2193 Self::ConstantItem(node) => node.span(),
2194 Self::Construct(node) => node.span(),
2195 Self::DieConstruct(node) => node.span(),
2196 Self::EmptyConstruct(node) => node.span(),
2197 Self::EvalConstruct(node) => node.span(),
2198 Self::ExitConstruct(node) => node.span(),
2199 Self::IncludeConstruct(node) => node.span(),
2200 Self::IncludeOnceConstruct(node) => node.span(),
2201 Self::IssetConstruct(node) => node.span(),
2202 Self::PrintConstruct(node) => node.span(),
2203 Self::RequireConstruct(node) => node.span(),
2204 Self::RequireOnceConstruct(node) => node.span(),
2205 Self::If(node) => node.span(),
2206 Self::IfBody(node) => node.span(),
2207 Self::IfColonDelimitedBody(node) => node.span(),
2208 Self::IfColonDelimitedBodyElseClause(node) => node.span(),
2209 Self::IfColonDelimitedBodyElseIfClause(node) => node.span(),
2210 Self::IfStatementBody(node) => node.span(),
2211 Self::IfStatementBodyElseClause(node) => node.span(),
2212 Self::IfStatementBodyElseIfClause(node) => node.span(),
2213 Self::Match(node) => node.span(),
2214 Self::MatchArm(node) => node.span(),
2215 Self::MatchDefaultArm(node) => node.span(),
2216 Self::MatchExpressionArm(node) => node.span(),
2217 Self::Switch(node) => node.span(),
2218 Self::SwitchBody(node) => node.span(),
2219 Self::SwitchBraceDelimitedBody(node) => node.span(),
2220 Self::SwitchCase(node) => node.span(),
2221 Self::SwitchCaseSeparator(node) => node.span(),
2222 Self::SwitchColonDelimitedBody(node) => node.span(),
2223 Self::SwitchDefaultCase(node) => node.span(),
2224 Self::SwitchExpressionCase(node) => node.span(),
2225 Self::Declare(node) => node.span(),
2226 Self::DeclareBody(node) => node.span(),
2227 Self::DeclareColonDelimitedBody(node) => node.span(),
2228 Self::DeclareItem(node) => node.span(),
2229 Self::Echo(node) => node.span(),
2230 Self::Expression(node) => node.span(),
2231 Self::Binary(node) => node.span(),
2232 Self::BinaryOperator(node) => node.span(),
2233 Self::UnaryPrefix(node) => node.span(),
2234 Self::UnaryPrefixOperator(node) => node.span(),
2235 Self::UnaryPostfix(node) => node.span(),
2236 Self::UnaryPostfixOperator(node) => node.span(),
2237 Self::Parenthesized(node) => node.span(),
2238 Self::ArrowFunction(node) => node.span(),
2239 Self::Closure(node) => node.span(),
2240 Self::ClosureUseClause(node) => node.span(),
2241 Self::ClosureUseClauseVariable(node) => node.span(),
2242 Self::Function(node) => node.span(),
2243 Self::FunctionLikeParameter(node) => node.span(),
2244 Self::FunctionLikeParameterDefaultValue(node) => node.span(),
2245 Self::FunctionLikeParameterList(node) => node.span(),
2246 Self::FunctionLikeReturnTypeHint(node) => node.span(),
2247 Self::Global(node) => node.span(),
2248 Self::Goto(node) => node.span(),
2249 Self::Label(node) => node.span(),
2250 Self::HaltCompiler(node) => node.span(),
2251 Self::FullyQualifiedIdentifier(node) => node.span(),
2252 Self::Identifier(node) => node.span(),
2253 Self::LocalIdentifier(node) => node.span(),
2254 Self::QualifiedIdentifier(node) => node.span(),
2255 Self::Inline(node) => node.span(),
2256 Self::Instantiation(node) => node.span(),
2257 Self::Keyword(node) => node.span(),
2258 Self::Literal(node) => node.span(),
2259 Self::LiteralFloat(node) => node.span(),
2260 Self::LiteralInteger(node) => node.span(),
2261 Self::LiteralString(node) => node.span(),
2262 Self::MagicConstant(node) => node.span(),
2263 Self::Modifier(node) => node.span(),
2264 Self::Namespace(node) => node.span(),
2265 Self::NamespaceBody(node) => node.span(),
2266 Self::NamespaceImplicitBody(node) => node.span(),
2267 Self::Assignment(node) => node.span(),
2268 Self::AssignmentOperator(node) => node.span(),
2269 Self::Conditional(node) => node.span(),
2270 Self::DoWhile(node) => node.span(),
2271 Self::Foreach(node) => node.span(),
2272 Self::ForeachBody(node) => node.span(),
2273 Self::ForeachColonDelimitedBody(node) => node.span(),
2274 Self::ForeachKeyValueTarget(node) => node.span(),
2275 Self::ForeachTarget(node) => node.span(),
2276 Self::ForeachValueTarget(node) => node.span(),
2277 Self::For(node) => node.span(),
2278 Self::ForBody(node) => node.span(),
2279 Self::ForColonDelimitedBody(node) => node.span(),
2280 Self::While(node) => node.span(),
2281 Self::WhileBody(node) => node.span(),
2282 Self::WhileColonDelimitedBody(node) => node.span(),
2283 Self::Break(node) => node.span(),
2284 Self::Continue(node) => node.span(),
2285 Self::Return(node) => node.span(),
2286 Self::Static(node) => node.span(),
2287 Self::StaticAbstractItem(node) => node.span(),
2288 Self::StaticConcreteItem(node) => node.span(),
2289 Self::StaticItem(node) => node.span(),
2290 Self::Try(node) => node.span(),
2291 Self::TryCatchClause(node) => node.span(),
2292 Self::TryFinallyClause(node) => node.span(),
2293 Self::MaybeTypedUseItem(node) => node.span(),
2294 Self::MixedUseItemList(node) => node.span(),
2295 Self::TypedUseItemList(node) => node.span(),
2296 Self::TypedUseItemSequence(node) => node.span(),
2297 Self::Use(node) => node.span(),
2298 Self::UseItem(node) => node.span(),
2299 Self::UseItemAlias(node) => node.span(),
2300 Self::UseItemSequence(node) => node.span(),
2301 Self::UseItems(node) => node.span(),
2302 Self::UseType(node) => node.span(),
2303 Self::Yield(node) => node.span(),
2304 Self::YieldFrom(node) => node.span(),
2305 Self::YieldPair(node) => node.span(),
2306 Self::YieldValue(node) => node.span(),
2307 Self::Statement(node) => node.span(),
2308 Self::ExpressionStatement(node) => node.span(),
2309 Self::BracedExpressionStringPart(node) => node.span(),
2310 Self::DocumentString(node) => node.span(),
2311 Self::InterpolatedString(node) => node.span(),
2312 Self::LiteralStringPart(node) => node.span(),
2313 Self::ShellExecuteString(node) => node.span(),
2314 Self::CompositeString(node) => node.span(),
2315 Self::StringPart(node) => node.span(),
2316 Self::ClosingTag(node) => node.span(),
2317 Self::EchoTag(node) => node.span(),
2318 Self::FullOpeningTag(node) => node.span(),
2319 Self::OpeningTag(node) => node.span(),
2320 Self::ShortOpeningTag(node) => node.span(),
2321 Self::Terminator(node) => node.span(),
2322 Self::Throw(node) => node.span(),
2323 Self::Hint(node) => node.span(),
2324 Self::IntersectionHint(node) => node.span(),
2325 Self::NullableHint(node) => node.span(),
2326 Self::ParenthesizedHint(node) => node.span(),
2327 Self::UnionHint(node) => node.span(),
2328 Self::Unset(node) => node.span(),
2329 Self::DirectVariable(node) => node.span(),
2330 Self::IndirectVariable(node) => node.span(),
2331 Self::NestedVariable(node) => node.span(),
2332 Self::Variable(node) => node.span(),
2333 Self::Pipe(node) => node.span(),
2334 }
2335 }
2336}