mago_syntax/ast/
node.rs

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