diff --git a/lib/PhpParser/Internal/PrintableNewAnonClassNode.php b/lib/PhpParser/Internal/PrintableNewAnonClassNode.php index b30a99a14b..bce8faadb5 100644 --- a/lib/PhpParser/Internal/PrintableNewAnonClassNode.php +++ b/lib/PhpParser/Internal/PrintableNewAnonClassNode.php @@ -29,6 +29,8 @@ class PrintableNewAnonClassNode extends Expr { /** @var Node\Stmt[] Statements */ public array $stmts; + private const SUBNODE_NAMES = ['attrGroups', 'flags', 'args', 'extends', 'implements', 'stmts']; + /** * @param Node\AttributeGroup[] $attrGroups PHP attribute groups * @param (Node\Arg|Node\VariadicPlaceholder)[] $args Arguments @@ -65,7 +67,10 @@ public function getType(): string { return 'Expr_PrintableNewAnonClass'; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['attrGroups', 'flags', 'args', 'extends', 'implements', 'stmts']; + return self::SUBNODE_NAMES; } } diff --git a/lib/PhpParser/Node/Arg.php b/lib/PhpParser/Node/Arg.php index 6680efac98..5a20cf51fa 100644 --- a/lib/PhpParser/Node/Arg.php +++ b/lib/PhpParser/Node/Arg.php @@ -14,6 +14,8 @@ class Arg extends NodeAbstract { /** @var bool Whether to unpack the argument */ public bool $unpack; + private const SUBNODE_NAMES = ['name', 'value', 'byRef', 'unpack']; + /** * Constructs a function call argument node. * @@ -34,8 +36,11 @@ public function __construct( $this->unpack = $unpack; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['name', 'value', 'byRef', 'unpack']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/ArrayItem.php b/lib/PhpParser/Node/ArrayItem.php index fa1cff5276..94dad9a040 100644 --- a/lib/PhpParser/Node/ArrayItem.php +++ b/lib/PhpParser/Node/ArrayItem.php @@ -14,6 +14,8 @@ class ArrayItem extends NodeAbstract { /** @var bool Whether to unpack the argument */ public bool $unpack; + private const SUBNODE_NAMES = ['key', 'value', 'byRef', 'unpack']; + /** * Constructs an array item node. * @@ -30,8 +32,11 @@ public function __construct(Expr $value, ?Expr $key = null, bool $byRef = false, $this->unpack = $unpack; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['key', 'value', 'byRef', 'unpack']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Attribute.php b/lib/PhpParser/Node/Attribute.php index 9d892436af..9d1004e000 100644 --- a/lib/PhpParser/Node/Attribute.php +++ b/lib/PhpParser/Node/Attribute.php @@ -12,6 +12,8 @@ class Attribute extends NodeAbstract { /** @var list Attribute arguments */ public array $args; + private const SUBNODE_NAMES = ['name', 'args']; + /** * @param Node\Name $name Attribute name * @param list $args Attribute arguments @@ -23,8 +25,11 @@ public function __construct(Name $name, array $args = [], array $attributes = [] $this->args = $args; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['name', 'args']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/AttributeGroup.php b/lib/PhpParser/Node/AttributeGroup.php index b9eb588d01..150efe2238 100644 --- a/lib/PhpParser/Node/AttributeGroup.php +++ b/lib/PhpParser/Node/AttributeGroup.php @@ -8,6 +8,8 @@ class AttributeGroup extends NodeAbstract { /** @var Attribute[] Attributes */ public array $attrs; + private const SUBNODE_NAMES = ['attrs']; + /** * @param Attribute[] $attrs PHP attributes * @param array $attributes Additional node attributes @@ -17,8 +19,11 @@ public function __construct(array $attrs, array $attributes = []) { $this->attrs = $attrs; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['attrs']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/ClosureUse.php b/lib/PhpParser/Node/ClosureUse.php index e313280b6c..cb82cbdccb 100644 --- a/lib/PhpParser/Node/ClosureUse.php +++ b/lib/PhpParser/Node/ClosureUse.php @@ -10,6 +10,8 @@ class ClosureUse extends NodeAbstract { /** @var bool Whether to use by reference */ public bool $byRef; + private const SUBNODE_NAMES = ['var', 'byRef']; + /** * Constructs a closure use node. * @@ -23,8 +25,11 @@ public function __construct(Expr\Variable $var, bool $byRef = false, array $attr $this->byRef = $byRef; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['var', 'byRef']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Const_.php b/lib/PhpParser/Node/Const_.php index 8b26ae86a4..2126973347 100644 --- a/lib/PhpParser/Node/Const_.php +++ b/lib/PhpParser/Node/Const_.php @@ -13,6 +13,8 @@ class Const_ extends NodeAbstract { /** @var Name|null Namespaced name (if using NameResolver) */ public ?Name $namespacedName; + private const SUBNODE_NAMES = ['name', 'value']; + /** * Constructs a const node for use in class const and const statements. * @@ -26,8 +28,11 @@ public function __construct($name, Expr $value, array $attributes = []) { $this->value = $value; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['name', 'value']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/DeclareItem.php b/lib/PhpParser/Node/DeclareItem.php index 55c1fe4f19..28c5e2b9a9 100644 --- a/lib/PhpParser/Node/DeclareItem.php +++ b/lib/PhpParser/Node/DeclareItem.php @@ -11,6 +11,8 @@ class DeclareItem extends NodeAbstract { /** @var Node\Expr Value */ public Expr $value; + private const SUBNODE_NAMES = ['key', 'value']; + /** * Constructs a declare key=>value pair node. * @@ -24,8 +26,11 @@ public function __construct($key, Node\Expr $value, array $attributes = []) { $this->value = $value; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['key', 'value']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/ArrayDimFetch.php b/lib/PhpParser/Node/Expr/ArrayDimFetch.php index 24427bbc35..b2346c0478 100644 --- a/lib/PhpParser/Node/Expr/ArrayDimFetch.php +++ b/lib/PhpParser/Node/Expr/ArrayDimFetch.php @@ -10,6 +10,8 @@ class ArrayDimFetch extends Expr { /** @var null|Expr Array index / dim */ public ?Expr $dim; + private const SUBNODE_NAMES = ['var', 'dim']; + /** * Constructs an array index fetch node. * @@ -23,8 +25,11 @@ public function __construct(Expr $var, ?Expr $dim = null, array $attributes = [] $this->dim = $dim; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['var', 'dim']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/Array_.php b/lib/PhpParser/Node/Expr/Array_.php index 3c8c9c2fcf..aadbe62907 100644 --- a/lib/PhpParser/Node/Expr/Array_.php +++ b/lib/PhpParser/Node/Expr/Array_.php @@ -13,6 +13,8 @@ class Array_ extends Expr { /** @var ArrayItem[] Items */ public array $items; + private const SUBNODE_NAMES = ['items']; + /** * Constructs an array node. * @@ -24,8 +26,11 @@ public function __construct(array $items = [], array $attributes = []) { $this->items = $items; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['items']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/ArrowFunction.php b/lib/PhpParser/Node/Expr/ArrowFunction.php index 0e98ce9f6b..65cabd7295 100644 --- a/lib/PhpParser/Node/Expr/ArrowFunction.php +++ b/lib/PhpParser/Node/Expr/ArrowFunction.php @@ -24,6 +24,8 @@ class ArrowFunction extends Expr implements FunctionLike { /** @var Node\AttributeGroup[] */ public array $attrGroups; + private const SUBNODE_NAMES = ['attrGroups', 'static', 'byRef', 'params', 'returnType', 'expr']; + /** * @param array{ * expr: Expr, @@ -51,8 +53,11 @@ public function __construct(array $subNodes, array $attributes = []) { $this->attrGroups = $subNodes['attrGroups'] ?? []; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['attrGroups', 'static', 'byRef', 'params', 'returnType', 'expr']; + return self::SUBNODE_NAMES; } public function returnsByRef(): bool { diff --git a/lib/PhpParser/Node/Expr/Assign.php b/lib/PhpParser/Node/Expr/Assign.php index dcbf84dd41..2bd6652ef9 100644 --- a/lib/PhpParser/Node/Expr/Assign.php +++ b/lib/PhpParser/Node/Expr/Assign.php @@ -10,6 +10,8 @@ class Assign extends Expr { /** @var Expr Expression */ public Expr $expr; + private const SUBNODE_NAMES = ['var', 'expr']; + /** * Constructs an assignment node. * @@ -23,8 +25,11 @@ public function __construct(Expr $var, Expr $expr, array $attributes = []) { $this->expr = $expr; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['var', 'expr']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/AssignOp.php b/lib/PhpParser/Node/Expr/AssignOp.php index 5209a64b1f..5ba9b0d614 100644 --- a/lib/PhpParser/Node/Expr/AssignOp.php +++ b/lib/PhpParser/Node/Expr/AssignOp.php @@ -10,6 +10,8 @@ abstract class AssignOp extends Expr { /** @var Expr Expression */ public Expr $expr; + private const SUBNODE_NAMES = ['var', 'expr']; + /** * Constructs a compound assignment operation node. * @@ -23,7 +25,10 @@ public function __construct(Expr $var, Expr $expr, array $attributes = []) { $this->expr = $expr; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['var', 'expr']; + return self::SUBNODE_NAMES; } } diff --git a/lib/PhpParser/Node/Expr/AssignRef.php b/lib/PhpParser/Node/Expr/AssignRef.php index 9714650a54..4ee8944e72 100644 --- a/lib/PhpParser/Node/Expr/AssignRef.php +++ b/lib/PhpParser/Node/Expr/AssignRef.php @@ -10,6 +10,8 @@ class AssignRef extends Expr { /** @var Expr Variable which is referenced */ public Expr $expr; + private const SUBNODE_NAMES = ['var', 'expr']; + /** * Constructs an assignment node. * @@ -23,8 +25,11 @@ public function __construct(Expr $var, Expr $expr, array $attributes = []) { $this->expr = $expr; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['var', 'expr']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/BinaryOp.php b/lib/PhpParser/Node/Expr/BinaryOp.php index 1b92bd4f50..be17a0104b 100644 --- a/lib/PhpParser/Node/Expr/BinaryOp.php +++ b/lib/PhpParser/Node/Expr/BinaryOp.php @@ -10,6 +10,8 @@ abstract class BinaryOp extends Expr { /** @var Expr The right hand side expression */ public Expr $right; + private const SUBNODE_NAMES = ['left', 'right']; + /** * Constructs a binary operator node. * @@ -23,8 +25,11 @@ public function __construct(Expr $left, Expr $right, array $attributes = []) { $this->right = $right; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['left', 'right']; + return self::SUBNODE_NAMES; } /** diff --git a/lib/PhpParser/Node/Expr/BitwiseNot.php b/lib/PhpParser/Node/Expr/BitwiseNot.php index b7175a7ae5..a1ceb60e55 100644 --- a/lib/PhpParser/Node/Expr/BitwiseNot.php +++ b/lib/PhpParser/Node/Expr/BitwiseNot.php @@ -8,6 +8,8 @@ class BitwiseNot extends Expr { /** @var Expr Expression */ public Expr $expr; + private const SUBNODE_NAMES = ['expr']; + /** * Constructs a bitwise not node. * @@ -19,8 +21,11 @@ public function __construct(Expr $expr, array $attributes = []) { $this->expr = $expr; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['expr']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/BooleanNot.php b/lib/PhpParser/Node/Expr/BooleanNot.php index c66d23326d..47850ae00b 100644 --- a/lib/PhpParser/Node/Expr/BooleanNot.php +++ b/lib/PhpParser/Node/Expr/BooleanNot.php @@ -8,6 +8,8 @@ class BooleanNot extends Expr { /** @var Expr Expression */ public Expr $expr; + private const SUBNODE_NAMES = ['expr']; + /** * Constructs a boolean not node. * @@ -19,8 +21,11 @@ public function __construct(Expr $expr, array $attributes = []) { $this->expr = $expr; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['expr']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/Cast.php b/lib/PhpParser/Node/Expr/Cast.php index c2751de470..65c00c568c 100644 --- a/lib/PhpParser/Node/Expr/Cast.php +++ b/lib/PhpParser/Node/Expr/Cast.php @@ -8,6 +8,8 @@ abstract class Cast extends Expr { /** @var Expr Expression */ public Expr $expr; + private const SUBNODE_NAMES = ['expr']; + /** * Constructs a cast node. * @@ -19,7 +21,10 @@ public function __construct(Expr $expr, array $attributes = []) { $this->expr = $expr; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['expr']; + return self::SUBNODE_NAMES; } } diff --git a/lib/PhpParser/Node/Expr/ClassConstFetch.php b/lib/PhpParser/Node/Expr/ClassConstFetch.php index 7fdd40e411..4d54c95673 100644 --- a/lib/PhpParser/Node/Expr/ClassConstFetch.php +++ b/lib/PhpParser/Node/Expr/ClassConstFetch.php @@ -13,6 +13,8 @@ class ClassConstFetch extends Expr { /** @var Identifier|Expr|Error Constant name */ public Node $name; + private const SUBNODE_NAMES = ['class', 'name']; + /** * Constructs a class const fetch node. * @@ -26,8 +28,11 @@ public function __construct(Node $class, $name, array $attributes = []) { $this->name = \is_string($name) ? new Identifier($name) : $name; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['class', 'name']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/Clone_.php b/lib/PhpParser/Node/Expr/Clone_.php index d85bc9ab42..097b7d8954 100644 --- a/lib/PhpParser/Node/Expr/Clone_.php +++ b/lib/PhpParser/Node/Expr/Clone_.php @@ -8,6 +8,8 @@ class Clone_ extends Expr { /** @var Expr Expression */ public Expr $expr; + private const SUBNODE_NAMES = ['expr']; + /** * Constructs a clone node. * @@ -19,8 +21,11 @@ public function __construct(Expr $expr, array $attributes = []) { $this->expr = $expr; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['expr']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/Closure.php b/lib/PhpParser/Node/Expr/Closure.php index 0680446f34..72625fbb7f 100644 --- a/lib/PhpParser/Node/Expr/Closure.php +++ b/lib/PhpParser/Node/Expr/Closure.php @@ -23,6 +23,8 @@ class Closure extends Expr implements FunctionLike { /** @var Node\AttributeGroup[] PHP attribute groups */ public array $attrGroups; + private const SUBNODE_NAMES = ['attrGroups', 'static', 'byRef', 'params', 'uses', 'returnType', 'stmts']; + /** * Constructs a lambda function node. * @@ -55,8 +57,11 @@ public function __construct(array $subNodes = [], array $attributes = []) { $this->attrGroups = $subNodes['attrGroups'] ?? []; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['attrGroups', 'static', 'byRef', 'params', 'uses', 'returnType', 'stmts']; + return self::SUBNODE_NAMES; } public function returnsByRef(): bool { diff --git a/lib/PhpParser/Node/Expr/ConstFetch.php b/lib/PhpParser/Node/Expr/ConstFetch.php index 47191c5f33..ce4cbea1a3 100644 --- a/lib/PhpParser/Node/Expr/ConstFetch.php +++ b/lib/PhpParser/Node/Expr/ConstFetch.php @@ -9,6 +9,8 @@ class ConstFetch extends Expr { /** @var Name Constant name */ public Name $name; + private const SUBNODE_NAMES = ['name']; + /** * Constructs a const fetch node. * @@ -20,8 +22,11 @@ public function __construct(Name $name, array $attributes = []) { $this->name = $name; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['name']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/Empty_.php b/lib/PhpParser/Node/Expr/Empty_.php index d2f30506ba..567ba90554 100644 --- a/lib/PhpParser/Node/Expr/Empty_.php +++ b/lib/PhpParser/Node/Expr/Empty_.php @@ -8,6 +8,8 @@ class Empty_ extends Expr { /** @var Expr Expression */ public Expr $expr; + private const SUBNODE_NAMES = ['expr']; + /** * Constructs an empty() node. * @@ -19,8 +21,11 @@ public function __construct(Expr $expr, array $attributes = []) { $this->expr = $expr; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['expr']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/ErrorSuppress.php b/lib/PhpParser/Node/Expr/ErrorSuppress.php index 32625a2335..b4c159df49 100644 --- a/lib/PhpParser/Node/Expr/ErrorSuppress.php +++ b/lib/PhpParser/Node/Expr/ErrorSuppress.php @@ -8,6 +8,8 @@ class ErrorSuppress extends Expr { /** @var Expr Expression */ public Expr $expr; + private const SUBNODE_NAMES = ['expr']; + /** * Constructs an error suppress node. * @@ -19,8 +21,11 @@ public function __construct(Expr $expr, array $attributes = []) { $this->expr = $expr; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['expr']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/Eval_.php b/lib/PhpParser/Node/Expr/Eval_.php index 5120b1b4f3..82196d8f76 100644 --- a/lib/PhpParser/Node/Expr/Eval_.php +++ b/lib/PhpParser/Node/Expr/Eval_.php @@ -8,6 +8,8 @@ class Eval_ extends Expr { /** @var Expr Expression */ public Expr $expr; + private const SUBNODE_NAMES = ['expr']; + /** * Constructs an eval() node. * @@ -19,10 +21,12 @@ public function __construct(Expr $expr, array $attributes = []) { $this->expr = $expr; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['expr']; + return self::SUBNODE_NAMES; } - public function getType(): string { return 'Expr_Eval'; } diff --git a/lib/PhpParser/Node/Expr/Exit_.php b/lib/PhpParser/Node/Expr/Exit_.php index cf00246699..ba43e2d8f7 100644 --- a/lib/PhpParser/Node/Expr/Exit_.php +++ b/lib/PhpParser/Node/Expr/Exit_.php @@ -12,6 +12,8 @@ class Exit_ extends Expr { /** @var null|Expr Expression */ public ?Expr $expr; + private const SUBNODE_NAMES = ['expr']; + /** * Constructs an exit() node. * @@ -23,8 +25,11 @@ public function __construct(?Expr $expr = null, array $attributes = []) { $this->expr = $expr; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['expr']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/FuncCall.php b/lib/PhpParser/Node/Expr/FuncCall.php index 0b85840d8e..aba4483a6d 100644 --- a/lib/PhpParser/Node/Expr/FuncCall.php +++ b/lib/PhpParser/Node/Expr/FuncCall.php @@ -11,6 +11,8 @@ class FuncCall extends CallLike { /** @var array Arguments */ public array $args; + private const SUBNODE_NAMES = ['name', 'args']; + /** * Constructs a function call node. * @@ -24,8 +26,11 @@ public function __construct(Node $name, array $args = [], array $attributes = [] $this->args = $args; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['name', 'args']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/Include_.php b/lib/PhpParser/Node/Expr/Include_.php index e1187b194f..796ce88cd7 100644 --- a/lib/PhpParser/Node/Expr/Include_.php +++ b/lib/PhpParser/Node/Expr/Include_.php @@ -15,6 +15,8 @@ class Include_ extends Expr { /** @var int Type of include */ public int $type; + private const SUBNODE_NAMES = ['expr', 'type']; + /** * Constructs an include node. * @@ -28,8 +30,11 @@ public function __construct(Expr $expr, int $type, array $attributes = []) { $this->type = $type; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['expr', 'type']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/Instanceof_.php b/lib/PhpParser/Node/Expr/Instanceof_.php index a2783cb3af..0a082b7b5c 100644 --- a/lib/PhpParser/Node/Expr/Instanceof_.php +++ b/lib/PhpParser/Node/Expr/Instanceof_.php @@ -12,6 +12,8 @@ class Instanceof_ extends Expr { /** @var Name|Expr Class name */ public Node $class; + private const SUBNODE_NAMES = ['expr', 'class']; + /** * Constructs an instanceof check node. * @@ -25,8 +27,11 @@ public function __construct(Expr $expr, Node $class, array $attributes = []) { $this->class = $class; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['expr', 'class']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/Isset_.php b/lib/PhpParser/Node/Expr/Isset_.php index 4f80fff723..f82bce982c 100644 --- a/lib/PhpParser/Node/Expr/Isset_.php +++ b/lib/PhpParser/Node/Expr/Isset_.php @@ -8,6 +8,8 @@ class Isset_ extends Expr { /** @var Expr[] Variables */ public array $vars; + private const SUBNODE_NAMES = ['vars']; + /** * Constructs an array node. * @@ -19,8 +21,11 @@ public function __construct(array $vars, array $attributes = []) { $this->vars = $vars; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['vars']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/List_.php b/lib/PhpParser/Node/Expr/List_.php index 496b7b3853..bef3c86ea8 100644 --- a/lib/PhpParser/Node/Expr/List_.php +++ b/lib/PhpParser/Node/Expr/List_.php @@ -13,6 +13,8 @@ class List_ extends Expr { /** @var (ArrayItem|null)[] List of items to assign to */ public array $items; + private const SUBNODE_NAMES = ['items']; + /** * Constructs a list() destructuring node. * @@ -24,8 +26,11 @@ public function __construct(array $items, array $attributes = []) { $this->items = $items; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['items']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/Match_.php b/lib/PhpParser/Node/Expr/Match_.php index cd028a2da7..085ac48383 100644 --- a/lib/PhpParser/Node/Expr/Match_.php +++ b/lib/PhpParser/Node/Expr/Match_.php @@ -11,6 +11,8 @@ class Match_ extends Node\Expr { /** @var MatchArm[] */ public array $arms; + private const SUBNODE_NAMES = ['cond', 'arms']; + /** * @param Node\Expr $cond Condition * @param MatchArm[] $arms @@ -22,8 +24,11 @@ public function __construct(Node\Expr $cond, array $arms = [], array $attributes $this->arms = $arms; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['cond', 'arms']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/MethodCall.php b/lib/PhpParser/Node/Expr/MethodCall.php index 2703c75d88..d12d2534aa 100644 --- a/lib/PhpParser/Node/Expr/MethodCall.php +++ b/lib/PhpParser/Node/Expr/MethodCall.php @@ -16,6 +16,8 @@ class MethodCall extends CallLike { /** @var array Arguments */ public array $args; + private const SUBNODE_NAMES = ['var', 'name', 'args']; + /** * Constructs a function call node. * @@ -31,8 +33,11 @@ public function __construct(Expr $var, $name, array $args = [], array $attribute $this->args = $args; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['var', 'name', 'args']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/New_.php b/lib/PhpParser/Node/Expr/New_.php index eedaaa1e3b..6ac39afe1d 100644 --- a/lib/PhpParser/Node/Expr/New_.php +++ b/lib/PhpParser/Node/Expr/New_.php @@ -13,6 +13,8 @@ class New_ extends CallLike { /** @var array Arguments */ public array $args; + private const SUBNODE_NAMES = ['class', 'args']; + /** * Constructs a function call node. * @@ -26,8 +28,11 @@ public function __construct(Node $class, array $args = [], array $attributes = [ $this->args = $args; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['class', 'args']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/NullsafeMethodCall.php b/lib/PhpParser/Node/Expr/NullsafeMethodCall.php index a151f71528..2ab5ad299f 100644 --- a/lib/PhpParser/Node/Expr/NullsafeMethodCall.php +++ b/lib/PhpParser/Node/Expr/NullsafeMethodCall.php @@ -16,6 +16,8 @@ class NullsafeMethodCall extends CallLike { /** @var array Arguments */ public array $args; + private const SUBNODE_NAMES = ['var', 'name', 'args']; + /** * Constructs a nullsafe method call node. * @@ -31,8 +33,11 @@ public function __construct(Expr $var, $name, array $args = [], array $attribute $this->args = $args; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['var', 'name', 'args']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/NullsafePropertyFetch.php b/lib/PhpParser/Node/Expr/NullsafePropertyFetch.php index 6f73a16d76..ee3a72fae7 100644 --- a/lib/PhpParser/Node/Expr/NullsafePropertyFetch.php +++ b/lib/PhpParser/Node/Expr/NullsafePropertyFetch.php @@ -12,6 +12,8 @@ class NullsafePropertyFetch extends Expr { /** @var Identifier|Expr Property name */ public Node $name; + private const SUBNODE_NAMES = ['var', 'name']; + /** * Constructs a nullsafe property fetch node. * @@ -25,8 +27,11 @@ public function __construct(Expr $var, $name, array $attributes = []) { $this->name = \is_string($name) ? new Identifier($name) : $name; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['var', 'name']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/PostDec.php b/lib/PhpParser/Node/Expr/PostDec.php index 3dca8fdc5a..b5d0784c89 100644 --- a/lib/PhpParser/Node/Expr/PostDec.php +++ b/lib/PhpParser/Node/Expr/PostDec.php @@ -8,6 +8,8 @@ class PostDec extends Expr { /** @var Expr Variable */ public Expr $var; + private const SUBNODE_NAMES = ['var']; + /** * Constructs a post decrement node. * @@ -19,8 +21,11 @@ public function __construct(Expr $var, array $attributes = []) { $this->var = $var; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['var']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/PostInc.php b/lib/PhpParser/Node/Expr/PostInc.php index bc990c3030..421309385d 100644 --- a/lib/PhpParser/Node/Expr/PostInc.php +++ b/lib/PhpParser/Node/Expr/PostInc.php @@ -8,6 +8,8 @@ class PostInc extends Expr { /** @var Expr Variable */ public Expr $var; + private const SUBNODE_NAMES = ['var']; + /** * Constructs a post increment node. * @@ -19,8 +21,11 @@ public function __construct(Expr $var, array $attributes = []) { $this->var = $var; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['var']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/PreDec.php b/lib/PhpParser/Node/Expr/PreDec.php index 2f16873016..18264afd70 100644 --- a/lib/PhpParser/Node/Expr/PreDec.php +++ b/lib/PhpParser/Node/Expr/PreDec.php @@ -8,6 +8,8 @@ class PreDec extends Expr { /** @var Expr Variable */ public Expr $var; + private const SUBNODE_NAMES = ['var']; + /** * Constructs a pre decrement node. * @@ -19,8 +21,11 @@ public function __construct(Expr $var, array $attributes = []) { $this->var = $var; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['var']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/PreInc.php b/lib/PhpParser/Node/Expr/PreInc.php index fd455f55b9..63a4d78fd5 100644 --- a/lib/PhpParser/Node/Expr/PreInc.php +++ b/lib/PhpParser/Node/Expr/PreInc.php @@ -8,6 +8,8 @@ class PreInc extends Expr { /** @var Expr Variable */ public Expr $var; + private const SUBNODE_NAMES = ['var']; + /** * Constructs a pre increment node. * @@ -19,8 +21,11 @@ public function __construct(Expr $var, array $attributes = []) { $this->var = $var; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['var']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/Print_.php b/lib/PhpParser/Node/Expr/Print_.php index 605747604d..dc5628ab4f 100644 --- a/lib/PhpParser/Node/Expr/Print_.php +++ b/lib/PhpParser/Node/Expr/Print_.php @@ -8,6 +8,8 @@ class Print_ extends Expr { /** @var Expr Expression */ public Expr $expr; + private const SUBNODE_NAMES = ['expr']; + /** * Constructs an print() node. * @@ -19,8 +21,11 @@ public function __construct(Expr $expr, array $attributes = []) { $this->expr = $expr; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['expr']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/PropertyFetch.php b/lib/PhpParser/Node/Expr/PropertyFetch.php index 8c416a8c40..f96620294b 100644 --- a/lib/PhpParser/Node/Expr/PropertyFetch.php +++ b/lib/PhpParser/Node/Expr/PropertyFetch.php @@ -12,6 +12,8 @@ class PropertyFetch extends Expr { /** @var Identifier|Expr Property name */ public Node $name; + private const SUBNODE_NAMES = ['var', 'name']; + /** * Constructs a function call node. * @@ -25,8 +27,11 @@ public function __construct(Expr $var, $name, array $attributes = []) { $this->name = \is_string($name) ? new Identifier($name) : $name; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['var', 'name']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/ShellExec.php b/lib/PhpParser/Node/Expr/ShellExec.php index e400351277..79bb457242 100644 --- a/lib/PhpParser/Node/Expr/ShellExec.php +++ b/lib/PhpParser/Node/Expr/ShellExec.php @@ -9,6 +9,8 @@ class ShellExec extends Expr { /** @var (Expr|InterpolatedStringPart)[] Interpolated string array */ public array $parts; + private const SUBNODE_NAMES = ['parts']; + /** * Constructs a shell exec (backtick) node. * @@ -20,8 +22,11 @@ public function __construct(array $parts, array $attributes = []) { $this->parts = $parts; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['parts']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/StaticCall.php b/lib/PhpParser/Node/Expr/StaticCall.php index 707f34b669..bd091d4c94 100644 --- a/lib/PhpParser/Node/Expr/StaticCall.php +++ b/lib/PhpParser/Node/Expr/StaticCall.php @@ -16,6 +16,8 @@ class StaticCall extends CallLike { /** @var array Arguments */ public array $args; + private const SUBNODE_NAMES = ['class', 'name', 'args']; + /** * Constructs a static method call node. * @@ -31,8 +33,11 @@ public function __construct(Node $class, $name, array $args = [], array $attribu $this->args = $args; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['class', 'name', 'args']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/StaticPropertyFetch.php b/lib/PhpParser/Node/Expr/StaticPropertyFetch.php index 4836a65b23..40212e5361 100644 --- a/lib/PhpParser/Node/Expr/StaticPropertyFetch.php +++ b/lib/PhpParser/Node/Expr/StaticPropertyFetch.php @@ -13,6 +13,8 @@ class StaticPropertyFetch extends Expr { /** @var VarLikeIdentifier|Expr Property name */ public Node $name; + private const SUBNODE_NAMES = ['class', 'name']; + /** * Constructs a static property fetch node. * @@ -26,8 +28,11 @@ public function __construct(Node $class, $name, array $attributes = []) { $this->name = \is_string($name) ? new VarLikeIdentifier($name) : $name; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['class', 'name']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/Ternary.php b/lib/PhpParser/Node/Expr/Ternary.php index d4837e6402..b1c3265659 100644 --- a/lib/PhpParser/Node/Expr/Ternary.php +++ b/lib/PhpParser/Node/Expr/Ternary.php @@ -12,6 +12,8 @@ class Ternary extends Expr { /** @var Expr Expression for false */ public Expr $else; + private const SUBNODE_NAMES = ['cond', 'if', 'else']; + /** * Constructs a ternary operator node. * @@ -27,8 +29,11 @@ public function __construct(Expr $cond, ?Expr $if, Expr $else, array $attributes $this->else = $else; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['cond', 'if', 'else']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/Throw_.php b/lib/PhpParser/Node/Expr/Throw_.php index ee49f835fb..3254b2c3f0 100644 --- a/lib/PhpParser/Node/Expr/Throw_.php +++ b/lib/PhpParser/Node/Expr/Throw_.php @@ -8,6 +8,8 @@ class Throw_ extends Node\Expr { /** @var Node\Expr Expression */ public Node\Expr $expr; + private const SUBNODE_NAMES = ['expr']; + /** * Constructs a throw expression node. * @@ -19,8 +21,11 @@ public function __construct(Node\Expr $expr, array $attributes = []) { $this->expr = $expr; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['expr']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/UnaryMinus.php b/lib/PhpParser/Node/Expr/UnaryMinus.php index cd06f74bab..af7cefb3e0 100644 --- a/lib/PhpParser/Node/Expr/UnaryMinus.php +++ b/lib/PhpParser/Node/Expr/UnaryMinus.php @@ -8,6 +8,8 @@ class UnaryMinus extends Expr { /** @var Expr Expression */ public Expr $expr; + private const SUBNODE_NAMES = ['expr']; + /** * Constructs a unary minus node. * @@ -19,8 +21,11 @@ public function __construct(Expr $expr, array $attributes = []) { $this->expr = $expr; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['expr']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/UnaryPlus.php b/lib/PhpParser/Node/Expr/UnaryPlus.php index 1b44f7b3e7..5a5e48f666 100644 --- a/lib/PhpParser/Node/Expr/UnaryPlus.php +++ b/lib/PhpParser/Node/Expr/UnaryPlus.php @@ -8,6 +8,8 @@ class UnaryPlus extends Expr { /** @var Expr Expression */ public Expr $expr; + private const SUBNODE_NAMES = ['expr']; + /** * Constructs a unary plus node. * @@ -19,8 +21,11 @@ public function __construct(Expr $expr, array $attributes = []) { $this->expr = $expr; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['expr']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/Variable.php b/lib/PhpParser/Node/Expr/Variable.php index bab74920a1..db91a86893 100644 --- a/lib/PhpParser/Node/Expr/Variable.php +++ b/lib/PhpParser/Node/Expr/Variable.php @@ -8,6 +8,8 @@ class Variable extends Expr { /** @var string|Expr Name */ public $name; + private const SUBNODE_NAMES = ['name']; + /** * Constructs a variable node. * @@ -19,8 +21,11 @@ public function __construct($name, array $attributes = []) { $this->name = $name; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['name']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/YieldFrom.php b/lib/PhpParser/Node/Expr/YieldFrom.php index 5cff88f869..5a7942b2db 100644 --- a/lib/PhpParser/Node/Expr/YieldFrom.php +++ b/lib/PhpParser/Node/Expr/YieldFrom.php @@ -8,6 +8,8 @@ class YieldFrom extends Expr { /** @var Expr Expression to yield from */ public Expr $expr; + private const SUBNODE_NAMES = ['expr']; + /** * Constructs an "yield from" node. * @@ -19,8 +21,11 @@ public function __construct(Expr $expr, array $attributes = []) { $this->expr = $expr; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['expr']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Expr/Yield_.php b/lib/PhpParser/Node/Expr/Yield_.php index bd81e69b31..ea706a4d24 100644 --- a/lib/PhpParser/Node/Expr/Yield_.php +++ b/lib/PhpParser/Node/Expr/Yield_.php @@ -10,6 +10,8 @@ class Yield_ extends Expr { /** @var null|Expr Value expression */ public ?Expr $value; + private const SUBNODE_NAMES = ['key', 'value']; + /** * Constructs a yield expression node. * @@ -23,8 +25,11 @@ public function __construct(?Expr $value = null, ?Expr $key = null, array $attri $this->value = $value; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['key', 'value']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Identifier.php b/lib/PhpParser/Node/Identifier.php index 01eebe5ca4..0e42f518af 100644 --- a/lib/PhpParser/Node/Identifier.php +++ b/lib/PhpParser/Node/Identifier.php @@ -21,6 +21,8 @@ class Identifier extends NodeAbstract { 'static' => true, ]; + private const SUBNODE_NAMES = ['name']; + /** * Constructs an identifier node. * @@ -36,8 +38,11 @@ public function __construct(string $name, array $attributes = []) { $this->name = $name; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['name']; + return self::SUBNODE_NAMES; } /** diff --git a/lib/PhpParser/Node/InterpolatedStringPart.php b/lib/PhpParser/Node/InterpolatedStringPart.php index 576dac46f5..5c1a8e17a1 100644 --- a/lib/PhpParser/Node/InterpolatedStringPart.php +++ b/lib/PhpParser/Node/InterpolatedStringPart.php @@ -8,6 +8,8 @@ class InterpolatedStringPart extends NodeAbstract { /** @var string String value */ public string $value; + private const SUBNODE_NAMES = ['value']; + /** * Constructs a node representing a string part of an interpolated string. * @@ -19,8 +21,11 @@ public function __construct(string $value, array $attributes = []) { $this->value = $value; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['value']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/IntersectionType.php b/lib/PhpParser/Node/IntersectionType.php index 3b39cf105b..d649545f57 100644 --- a/lib/PhpParser/Node/IntersectionType.php +++ b/lib/PhpParser/Node/IntersectionType.php @@ -6,6 +6,8 @@ class IntersectionType extends ComplexType { /** @var (Identifier|Name)[] Types */ public array $types; + private const SUBNODE_NAMES = ['types']; + /** * Constructs an intersection type. * @@ -17,8 +19,11 @@ public function __construct(array $types, array $attributes = []) { $this->types = $types; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['types']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/MatchArm.php b/lib/PhpParser/Node/MatchArm.php index 2927f029d6..d24e4d1d29 100644 --- a/lib/PhpParser/Node/MatchArm.php +++ b/lib/PhpParser/Node/MatchArm.php @@ -11,6 +11,8 @@ class MatchArm extends NodeAbstract { /** @var Node\Expr */ public Expr $body; + private const SUBNODE_NAMES = ['conds', 'body']; + /** * @param null|list $conds */ @@ -20,8 +22,11 @@ public function __construct(?array $conds, Node\Expr $body, array $attributes = $this->attributes = $attributes; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['conds', 'body']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Name.php b/lib/PhpParser/Node/Name.php index aa2b90eb22..78be134c49 100644 --- a/lib/PhpParser/Node/Name.php +++ b/lib/PhpParser/Node/Name.php @@ -18,6 +18,8 @@ class Name extends NodeAbstract { 'static' => true, ]; + private const SUBNODE_NAMES = ['name']; + /** * Constructs a name node. * @@ -29,8 +31,11 @@ final public function __construct($name, array $attributes = []) { $this->name = self::prepareName($name); } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['name']; + return self::SUBNODE_NAMES; } /** diff --git a/lib/PhpParser/Node/NullableType.php b/lib/PhpParser/Node/NullableType.php index b99acd1351..e284a7ae21 100644 --- a/lib/PhpParser/Node/NullableType.php +++ b/lib/PhpParser/Node/NullableType.php @@ -8,6 +8,8 @@ class NullableType extends ComplexType { /** @var Identifier|Name Type */ public Node $type; + private const SUBNODE_NAMES = ['type']; + /** * Constructs a nullable type (wrapping another type). * @@ -19,8 +21,11 @@ public function __construct(Node $type, array $attributes = []) { $this->type = $type; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['type']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Param.php b/lib/PhpParser/Node/Param.php index a277ca0a15..b0c4cf91bc 100644 --- a/lib/PhpParser/Node/Param.php +++ b/lib/PhpParser/Node/Param.php @@ -24,6 +24,8 @@ class Param extends NodeAbstract { /** @var PropertyHook[] Property hooks for promoted properties */ public array $hooks; + private const SUBNODE_NAMES = ['attrGroups', 'flags', 'type', 'byRef', 'variadic', 'var', 'default', 'hooks']; + /** * Constructs a parameter node. * @@ -56,8 +58,11 @@ public function __construct( $this->hooks = $hooks; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['attrGroups', 'flags', 'type', 'byRef', 'variadic', 'var', 'default', 'hooks']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/PropertyHook.php b/lib/PhpParser/Node/PropertyHook.php index a8cde850f7..9b662d20a4 100644 --- a/lib/PhpParser/Node/PropertyHook.php +++ b/lib/PhpParser/Node/PropertyHook.php @@ -19,6 +19,8 @@ class PropertyHook extends NodeAbstract implements FunctionLike { /** @var null|Expr|Stmt[] Hook body */ public $body; + private const SUBNODE_NAMES = ['attrGroups', 'flags', 'byRef', 'name', 'params', 'body']; + /** * Constructs a property hook node. * @@ -72,7 +74,10 @@ public function getType(): string { return 'PropertyHook'; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['attrGroups', 'flags', 'byRef', 'name', 'params', 'body']; + return self::SUBNODE_NAMES; } } diff --git a/lib/PhpParser/Node/PropertyItem.php b/lib/PhpParser/Node/PropertyItem.php index 101611e6bc..2e7898053e 100644 --- a/lib/PhpParser/Node/PropertyItem.php +++ b/lib/PhpParser/Node/PropertyItem.php @@ -11,6 +11,8 @@ class PropertyItem extends NodeAbstract { /** @var null|Node\Expr Default */ public ?Expr $default; + private const SUBNODE_NAMES = ['name', 'default']; + /** * Constructs a class property item node. * @@ -24,8 +26,11 @@ public function __construct($name, ?Node\Expr $default = null, array $attributes $this->default = $default; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['name', 'default']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Scalar/Float_.php b/lib/PhpParser/Node/Scalar/Float_.php index 5af1319237..47e71c772a 100644 --- a/lib/PhpParser/Node/Scalar/Float_.php +++ b/lib/PhpParser/Node/Scalar/Float_.php @@ -8,6 +8,8 @@ class Float_ extends Scalar { /** @var float Number value */ public float $value; + private const SUBNODE_NAMES = ['value']; + /** * Constructs a float number scalar node. * @@ -19,8 +21,11 @@ public function __construct(float $value, array $attributes = []) { $this->value = $value; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['value']; + return self::SUBNODE_NAMES; } /** diff --git a/lib/PhpParser/Node/Scalar/Int_.php b/lib/PhpParser/Node/Scalar/Int_.php index bcc257a6a1..6a34277d54 100644 --- a/lib/PhpParser/Node/Scalar/Int_.php +++ b/lib/PhpParser/Node/Scalar/Int_.php @@ -15,6 +15,8 @@ class Int_ extends Scalar { /** @var int Number value */ public int $value; + private const SUBNODE_NAMES = ['value']; + /** * Constructs an integer number scalar node. * @@ -26,8 +28,11 @@ public function __construct(int $value, array $attributes = []) { $this->value = $value; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['value']; + return self::SUBNODE_NAMES; } /** diff --git a/lib/PhpParser/Node/Scalar/InterpolatedString.php b/lib/PhpParser/Node/Scalar/InterpolatedString.php index 9336dfe4da..ce3826af87 100644 --- a/lib/PhpParser/Node/Scalar/InterpolatedString.php +++ b/lib/PhpParser/Node/Scalar/InterpolatedString.php @@ -10,6 +10,8 @@ class InterpolatedString extends Scalar { /** @var (Expr|InterpolatedStringPart)[] list of string parts */ public array $parts; + private const SUBNODE_NAMES = ['parts']; + /** * Constructs an interpolated string node. * @@ -21,8 +23,11 @@ public function __construct(array $parts, array $attributes = []) { $this->parts = $parts; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['parts']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Scalar/String_.php b/lib/PhpParser/Node/Scalar/String_.php index c965366d43..835313a2d1 100644 --- a/lib/PhpParser/Node/Scalar/String_.php +++ b/lib/PhpParser/Node/Scalar/String_.php @@ -27,6 +27,8 @@ class String_ extends Scalar { 'e' => "\x1B", ]; + private const SUBNODE_NAMES = ['value']; + /** * Constructs a string scalar node. * @@ -38,8 +40,11 @@ public function __construct(string $value, array $attributes = []) { $this->value = $value; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['value']; + return self::SUBNODE_NAMES; } /** diff --git a/lib/PhpParser/Node/StaticVar.php b/lib/PhpParser/Node/StaticVar.php index 517c0edddd..03c05d6f74 100644 --- a/lib/PhpParser/Node/StaticVar.php +++ b/lib/PhpParser/Node/StaticVar.php @@ -11,6 +11,8 @@ class StaticVar extends NodeAbstract { /** @var null|Node\Expr Default value */ public ?Expr $default; + private const SUBNODE_NAMES = ['var', 'default']; + /** * Constructs a static variable node. * @@ -26,8 +28,11 @@ public function __construct( $this->default = $default; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['var', 'default']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/Block.php b/lib/PhpParser/Node/Stmt/Block.php index 073df2086f..2dfb958650 100644 --- a/lib/PhpParser/Node/Stmt/Block.php +++ b/lib/PhpParser/Node/Stmt/Block.php @@ -8,6 +8,8 @@ class Block extends Stmt { /** @var Stmt[] Statements */ public array $stmts; + private const SUBNODE_NAMES = ['stmts']; + /** * A block of statements. * @@ -23,7 +25,10 @@ public function getType(): string { return 'Stmt_Block'; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['stmts']; + return self::SUBNODE_NAMES; } } diff --git a/lib/PhpParser/Node/Stmt/Break_.php b/lib/PhpParser/Node/Stmt/Break_.php index d2bcc5eb2d..96a28d2560 100644 --- a/lib/PhpParser/Node/Stmt/Break_.php +++ b/lib/PhpParser/Node/Stmt/Break_.php @@ -8,6 +8,8 @@ class Break_ extends Node\Stmt { /** @var null|Node\Expr Number of loops to break */ public ?Node\Expr $num; + private const SUBNODE_NAMES = ['num']; + /** * Constructs a break node. * @@ -19,8 +21,11 @@ public function __construct(?Node\Expr $num = null, array $attributes = []) { $this->num = $num; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['num']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/Case_.php b/lib/PhpParser/Node/Stmt/Case_.php index a06ca1832e..108ee9e799 100644 --- a/lib/PhpParser/Node/Stmt/Case_.php +++ b/lib/PhpParser/Node/Stmt/Case_.php @@ -10,6 +10,8 @@ class Case_ extends Node\Stmt { /** @var Node\Stmt[] Statements */ public array $stmts; + private const SUBNODE_NAMES = ['cond', 'stmts']; + /** * Constructs a case node. * @@ -23,8 +25,11 @@ public function __construct(?Node\Expr $cond, array $stmts = [], array $attribut $this->stmts = $stmts; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['cond', 'stmts']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/Catch_.php b/lib/PhpParser/Node/Stmt/Catch_.php index e8d39c9cce..38fa6e2ac5 100644 --- a/lib/PhpParser/Node/Stmt/Catch_.php +++ b/lib/PhpParser/Node/Stmt/Catch_.php @@ -13,6 +13,8 @@ class Catch_ extends Node\Stmt { /** @var Node\Stmt[] Statements */ public array $stmts; + private const SUBNODE_NAMES = ['types', 'var', 'stmts']; + /** * Constructs a catch node. * @@ -30,8 +32,11 @@ public function __construct( $this->stmts = $stmts; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['types', 'var', 'stmts']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/ClassConst.php b/lib/PhpParser/Node/Stmt/ClassConst.php index 9bdce1f1db..ba013a99dd 100644 --- a/lib/PhpParser/Node/Stmt/ClassConst.php +++ b/lib/PhpParser/Node/Stmt/ClassConst.php @@ -15,6 +15,8 @@ class ClassConst extends Node\Stmt { /** @var Node\Identifier|Node\Name|Node\ComplexType|null Type declaration */ public ?Node $type; + private const SUBNODE_NAMES = ['attrGroups', 'flags', 'type', 'consts']; + /** * Constructs a class const list node. * @@ -38,8 +40,11 @@ public function __construct( $this->type = $type; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['attrGroups', 'flags', 'type', 'consts']; + return self::SUBNODE_NAMES; } /** diff --git a/lib/PhpParser/Node/Stmt/ClassMethod.php b/lib/PhpParser/Node/Stmt/ClassMethod.php index 59c0519ea6..aeb2269d33 100644 --- a/lib/PhpParser/Node/Stmt/ClassMethod.php +++ b/lib/PhpParser/Node/Stmt/ClassMethod.php @@ -43,6 +43,8 @@ class ClassMethod extends Node\Stmt implements FunctionLike { '__unserialize' => true, ]; + private const SUBNODE_NAMES = ['attrGroups', 'flags', 'byRef', 'name', 'params', 'returnType', 'stmts']; + /** * Constructs a class method node. * @@ -74,8 +76,11 @@ public function __construct($name, array $subNodes = [], array $attributes = []) $this->attrGroups = $subNodes['attrGroups'] ?? []; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['attrGroups', 'flags', 'byRef', 'name', 'params', 'returnType', 'stmts']; + return self::SUBNODE_NAMES; } public function returnsByRef(): bool { diff --git a/lib/PhpParser/Node/Stmt/Class_.php b/lib/PhpParser/Node/Stmt/Class_.php index 3f492b7bb3..2c11750bf4 100644 --- a/lib/PhpParser/Node/Stmt/Class_.php +++ b/lib/PhpParser/Node/Stmt/Class_.php @@ -31,6 +31,8 @@ class Class_ extends ClassLike { /** @var Node\Name[] Names of implemented interfaces */ public array $implements; + private const SUBNODE_NAMES = ['attrGroups', 'flags', 'name', 'extends', 'implements', 'stmts']; + /** * Constructs a class node. * @@ -59,8 +61,11 @@ public function __construct($name, array $subNodes = [], array $attributes = []) $this->attrGroups = $subNodes['attrGroups'] ?? []; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['attrGroups', 'flags', 'name', 'extends', 'implements', 'stmts']; + return self::SUBNODE_NAMES; } /** diff --git a/lib/PhpParser/Node/Stmt/Const_.php b/lib/PhpParser/Node/Stmt/Const_.php index f1165fd0b0..39e4867712 100644 --- a/lib/PhpParser/Node/Stmt/Const_.php +++ b/lib/PhpParser/Node/Stmt/Const_.php @@ -8,6 +8,8 @@ class Const_ extends Node\Stmt { /** @var Node\Const_[] Constant declarations */ public array $consts; + private const SUBNODE_NAMES = ['consts']; + /** * Constructs a const list node. * @@ -19,8 +21,11 @@ public function __construct(array $consts, array $attributes = []) { $this->consts = $consts; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['consts']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/Continue_.php b/lib/PhpParser/Node/Stmt/Continue_.php index 54e979ddaa..0dcc11958b 100644 --- a/lib/PhpParser/Node/Stmt/Continue_.php +++ b/lib/PhpParser/Node/Stmt/Continue_.php @@ -8,6 +8,8 @@ class Continue_ extends Node\Stmt { /** @var null|Node\Expr Number of loops to continue */ public ?Node\Expr $num; + private const SUBNODE_NAMES = ['num']; + /** * Constructs a continue node. * @@ -19,8 +21,11 @@ public function __construct(?Node\Expr $num = null, array $attributes = []) { $this->num = $num; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['num']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/Declare_.php b/lib/PhpParser/Node/Stmt/Declare_.php index 3c0547bdf2..380f5ebaf9 100644 --- a/lib/PhpParser/Node/Stmt/Declare_.php +++ b/lib/PhpParser/Node/Stmt/Declare_.php @@ -11,6 +11,8 @@ class Declare_ extends Node\Stmt { /** @var Node\Stmt[]|null Statements */ public ?array $stmts; + private const SUBNODE_NAMES = ['declares', 'stmts']; + /** * Constructs a declare node. * @@ -24,8 +26,11 @@ public function __construct(array $declares, ?array $stmts = null, array $attrib $this->stmts = $stmts; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['declares', 'stmts']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/Do_.php b/lib/PhpParser/Node/Stmt/Do_.php index 6124442881..b83bb01e17 100644 --- a/lib/PhpParser/Node/Stmt/Do_.php +++ b/lib/PhpParser/Node/Stmt/Do_.php @@ -10,6 +10,8 @@ class Do_ extends Node\Stmt { /** @var Node\Expr Condition */ public Node\Expr $cond; + private const SUBNODE_NAMES = ['stmts', 'cond']; + /** * Constructs a do while node. * @@ -23,8 +25,11 @@ public function __construct(Node\Expr $cond, array $stmts = [], array $attribute $this->stmts = $stmts; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['stmts', 'cond']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/Echo_.php b/lib/PhpParser/Node/Stmt/Echo_.php index 4d42452353..95f2ee83a2 100644 --- a/lib/PhpParser/Node/Stmt/Echo_.php +++ b/lib/PhpParser/Node/Stmt/Echo_.php @@ -8,6 +8,8 @@ class Echo_ extends Node\Stmt { /** @var Node\Expr[] Expressions */ public array $exprs; + private const SUBNODE_NAMES = ['exprs']; + /** * Constructs an echo node. * @@ -19,8 +21,11 @@ public function __construct(array $exprs, array $attributes = []) { $this->exprs = $exprs; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['exprs']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/ElseIf_.php b/lib/PhpParser/Node/Stmt/ElseIf_.php index b26d59ce5f..30318cd74e 100644 --- a/lib/PhpParser/Node/Stmt/ElseIf_.php +++ b/lib/PhpParser/Node/Stmt/ElseIf_.php @@ -10,6 +10,8 @@ class ElseIf_ extends Node\Stmt { /** @var Node\Stmt[] Statements */ public array $stmts; + private const SUBNODE_NAMES = ['cond', 'stmts']; + /** * Constructs an elseif node. * @@ -23,8 +25,11 @@ public function __construct(Node\Expr $cond, array $stmts = [], array $attribute $this->stmts = $stmts; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['cond', 'stmts']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/Else_.php b/lib/PhpParser/Node/Stmt/Else_.php index 3d2b066ec9..34127321b4 100644 --- a/lib/PhpParser/Node/Stmt/Else_.php +++ b/lib/PhpParser/Node/Stmt/Else_.php @@ -8,6 +8,8 @@ class Else_ extends Node\Stmt { /** @var Node\Stmt[] Statements */ public array $stmts; + private const SUBNODE_NAMES = ['stmts']; + /** * Constructs an else node. * @@ -19,8 +21,11 @@ public function __construct(array $stmts = [], array $attributes = []) { $this->stmts = $stmts; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['stmts']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/EnumCase.php b/lib/PhpParser/Node/Stmt/EnumCase.php index c071a0af13..c86ffa99d7 100644 --- a/lib/PhpParser/Node/Stmt/EnumCase.php +++ b/lib/PhpParser/Node/Stmt/EnumCase.php @@ -13,6 +13,8 @@ class EnumCase extends Node\Stmt { /** @var Node\AttributeGroup[] PHP attribute groups */ public array $attrGroups; + private const SUBNODE_NAMES = ['attrGroups', 'name', 'expr']; + /** * @param string|Node\Identifier $name Enum case name * @param Node\Expr|null $expr Enum case expression @@ -26,8 +28,11 @@ public function __construct($name, ?Node\Expr $expr = null, array $attrGroups = $this->attrGroups = $attrGroups; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['attrGroups', 'name', 'expr']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/Enum_.php b/lib/PhpParser/Node/Stmt/Enum_.php index 7eea6a6991..5d2eac118e 100644 --- a/lib/PhpParser/Node/Stmt/Enum_.php +++ b/lib/PhpParser/Node/Stmt/Enum_.php @@ -10,6 +10,8 @@ class Enum_ extends ClassLike { /** @var Node\Name[] Names of implemented interfaces */ public array $implements; + private const SUBNODE_NAMES = ['attrGroups', 'name', 'scalarType', 'implements', 'stmts']; + /** * @param string|Node\Identifier|null $name Name * @param array{ @@ -34,8 +36,11 @@ public function __construct($name, array $subNodes = [], array $attributes = []) parent::__construct($attributes); } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['attrGroups', 'name', 'scalarType', 'implements', 'stmts']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/Expression.php b/lib/PhpParser/Node/Stmt/Expression.php index 89751fa2dc..3f910a1c88 100644 --- a/lib/PhpParser/Node/Stmt/Expression.php +++ b/lib/PhpParser/Node/Stmt/Expression.php @@ -11,6 +11,8 @@ class Expression extends Node\Stmt { /** @var Node\Expr Expression */ public Node\Expr $expr; + private const SUBNODE_NAMES = ['expr']; + /** * Constructs an expression statement. * @@ -22,8 +24,11 @@ public function __construct(Node\Expr $expr, array $attributes = []) { $this->expr = $expr; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['expr']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/Finally_.php b/lib/PhpParser/Node/Stmt/Finally_.php index 69ecf25373..c8bf379d68 100644 --- a/lib/PhpParser/Node/Stmt/Finally_.php +++ b/lib/PhpParser/Node/Stmt/Finally_.php @@ -8,6 +8,8 @@ class Finally_ extends Node\Stmt { /** @var Node\Stmt[] Statements */ public array $stmts; + private const SUBNODE_NAMES = ['stmts']; + /** * Constructs a finally node. * @@ -19,8 +21,11 @@ public function __construct(array $stmts = [], array $attributes = []) { $this->stmts = $stmts; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['stmts']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/For_.php b/lib/PhpParser/Node/Stmt/For_.php index 6f2fbb9e3a..d30a69fa37 100644 --- a/lib/PhpParser/Node/Stmt/For_.php +++ b/lib/PhpParser/Node/Stmt/For_.php @@ -14,6 +14,8 @@ class For_ extends Node\Stmt { /** @var Node\Stmt[] Statements */ public array $stmts; + private const SUBNODE_NAMES = ['init', 'cond', 'loop', 'stmts']; + /** * Constructs a for loop node. * @@ -37,8 +39,11 @@ public function __construct(array $subNodes = [], array $attributes = []) { $this->stmts = $subNodes['stmts'] ?? []; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['init', 'cond', 'loop', 'stmts']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/Foreach_.php b/lib/PhpParser/Node/Stmt/Foreach_.php index c5d9a8b132..2892cdf53a 100644 --- a/lib/PhpParser/Node/Stmt/Foreach_.php +++ b/lib/PhpParser/Node/Stmt/Foreach_.php @@ -16,6 +16,8 @@ class Foreach_ extends Node\Stmt { /** @var Node\Stmt[] Statements */ public array $stmts; + private const SUBNODE_NAMES = ['expr', 'keyVar', 'byRef', 'valueVar', 'stmts']; + /** * Constructs a foreach node. * @@ -40,8 +42,11 @@ public function __construct(Node\Expr $expr, Node\Expr $valueVar, array $subNode $this->stmts = $subNodes['stmts'] ?? []; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['expr', 'keyVar', 'byRef', 'valueVar', 'stmts']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/Function_.php b/lib/PhpParser/Node/Stmt/Function_.php index 2111bab749..feb1c110e7 100644 --- a/lib/PhpParser/Node/Stmt/Function_.php +++ b/lib/PhpParser/Node/Stmt/Function_.php @@ -22,6 +22,8 @@ class Function_ extends Node\Stmt implements FunctionLike { /** @var Node\Name|null Namespaced name (if using NameResolver) */ public ?Node\Name $namespacedName; + private const SUBNODE_NAMES = ['attrGroups', 'byRef', 'name', 'params', 'returnType', 'stmts']; + /** * Constructs a function node. * @@ -50,10 +52,12 @@ public function __construct($name, array $subNodes = [], array $attributes = []) $this->attrGroups = $subNodes['attrGroups'] ?? []; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['attrGroups', 'byRef', 'name', 'params', 'returnType', 'stmts']; + return self::SUBNODE_NAMES; } - public function returnsByRef(): bool { return $this->byRef; } diff --git a/lib/PhpParser/Node/Stmt/Global_.php b/lib/PhpParser/Node/Stmt/Global_.php index d3ab12fc24..1f00e8d890 100644 --- a/lib/PhpParser/Node/Stmt/Global_.php +++ b/lib/PhpParser/Node/Stmt/Global_.php @@ -8,6 +8,8 @@ class Global_ extends Node\Stmt { /** @var Node\Expr[] Variables */ public array $vars; + private const SUBNODE_NAMES = ['vars']; + /** * Constructs a global variables list node. * @@ -19,8 +21,11 @@ public function __construct(array $vars, array $attributes = []) { $this->vars = $vars; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['vars']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/Goto_.php b/lib/PhpParser/Node/Stmt/Goto_.php index 26a0d01eae..0f543180c9 100644 --- a/lib/PhpParser/Node/Stmt/Goto_.php +++ b/lib/PhpParser/Node/Stmt/Goto_.php @@ -9,6 +9,8 @@ class Goto_ extends Stmt { /** @var Identifier Name of label to jump to */ public Identifier $name; + private const SUBNODE_NAMES = ['name']; + /** * Constructs a goto node. * @@ -20,8 +22,11 @@ public function __construct($name, array $attributes = []) { $this->name = \is_string($name) ? new Identifier($name) : $name; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['name']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/GroupUse.php b/lib/PhpParser/Node/Stmt/GroupUse.php index 0ec8e9d42b..4d4c6b62a4 100644 --- a/lib/PhpParser/Node/Stmt/GroupUse.php +++ b/lib/PhpParser/Node/Stmt/GroupUse.php @@ -16,6 +16,8 @@ class GroupUse extends Stmt { /** @var UseItem[] Uses */ public array $uses; + private const SUBNODE_NAMES = ['type', 'prefix', 'uses']; + /** * Constructs a group use node. * @@ -31,10 +33,12 @@ public function __construct(Name $prefix, array $uses, int $type = Use_::TYPE_NO $this->uses = $uses; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['type', 'prefix', 'uses']; + return self::SUBNODE_NAMES; } - public function getType(): string { return 'Stmt_GroupUse'; } diff --git a/lib/PhpParser/Node/Stmt/HaltCompiler.php b/lib/PhpParser/Node/Stmt/HaltCompiler.php index 665bacdee2..590b6bb449 100644 --- a/lib/PhpParser/Node/Stmt/HaltCompiler.php +++ b/lib/PhpParser/Node/Stmt/HaltCompiler.php @@ -8,6 +8,8 @@ class HaltCompiler extends Stmt { /** @var string Remaining text after halt compiler statement. */ public string $remaining; + private const SUBNODE_NAMES = ['remaining']; + /** * Constructs a __halt_compiler node. * @@ -19,10 +21,12 @@ public function __construct(string $remaining, array $attributes = []) { $this->remaining = $remaining; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['remaining']; + return self::SUBNODE_NAMES; } - public function getType(): string { return 'Stmt_HaltCompiler'; } diff --git a/lib/PhpParser/Node/Stmt/If_.php b/lib/PhpParser/Node/Stmt/If_.php index 544390ff5e..58e393ff16 100644 --- a/lib/PhpParser/Node/Stmt/If_.php +++ b/lib/PhpParser/Node/Stmt/If_.php @@ -14,6 +14,8 @@ class If_ extends Node\Stmt { /** @var null|Else_ Else clause */ public ?Else_ $else; + private const SUBNODE_NAMES = ['cond', 'stmts', 'elseifs', 'else']; + /** * Constructs an if node. * @@ -36,8 +38,11 @@ public function __construct(Node\Expr $cond, array $subNodes = [], array $attrib $this->else = $subNodes['else'] ?? null; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['cond', 'stmts', 'elseifs', 'else']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/InlineHTML.php b/lib/PhpParser/Node/Stmt/InlineHTML.php index 0515d02054..bb3d840c04 100644 --- a/lib/PhpParser/Node/Stmt/InlineHTML.php +++ b/lib/PhpParser/Node/Stmt/InlineHTML.php @@ -8,6 +8,8 @@ class InlineHTML extends Stmt { /** @var string String */ public string $value; + private const SUBNODE_NAMES = ['value']; + /** * Constructs an inline HTML node. * @@ -19,10 +21,12 @@ public function __construct(string $value, array $attributes = []) { $this->value = $value; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['value']; + return self::SUBNODE_NAMES; } - public function getType(): string { return 'Stmt_InlineHTML'; } diff --git a/lib/PhpParser/Node/Stmt/Interface_.php b/lib/PhpParser/Node/Stmt/Interface_.php index 9359064f8e..1cca07f6f1 100644 --- a/lib/PhpParser/Node/Stmt/Interface_.php +++ b/lib/PhpParser/Node/Stmt/Interface_.php @@ -8,6 +8,8 @@ class Interface_ extends ClassLike { /** @var Node\Name[] Extended interfaces */ public array $extends; + private const SUBNODE_NAMES = ['attrGroups', 'name', 'extends', 'stmts']; + /** * Constructs a class node. * @@ -30,8 +32,11 @@ public function __construct($name, array $subNodes = [], array $attributes = []) $this->attrGroups = $subNodes['attrGroups'] ?? []; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['attrGroups', 'name', 'extends', 'stmts']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/Label.php b/lib/PhpParser/Node/Stmt/Label.php index 658468d2f6..5fcf64e17d 100644 --- a/lib/PhpParser/Node/Stmt/Label.php +++ b/lib/PhpParser/Node/Stmt/Label.php @@ -9,6 +9,8 @@ class Label extends Stmt { /** @var Identifier Name */ public Identifier $name; + private const SUBNODE_NAMES = ['name']; + /** * Constructs a label node. * @@ -20,10 +22,12 @@ public function __construct($name, array $attributes = []) { $this->name = \is_string($name) ? new Identifier($name) : $name; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['name']; + return self::SUBNODE_NAMES; } - public function getType(): string { return 'Stmt_Label'; } diff --git a/lib/PhpParser/Node/Stmt/Namespace_.php b/lib/PhpParser/Node/Stmt/Namespace_.php index f5b59ad6e3..54abb3dc65 100644 --- a/lib/PhpParser/Node/Stmt/Namespace_.php +++ b/lib/PhpParser/Node/Stmt/Namespace_.php @@ -14,6 +14,8 @@ class Namespace_ extends Node\Stmt { /** @var Node\Stmt[] Statements */ public $stmts; + private const SUBNODE_NAMES = ['name', 'stmts']; + /** * Constructs a namespace node. * @@ -27,10 +29,12 @@ public function __construct(?Node\Name $name = null, ?array $stmts = [], array $ $this->stmts = $stmts; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['name', 'stmts']; + return self::SUBNODE_NAMES; } - public function getType(): string { return 'Stmt_Namespace'; } diff --git a/lib/PhpParser/Node/Stmt/Property.php b/lib/PhpParser/Node/Stmt/Property.php index 3b238c76a9..909c70463d 100644 --- a/lib/PhpParser/Node/Stmt/Property.php +++ b/lib/PhpParser/Node/Stmt/Property.php @@ -21,6 +21,8 @@ class Property extends Node\Stmt { /** @var Node\PropertyHook[] Property hooks */ public array $hooks; + private const SUBNODE_NAMES = ['attrGroups', 'flags', 'type', 'props', 'hooks']; + /** * Constructs a class property list node. * @@ -40,8 +42,11 @@ public function __construct(int $flags, array $props, array $attributes = [], ?N $this->hooks = $hooks; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['attrGroups', 'flags', 'type', 'props', 'hooks']; + return self::SUBNODE_NAMES; } /** diff --git a/lib/PhpParser/Node/Stmt/Return_.php b/lib/PhpParser/Node/Stmt/Return_.php index 9c44cca85c..8f6fdbe635 100644 --- a/lib/PhpParser/Node/Stmt/Return_.php +++ b/lib/PhpParser/Node/Stmt/Return_.php @@ -8,6 +8,8 @@ class Return_ extends Node\Stmt { /** @var null|Node\Expr Expression */ public ?Node\Expr $expr; + private const SUBNODE_NAMES = ['expr']; + /** * Constructs a return node. * @@ -19,8 +21,11 @@ public function __construct(?Node\Expr $expr = null, array $attributes = []) { $this->expr = $expr; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['expr']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/Static_.php b/lib/PhpParser/Node/Stmt/Static_.php index a84de106ac..6f059761a8 100644 --- a/lib/PhpParser/Node/Stmt/Static_.php +++ b/lib/PhpParser/Node/Stmt/Static_.php @@ -9,6 +9,8 @@ class Static_ extends Stmt { /** @var StaticVar[] Variable definitions */ public array $vars; + private const SUBNODE_NAMES = ['vars']; + /** * Constructs a static variables list node. * @@ -20,10 +22,12 @@ public function __construct(array $vars, array $attributes = []) { $this->vars = $vars; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['vars']; + return self::SUBNODE_NAMES; } - public function getType(): string { return 'Stmt_Static'; } diff --git a/lib/PhpParser/Node/Stmt/Switch_.php b/lib/PhpParser/Node/Stmt/Switch_.php index 21e5efa569..c3aeef2ad3 100644 --- a/lib/PhpParser/Node/Stmt/Switch_.php +++ b/lib/PhpParser/Node/Stmt/Switch_.php @@ -10,6 +10,8 @@ class Switch_ extends Node\Stmt { /** @var Case_[] Case list */ public array $cases; + private const SUBNODE_NAMES = ['cond', 'cases']; + /** * Constructs a case node. * @@ -23,10 +25,12 @@ public function __construct(Node\Expr $cond, array $cases, array $attributes = [ $this->cases = $cases; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['cond', 'cases']; + return self::SUBNODE_NAMES; } - public function getType(): string { return 'Stmt_Switch'; } diff --git a/lib/PhpParser/Node/Stmt/TraitUse.php b/lib/PhpParser/Node/Stmt/TraitUse.php index 7705a57057..4d843fbad6 100644 --- a/lib/PhpParser/Node/Stmt/TraitUse.php +++ b/lib/PhpParser/Node/Stmt/TraitUse.php @@ -10,6 +10,8 @@ class TraitUse extends Node\Stmt { /** @var TraitUseAdaptation[] Adaptations */ public array $adaptations; + private const SUBNODE_NAMES = ['traits', 'adaptations']; + /** * Constructs a trait use node. * @@ -23,10 +25,12 @@ public function __construct(array $traits, array $adaptations = [], array $attri $this->adaptations = $adaptations; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['traits', 'adaptations']; + return self::SUBNODE_NAMES; } - public function getType(): string { return 'Stmt_TraitUse'; } diff --git a/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php b/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php index 449671e771..ab07ab3ad6 100644 --- a/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php +++ b/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php @@ -10,6 +10,8 @@ class Alias extends Node\Stmt\TraitUseAdaptation { /** @var null|Node\Identifier New name */ public ?Node\Identifier $newName; + private const SUBNODE_NAMES = ['trait', 'method', 'newModifier', 'newName']; + /** * Constructs a trait use precedence adaptation node. * @@ -27,10 +29,12 @@ public function __construct(?Node\Name $trait, $method, ?int $newModifier, $newN $this->newName = \is_string($newName) ? new Node\Identifier($newName) : $newName; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['trait', 'method', 'newModifier', 'newName']; + return self::SUBNODE_NAMES; } - public function getType(): string { return 'Stmt_TraitUseAdaptation_Alias'; } diff --git a/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php b/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php index 7bc4083769..c26f3d1828 100644 --- a/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php +++ b/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php @@ -8,6 +8,8 @@ class Precedence extends Node\Stmt\TraitUseAdaptation { /** @var Node\Name[] Overwritten traits */ public array $insteadof; + private const SUBNODE_NAMES = ['trait', 'method', 'insteadof']; + /** * Constructs a trait use precedence adaptation node. * @@ -23,10 +25,12 @@ public function __construct(Node\Name $trait, $method, array $insteadof, array $ $this->insteadof = $insteadof; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['trait', 'method', 'insteadof']; + return self::SUBNODE_NAMES; } - public function getType(): string { return 'Stmt_TraitUseAdaptation_Precedence'; } diff --git a/lib/PhpParser/Node/Stmt/Trait_.php b/lib/PhpParser/Node/Stmt/Trait_.php index 5f2b33070a..b0f796b63a 100644 --- a/lib/PhpParser/Node/Stmt/Trait_.php +++ b/lib/PhpParser/Node/Stmt/Trait_.php @@ -5,6 +5,8 @@ use PhpParser\Node; class Trait_ extends ClassLike { + private const SUBNODE_NAMES = ['attrGroups', 'name', 'stmts']; + /** * Constructs a trait node. * @@ -24,10 +26,12 @@ public function __construct($name, array $subNodes = [], array $attributes = []) $this->attrGroups = $subNodes['attrGroups'] ?? []; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['attrGroups', 'name', 'stmts']; + return self::SUBNODE_NAMES; } - public function getType(): string { return 'Stmt_Trait'; } diff --git a/lib/PhpParser/Node/Stmt/TryCatch.php b/lib/PhpParser/Node/Stmt/TryCatch.php index 6414c46c94..7a47e79a3a 100644 --- a/lib/PhpParser/Node/Stmt/TryCatch.php +++ b/lib/PhpParser/Node/Stmt/TryCatch.php @@ -12,6 +12,8 @@ class TryCatch extends Node\Stmt { /** @var null|Finally_ Optional finally node */ public ?Finally_ $finally; + private const SUBNODE_NAMES = ['stmts', 'catches', 'finally']; + /** * Constructs a try catch node. * @@ -27,10 +29,12 @@ public function __construct(array $stmts, array $catches, ?Finally_ $finally = n $this->finally = $finally; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['stmts', 'catches', 'finally']; + return self::SUBNODE_NAMES; } - public function getType(): string { return 'Stmt_TryCatch'; } diff --git a/lib/PhpParser/Node/Stmt/Unset_.php b/lib/PhpParser/Node/Stmt/Unset_.php index c211beb0c5..ffe2cc0505 100644 --- a/lib/PhpParser/Node/Stmt/Unset_.php +++ b/lib/PhpParser/Node/Stmt/Unset_.php @@ -8,6 +8,8 @@ class Unset_ extends Node\Stmt { /** @var Node\Expr[] Variables to unset */ public array $vars; + private const SUBNODE_NAMES = ['vars']; + /** * Constructs an unset node. * @@ -19,10 +21,12 @@ public function __construct(array $vars, array $attributes = []) { $this->vars = $vars; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['vars']; + return self::SUBNODE_NAMES; } - public function getType(): string { return 'Stmt_Unset'; } diff --git a/lib/PhpParser/Node/Stmt/Use_.php b/lib/PhpParser/Node/Stmt/Use_.php index 5b2d864832..46f4e2eb98 100644 --- a/lib/PhpParser/Node/Stmt/Use_.php +++ b/lib/PhpParser/Node/Stmt/Use_.php @@ -24,6 +24,8 @@ class Use_ extends Stmt { /** @var UseItem[] Aliases */ public array $uses; + private const SUBNODE_NAMES = ['type', 'uses']; + /** * Constructs an alias (use) list node. * @@ -37,8 +39,11 @@ public function __construct(array $uses, int $type = self::TYPE_NORMAL, array $a $this->uses = $uses; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['type', 'uses']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/Stmt/While_.php b/lib/PhpParser/Node/Stmt/While_.php index 2f7aed2343..abdb3f1e77 100644 --- a/lib/PhpParser/Node/Stmt/While_.php +++ b/lib/PhpParser/Node/Stmt/While_.php @@ -10,6 +10,8 @@ class While_ extends Node\Stmt { /** @var Node\Stmt[] Statements */ public array $stmts; + private const SUBNODE_NAMES = ['cond', 'stmts']; + /** * Constructs a while node. * @@ -23,8 +25,11 @@ public function __construct(Node\Expr $cond, array $stmts = [], array $attribute $this->stmts = $stmts; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['cond', 'stmts']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/UnionType.php b/lib/PhpParser/Node/UnionType.php index bad88d2b8b..b27f74e3dc 100644 --- a/lib/PhpParser/Node/UnionType.php +++ b/lib/PhpParser/Node/UnionType.php @@ -6,6 +6,8 @@ class UnionType extends ComplexType { /** @var (Identifier|Name|IntersectionType)[] Types */ public array $types; + private const SUBNODE_NAMES = ['types']; + /** * Constructs a union type. * @@ -17,8 +19,11 @@ public function __construct(array $types, array $attributes = []) { $this->types = $types; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['types']; + return self::SUBNODE_NAMES; } public function getType(): string { diff --git a/lib/PhpParser/Node/UseItem.php b/lib/PhpParser/Node/UseItem.php index a7d9fc447c..e836a43f25 100644 --- a/lib/PhpParser/Node/UseItem.php +++ b/lib/PhpParser/Node/UseItem.php @@ -16,6 +16,8 @@ class UseItem extends NodeAbstract { /** @var Identifier|null Alias */ public ?Identifier $alias; + private const SUBNODE_NAMES = ['type', 'name', 'alias']; + /** * Constructs an alias (use) item node. * @@ -31,8 +33,11 @@ public function __construct(Node\Name $name, $alias = null, int $type = Use_::TY $this->alias = \is_string($alias) ? new Identifier($alias) : $alias; } + /** + * @return self::SUBNODE_NAMES + */ public function getSubNodeNames(): array { - return ['type', 'name', 'alias']; + return self::SUBNODE_NAMES; } /**