repo
stringlengths
7
63
file_url
stringlengths
81
284
file_path
stringlengths
5
200
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:02:33
2026-01-05 05:24:06
truncated
bool
2 classes
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Builder/TraitUseAdaptation.php
lib/PhpParser/Builder/TraitUseAdaptation.php
<?php declare(strict_types=1); namespace PhpParser\Builder; use PhpParser\Builder; use PhpParser\BuilderHelpers; use PhpParser\Modifiers; use PhpParser\Node; use PhpParser\Node\Stmt; class TraitUseAdaptation implements Builder { private const TYPE_UNDEFINED = 0; private const TYPE_ALIAS = 1; private const TYPE_PRECEDENCE = 2; protected int $type; protected ?Node\Name $trait; protected Node\Identifier $method; protected ?int $modifier = null; protected ?Node\Identifier $alias = null; /** @var Node\Name[] */ protected array $insteadof = []; /** * Creates a trait use adaptation builder. * * @param Node\Name|string|null $trait Name of adapted trait * @param Node\Identifier|string $method Name of adapted method */ public function __construct($trait, $method) { $this->type = self::TYPE_UNDEFINED; $this->trait = is_null($trait) ? null : BuilderHelpers::normalizeName($trait); $this->method = BuilderHelpers::normalizeIdentifier($method); } /** * Sets alias of method. * * @param Node\Identifier|string $alias Alias for adapted method * * @return $this The builder instance (for fluid interface) */ public function as($alias) { if ($this->type === self::TYPE_UNDEFINED) { $this->type = self::TYPE_ALIAS; } if ($this->type !== self::TYPE_ALIAS) { throw new \LogicException('Cannot set alias for not alias adaptation buider'); } $this->alias = BuilderHelpers::normalizeIdentifier($alias); return $this; } /** * Sets adapted method public. * * @return $this The builder instance (for fluid interface) */ public function makePublic() { $this->setModifier(Modifiers::PUBLIC); return $this; } /** * Sets adapted method protected. * * @return $this The builder instance (for fluid interface) */ public function makeProtected() { $this->setModifier(Modifiers::PROTECTED); return $this; } /** * Sets adapted method private. * * @return $this The builder instance (for fluid interface) */ public function makePrivate() { $this->setModifier(Modifiers::PRIVATE); return $this; } /** * Adds overwritten traits. * * @param Node\Name|string ...$traits Traits for overwrite * * @return $this The builder instance (for fluid interface) */ public function insteadof(...$traits) { if ($this->type === self::TYPE_UNDEFINED) { if (is_null($this->trait)) { throw new \LogicException('Precedence adaptation must have trait'); } $this->type = self::TYPE_PRECEDENCE; } if ($this->type !== self::TYPE_PRECEDENCE) { throw new \LogicException('Cannot add overwritten traits for not precedence adaptation buider'); } foreach ($traits as $trait) { $this->insteadof[] = BuilderHelpers::normalizeName($trait); } return $this; } protected function setModifier(int $modifier): void { if ($this->type === self::TYPE_UNDEFINED) { $this->type = self::TYPE_ALIAS; } if ($this->type !== self::TYPE_ALIAS) { throw new \LogicException('Cannot set access modifier for not alias adaptation buider'); } if (is_null($this->modifier)) { $this->modifier = $modifier; } else { throw new \LogicException('Multiple access type modifiers are not allowed'); } } /** * Returns the built node. * * @return Node The built node */ public function getNode(): Node { switch ($this->type) { case self::TYPE_ALIAS: return new Stmt\TraitUseAdaptation\Alias($this->trait, $this->method, $this->modifier, $this->alias); case self::TYPE_PRECEDENCE: return new Stmt\TraitUseAdaptation\Precedence($this->trait, $this->method, $this->insteadof); default: throw new \LogicException('Type of adaptation is not defined'); } } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Builder/Method.php
lib/PhpParser/Builder/Method.php
<?php declare(strict_types=1); namespace PhpParser\Builder; use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Modifiers; use PhpParser\Node; use PhpParser\Node\Stmt; class Method extends FunctionLike { protected string $name; protected int $flags = 0; /** @var list<Stmt>|null */ protected ?array $stmts = []; /** @var list<Node\AttributeGroup> */ protected array $attributeGroups = []; /** * Creates a method builder. * * @param string $name Name of the method */ public function __construct(string $name) { $this->name = $name; } /** * Makes the method public. * * @return $this The builder instance (for fluid interface) */ public function makePublic() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PUBLIC); return $this; } /** * Makes the method protected. * * @return $this The builder instance (for fluid interface) */ public function makeProtected() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED); return $this; } /** * Makes the method private. * * @return $this The builder instance (for fluid interface) */ public function makePrivate() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE); return $this; } /** * Makes the method static. * * @return $this The builder instance (for fluid interface) */ public function makeStatic() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::STATIC); return $this; } /** * Makes the method abstract. * * @return $this The builder instance (for fluid interface) */ public function makeAbstract() { if (!empty($this->stmts)) { throw new \LogicException('Cannot make method with statements abstract'); } $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::ABSTRACT); $this->stmts = null; // abstract methods don't have statements return $this; } /** * Makes the method final. * * @return $this The builder instance (for fluid interface) */ public function makeFinal() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::FINAL); return $this; } /** * Adds a statement. * * @param Node|PhpParser\Builder $stmt The statement to add * * @return $this The builder instance (for fluid interface) */ public function addStmt($stmt) { if (null === $this->stmts) { throw new \LogicException('Cannot add statements to an abstract method'); } $this->stmts[] = BuilderHelpers::normalizeStmt($stmt); return $this; } /** * Adds an attribute group. * * @param Node\Attribute|Node\AttributeGroup $attribute * * @return $this The builder instance (for fluid interface) */ public function addAttribute($attribute) { $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } /** * Returns the built method node. * * @return Stmt\ClassMethod The built method node */ public function getNode(): Node { return new Stmt\ClassMethod($this->name, [ 'flags' => $this->flags, 'byRef' => $this->returnByRef, 'params' => $this->params, 'returnType' => $this->returnType, 'stmts' => $this->stmts, 'attrGroups' => $this->attributeGroups, ], $this->attributes); } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Builder/Class_.php
lib/PhpParser/Builder/Class_.php
<?php declare(strict_types=1); namespace PhpParser\Builder; use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Modifiers; use PhpParser\Node; use PhpParser\Node\Name; use PhpParser\Node\Stmt; class Class_ extends Declaration { protected string $name; protected ?Name $extends = null; /** @var list<Name> */ protected array $implements = []; protected int $flags = 0; /** @var list<Stmt\TraitUse> */ protected array $uses = []; /** @var list<Stmt\ClassConst> */ protected array $constants = []; /** @var list<Stmt\Property> */ protected array $properties = []; /** @var list<Stmt\ClassMethod> */ protected array $methods = []; /** @var list<Node\AttributeGroup> */ protected array $attributeGroups = []; /** * Creates a class builder. * * @param string $name Name of the class */ public function __construct(string $name) { $this->name = $name; } /** * Extends a class. * * @param Name|string $class Name of class to extend * * @return $this The builder instance (for fluid interface) */ public function extend($class) { $this->extends = BuilderHelpers::normalizeName($class); return $this; } /** * Implements one or more interfaces. * * @param Name|string ...$interfaces Names of interfaces to implement * * @return $this The builder instance (for fluid interface) */ public function implement(...$interfaces) { foreach ($interfaces as $interface) { $this->implements[] = BuilderHelpers::normalizeName($interface); } return $this; } /** * Makes the class abstract. * * @return $this The builder instance (for fluid interface) */ public function makeAbstract() { $this->flags = BuilderHelpers::addClassModifier($this->flags, Modifiers::ABSTRACT); return $this; } /** * Makes the class final. * * @return $this The builder instance (for fluid interface) */ public function makeFinal() { $this->flags = BuilderHelpers::addClassModifier($this->flags, Modifiers::FINAL); return $this; } /** * Makes the class readonly. * * @return $this The builder instance (for fluid interface) */ public function makeReadonly() { $this->flags = BuilderHelpers::addClassModifier($this->flags, Modifiers::READONLY); return $this; } /** * Adds a statement. * * @param Stmt|PhpParser\Builder $stmt The statement to add * * @return $this The builder instance (for fluid interface) */ public function addStmt($stmt) { $stmt = BuilderHelpers::normalizeNode($stmt); if ($stmt instanceof Stmt\Property) { $this->properties[] = $stmt; } elseif ($stmt instanceof Stmt\ClassMethod) { $this->methods[] = $stmt; } elseif ($stmt instanceof Stmt\TraitUse) { $this->uses[] = $stmt; } elseif ($stmt instanceof Stmt\ClassConst) { $this->constants[] = $stmt; } else { throw new \LogicException(sprintf('Unexpected node of type "%s"', $stmt->getType())); } return $this; } /** * Adds an attribute group. * * @param Node\Attribute|Node\AttributeGroup $attribute * * @return $this The builder instance (for fluid interface) */ public function addAttribute($attribute) { $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } /** * Returns the built class node. * * @return Stmt\Class_ The built class node */ public function getNode(): PhpParser\Node { return new Stmt\Class_($this->name, [ 'flags' => $this->flags, 'extends' => $this->extends, 'implements' => $this->implements, 'stmts' => array_merge($this->uses, $this->constants, $this->properties, $this->methods), 'attrGroups' => $this->attributeGroups, ], $this->attributes); } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Builder/Interface_.php
lib/PhpParser/Builder/Interface_.php
<?php declare(strict_types=1); namespace PhpParser\Builder; use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Name; use PhpParser\Node\Stmt; class Interface_ extends Declaration { protected string $name; /** @var list<Name> */ protected array $extends = []; /** @var list<Stmt\ClassConst> */ protected array $constants = []; /** @var list<Stmt\ClassMethod> */ protected array $methods = []; /** @var list<Node\AttributeGroup> */ protected array $attributeGroups = []; /** * Creates an interface builder. * * @param string $name Name of the interface */ public function __construct(string $name) { $this->name = $name; } /** * Extends one or more interfaces. * * @param Name|string ...$interfaces Names of interfaces to extend * * @return $this The builder instance (for fluid interface) */ public function extend(...$interfaces) { foreach ($interfaces as $interface) { $this->extends[] = BuilderHelpers::normalizeName($interface); } return $this; } /** * Adds a statement. * * @param Stmt|PhpParser\Builder $stmt The statement to add * * @return $this The builder instance (for fluid interface) */ public function addStmt($stmt) { $stmt = BuilderHelpers::normalizeNode($stmt); if ($stmt instanceof Stmt\ClassConst) { $this->constants[] = $stmt; } elseif ($stmt instanceof Stmt\ClassMethod) { // we erase all statements in the body of an interface method $stmt->stmts = null; $this->methods[] = $stmt; } else { throw new \LogicException(sprintf('Unexpected node of type "%s"', $stmt->getType())); } return $this; } /** * Adds an attribute group. * * @param Node\Attribute|Node\AttributeGroup $attribute * * @return $this The builder instance (for fluid interface) */ public function addAttribute($attribute) { $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } /** * Returns the built interface node. * * @return Stmt\Interface_ The built interface node */ public function getNode(): PhpParser\Node { return new Stmt\Interface_($this->name, [ 'extends' => $this->extends, 'stmts' => array_merge($this->constants, $this->methods), 'attrGroups' => $this->attributeGroups, ], $this->attributes); } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Builder/EnumCase.php
lib/PhpParser/Builder/EnumCase.php
<?php declare(strict_types=1); namespace PhpParser\Builder; use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Identifier; use PhpParser\Node\Stmt; class EnumCase implements PhpParser\Builder { /** @var Identifier|string */ protected $name; protected ?Node\Expr $value = null; /** @var array<string, mixed> */ protected array $attributes = []; /** @var list<Node\AttributeGroup> */ protected array $attributeGroups = []; /** * Creates an enum case builder. * * @param string|Identifier $name Name */ public function __construct($name) { $this->name = $name; } /** * Sets the value. * * @param Node\Expr|string|int $value * * @return $this */ public function setValue($value) { $this->value = BuilderHelpers::normalizeValue($value); return $this; } /** * Sets doc comment for the constant. * * @param PhpParser\Comment\Doc|string $docComment Doc comment to set * * @return $this The builder instance (for fluid interface) */ public function setDocComment($docComment) { $this->attributes = [ 'comments' => [BuilderHelpers::normalizeDocComment($docComment)] ]; return $this; } /** * Adds an attribute group. * * @param Node\Attribute|Node\AttributeGroup $attribute * * @return $this The builder instance (for fluid interface) */ public function addAttribute($attribute) { $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } /** * Returns the built enum case node. * * @return Stmt\EnumCase The built constant node */ public function getNode(): PhpParser\Node { return new Stmt\EnumCase( $this->name, $this->value, $this->attributeGroups, $this->attributes ); } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Builder/Use_.php
lib/PhpParser/Builder/Use_.php
<?php declare(strict_types=1); namespace PhpParser\Builder; use PhpParser\Builder; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Stmt; class Use_ implements Builder { protected Node\Name $name; /** @var Stmt\Use_::TYPE_* */ protected int $type; protected ?string $alias = null; /** * Creates a name use (alias) builder. * * @param Node\Name|string $name Name of the entity (namespace, class, function, constant) to alias * @param Stmt\Use_::TYPE_* $type One of the Stmt\Use_::TYPE_* constants */ public function __construct($name, int $type) { $this->name = BuilderHelpers::normalizeName($name); $this->type = $type; } /** * Sets alias for used name. * * @param string $alias Alias to use (last component of full name by default) * * @return $this The builder instance (for fluid interface) */ public function as(string $alias) { $this->alias = $alias; return $this; } /** * Returns the built node. * * @return Stmt\Use_ The built node */ public function getNode(): Node { return new Stmt\Use_([ new Node\UseItem($this->name, $this->alias) ], $this->type); } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Builder/Property.php
lib/PhpParser/Builder/Property.php
<?php declare(strict_types=1); namespace PhpParser\Builder; use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Modifiers; use PhpParser\Node; use PhpParser\Node\Identifier; use PhpParser\Node\Name; use PhpParser\Node\Stmt; use PhpParser\Node\ComplexType; class Property implements PhpParser\Builder { protected string $name; protected int $flags = 0; protected ?Node\Expr $default = null; /** @var array<string, mixed> */ protected array $attributes = []; /** @var null|Identifier|Name|ComplexType */ protected ?Node $type = null; /** @var list<Node\AttributeGroup> */ protected array $attributeGroups = []; /** @var list<Node\PropertyHook> */ protected array $hooks = []; /** * Creates a property builder. * * @param string $name Name of the property */ public function __construct(string $name) { $this->name = $name; } /** * Makes the property public. * * @return $this The builder instance (for fluid interface) */ public function makePublic() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PUBLIC); return $this; } /** * Makes the property protected. * * @return $this The builder instance (for fluid interface) */ public function makeProtected() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED); return $this; } /** * Makes the property private. * * @return $this The builder instance (for fluid interface) */ public function makePrivate() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE); return $this; } /** * Makes the property static. * * @return $this The builder instance (for fluid interface) */ public function makeStatic() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::STATIC); return $this; } /** * Makes the property readonly. * * @return $this The builder instance (for fluid interface) */ public function makeReadonly() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::READONLY); return $this; } /** * Makes the property abstract. Requires at least one property hook to be specified as well. * * @return $this The builder instance (for fluid interface) */ public function makeAbstract() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::ABSTRACT); return $this; } /** * Makes the property final. * * @return $this The builder instance (for fluid interface) */ public function makeFinal() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::FINAL); return $this; } /** * Gives the property private(set) visibility. * * @return $this The builder instance (for fluid interface) */ public function makePrivateSet() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE_SET); return $this; } /** * Gives the property protected(set) visibility. * * @return $this The builder instance (for fluid interface) */ public function makeProtectedSet() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED_SET); return $this; } /** * Sets default value for the property. * * @param mixed $value Default value to use * * @return $this The builder instance (for fluid interface) */ public function setDefault($value) { $this->default = BuilderHelpers::normalizeValue($value); return $this; } /** * Sets doc comment for the property. * * @param PhpParser\Comment\Doc|string $docComment Doc comment to set * * @return $this The builder instance (for fluid interface) */ public function setDocComment($docComment) { $this->attributes = [ 'comments' => [BuilderHelpers::normalizeDocComment($docComment)] ]; return $this; } /** * Sets the property type for PHP 7.4+. * * @param string|Name|Identifier|ComplexType $type * * @return $this */ public function setType($type) { $this->type = BuilderHelpers::normalizeType($type); return $this; } /** * Adds an attribute group. * * @param Node\Attribute|Node\AttributeGroup $attribute * * @return $this The builder instance (for fluid interface) */ public function addAttribute($attribute) { $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } /** * Adds a property hook. * * @return $this The builder instance (for fluid interface) */ public function addHook(Node\PropertyHook $hook) { $this->hooks[] = $hook; return $this; } /** * Returns the built class node. * * @return Stmt\Property The built property node */ public function getNode(): PhpParser\Node { if ($this->flags & Modifiers::ABSTRACT && !$this->hooks) { throw new PhpParser\Error('Only hooked properties may be declared abstract'); } return new Stmt\Property( $this->flags !== 0 ? $this->flags : Modifiers::PUBLIC, [ new Node\PropertyItem($this->name, $this->default) ], $this->attributes, $this->type, $this->attributeGroups, $this->hooks ); } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Builder/Namespace_.php
lib/PhpParser/Builder/Namespace_.php
<?php declare(strict_types=1); namespace PhpParser\Builder; use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Stmt; class Namespace_ extends Declaration { private ?Node\Name $name; /** @var Stmt[] */ private array $stmts = []; /** * Creates a namespace builder. * * @param Node\Name|string|null $name Name of the namespace */ public function __construct($name) { $this->name = null !== $name ? BuilderHelpers::normalizeName($name) : null; } /** * Adds a statement. * * @param Node|PhpParser\Builder $stmt The statement to add * * @return $this The builder instance (for fluid interface) */ public function addStmt($stmt) { $this->stmts[] = BuilderHelpers::normalizeStmt($stmt); return $this; } /** * Returns the built node. * * @return Stmt\Namespace_ The built node */ public function getNode(): Node { return new Stmt\Namespace_($this->name, $this->stmts, $this->attributes); } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Builder/Param.php
lib/PhpParser/Builder/Param.php
<?php declare(strict_types=1); namespace PhpParser\Builder; use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Modifiers; use PhpParser\Node; class Param implements PhpParser\Builder { protected string $name; protected ?Node\Expr $default = null; /** @var Node\Identifier|Node\Name|Node\ComplexType|null */ protected ?Node $type = null; protected bool $byRef = false; protected int $flags = 0; protected bool $variadic = false; /** @var list<Node\AttributeGroup> */ protected array $attributeGroups = []; /** * Creates a parameter builder. * * @param string $name Name of the parameter */ public function __construct(string $name) { $this->name = $name; } /** * Sets default value for the parameter. * * @param mixed $value Default value to use * * @return $this The builder instance (for fluid interface) */ public function setDefault($value) { $this->default = BuilderHelpers::normalizeValue($value); return $this; } /** * Sets type for the parameter. * * @param string|Node\Name|Node\Identifier|Node\ComplexType $type Parameter type * * @return $this The builder instance (for fluid interface) */ public function setType($type) { $this->type = BuilderHelpers::normalizeType($type); if ($this->type == 'void') { throw new \LogicException('Parameter type cannot be void'); } return $this; } /** * Make the parameter accept the value by reference. * * @return $this The builder instance (for fluid interface) */ public function makeByRef() { $this->byRef = true; return $this; } /** * Make the parameter variadic * * @return $this The builder instance (for fluid interface) */ public function makeVariadic() { $this->variadic = true; return $this; } /** * Makes the (promoted) parameter public. * * @return $this The builder instance (for fluid interface) */ public function makePublic() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PUBLIC); return $this; } /** * Makes the (promoted) parameter protected. * * @return $this The builder instance (for fluid interface) */ public function makeProtected() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED); return $this; } /** * Makes the (promoted) parameter private. * * @return $this The builder instance (for fluid interface) */ public function makePrivate() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE); return $this; } /** * Makes the (promoted) parameter readonly. * * @return $this The builder instance (for fluid interface) */ public function makeReadonly() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::READONLY); return $this; } /** * Gives the promoted property private(set) visibility. * * @return $this The builder instance (for fluid interface) */ public function makePrivateSet() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE_SET); return $this; } /** * Gives the promoted property protected(set) visibility. * * @return $this The builder instance (for fluid interface) */ public function makeProtectedSet() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED_SET); return $this; } /** * Adds an attribute group. * * @param Node\Attribute|Node\AttributeGroup $attribute * * @return $this The builder instance (for fluid interface) */ public function addAttribute($attribute) { $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } /** * Returns the built parameter node. * * @return Node\Param The built parameter node */ public function getNode(): Node { return new Node\Param( new Node\Expr\Variable($this->name), $this->default, $this->type, $this->byRef, $this->variadic, [], $this->flags, $this->attributeGroups ); } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Builder/Declaration.php
lib/PhpParser/Builder/Declaration.php
<?php declare(strict_types=1); namespace PhpParser\Builder; use PhpParser; use PhpParser\BuilderHelpers; abstract class Declaration implements PhpParser\Builder { /** @var array<string, mixed> */ protected array $attributes = []; /** * Adds a statement. * * @param PhpParser\Node\Stmt|PhpParser\Builder $stmt The statement to add * * @return $this The builder instance (for fluid interface) */ abstract public function addStmt($stmt); /** * Adds multiple statements. * * @param (PhpParser\Node\Stmt|PhpParser\Builder)[] $stmts The statements to add * * @return $this The builder instance (for fluid interface) */ public function addStmts(array $stmts) { foreach ($stmts as $stmt) { $this->addStmt($stmt); } return $this; } /** * Sets doc comment for the declaration. * * @param PhpParser\Comment\Doc|string $docComment Doc comment to set * * @return $this The builder instance (for fluid interface) */ public function setDocComment($docComment) { $this->attributes['comments'] = [ BuilderHelpers::normalizeDocComment($docComment) ]; return $this; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Builder/TraitUse.php
lib/PhpParser/Builder/TraitUse.php
<?php declare(strict_types=1); namespace PhpParser\Builder; use PhpParser\Builder; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Stmt; class TraitUse implements Builder { /** @var Node\Name[] */ protected array $traits = []; /** @var Stmt\TraitUseAdaptation[] */ protected array $adaptations = []; /** * Creates a trait use builder. * * @param Node\Name|string ...$traits Names of used traits */ public function __construct(...$traits) { foreach ($traits as $trait) { $this->and($trait); } } /** * Adds used trait. * * @param Node\Name|string $trait Trait name * * @return $this The builder instance (for fluid interface) */ public function and($trait) { $this->traits[] = BuilderHelpers::normalizeName($trait); return $this; } /** * Adds trait adaptation. * * @param Stmt\TraitUseAdaptation|Builder\TraitUseAdaptation $adaptation Trait adaptation * * @return $this The builder instance (for fluid interface) */ public function with($adaptation) { $adaptation = BuilderHelpers::normalizeNode($adaptation); if (!$adaptation instanceof Stmt\TraitUseAdaptation) { throw new \LogicException('Adaptation must have type TraitUseAdaptation'); } $this->adaptations[] = $adaptation; return $this; } /** * Returns the built node. * * @return Node The built node */ public function getNode(): Node { return new Stmt\TraitUse($this->traits, $this->adaptations); } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Builder/Enum_.php
lib/PhpParser/Builder/Enum_.php
<?php declare(strict_types=1); namespace PhpParser\Builder; use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Identifier; use PhpParser\Node\Name; use PhpParser\Node\Stmt; class Enum_ extends Declaration { protected string $name; protected ?Identifier $scalarType = null; /** @var list<Name> */ protected array $implements = []; /** @var list<Stmt\TraitUse> */ protected array $uses = []; /** @var list<Stmt\EnumCase> */ protected array $enumCases = []; /** @var list<Stmt\ClassConst> */ protected array $constants = []; /** @var list<Stmt\ClassMethod> */ protected array $methods = []; /** @var list<Node\AttributeGroup> */ protected array $attributeGroups = []; /** * Creates an enum builder. * * @param string $name Name of the enum */ public function __construct(string $name) { $this->name = $name; } /** * Sets the scalar type. * * @param string|Identifier $scalarType * * @return $this */ public function setScalarType($scalarType) { $this->scalarType = BuilderHelpers::normalizeType($scalarType); return $this; } /** * Implements one or more interfaces. * * @param Name|string ...$interfaces Names of interfaces to implement * * @return $this The builder instance (for fluid interface) */ public function implement(...$interfaces) { foreach ($interfaces as $interface) { $this->implements[] = BuilderHelpers::normalizeName($interface); } return $this; } /** * Adds a statement. * * @param Stmt|PhpParser\Builder $stmt The statement to add * * @return $this The builder instance (for fluid interface) */ public function addStmt($stmt) { $stmt = BuilderHelpers::normalizeNode($stmt); if ($stmt instanceof Stmt\EnumCase) { $this->enumCases[] = $stmt; } elseif ($stmt instanceof Stmt\ClassMethod) { $this->methods[] = $stmt; } elseif ($stmt instanceof Stmt\TraitUse) { $this->uses[] = $stmt; } elseif ($stmt instanceof Stmt\ClassConst) { $this->constants[] = $stmt; } else { throw new \LogicException(sprintf('Unexpected node of type "%s"', $stmt->getType())); } return $this; } /** * Adds an attribute group. * * @param Node\Attribute|Node\AttributeGroup $attribute * * @return $this The builder instance (for fluid interface) */ public function addAttribute($attribute) { $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } /** * Returns the built class node. * * @return Stmt\Enum_ The built enum node */ public function getNode(): PhpParser\Node { return new Stmt\Enum_($this->name, [ 'scalarType' => $this->scalarType, 'implements' => $this->implements, 'stmts' => array_merge($this->uses, $this->enumCases, $this->constants, $this->methods), 'attrGroups' => $this->attributeGroups, ], $this->attributes); } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Builder/FunctionLike.php
lib/PhpParser/Builder/FunctionLike.php
<?php declare(strict_types=1); namespace PhpParser\Builder; use PhpParser\BuilderHelpers; use PhpParser\Node; abstract class FunctionLike extends Declaration { protected bool $returnByRef = false; /** @var Node\Param[] */ protected array $params = []; /** @var Node\Identifier|Node\Name|Node\ComplexType|null */ protected ?Node $returnType = null; /** * Make the function return by reference. * * @return $this The builder instance (for fluid interface) */ public function makeReturnByRef() { $this->returnByRef = true; return $this; } /** * Adds a parameter. * * @param Node\Param|Param $param The parameter to add * * @return $this The builder instance (for fluid interface) */ public function addParam($param) { $param = BuilderHelpers::normalizeNode($param); if (!$param instanceof Node\Param) { throw new \LogicException(sprintf('Expected parameter node, got "%s"', $param->getType())); } $this->params[] = $param; return $this; } /** * Adds multiple parameters. * * @param (Node\Param|Param)[] $params The parameters to add * * @return $this The builder instance (for fluid interface) */ public function addParams(array $params) { foreach ($params as $param) { $this->addParam($param); } return $this; } /** * Sets the return type for PHP 7. * * @param string|Node\Name|Node\Identifier|Node\ComplexType $type * * @return $this The builder instance (for fluid interface) */ public function setReturnType($type) { $this->returnType = BuilderHelpers::normalizeType($type); return $this; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Builder/Function_.php
lib/PhpParser/Builder/Function_.php
<?php declare(strict_types=1); namespace PhpParser\Builder; use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Stmt; class Function_ extends FunctionLike { protected string $name; /** @var list<Stmt> */ protected array $stmts = []; /** @var list<Node\AttributeGroup> */ protected array $attributeGroups = []; /** * Creates a function builder. * * @param string $name Name of the function */ public function __construct(string $name) { $this->name = $name; } /** * Adds a statement. * * @param Node|PhpParser\Builder $stmt The statement to add * * @return $this The builder instance (for fluid interface) */ public function addStmt($stmt) { $this->stmts[] = BuilderHelpers::normalizeStmt($stmt); return $this; } /** * Adds an attribute group. * * @param Node\Attribute|Node\AttributeGroup $attribute * * @return $this The builder instance (for fluid interface) */ public function addAttribute($attribute) { $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } /** * Returns the built function node. * * @return Stmt\Function_ The built function node */ public function getNode(): Node { return new Stmt\Function_($this->name, [ 'byRef' => $this->returnByRef, 'params' => $this->params, 'returnType' => $this->returnType, 'stmts' => $this->stmts, 'attrGroups' => $this->attributeGroups, ], $this->attributes); } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Builder/Trait_.php
lib/PhpParser/Builder/Trait_.php
<?php declare(strict_types=1); namespace PhpParser\Builder; use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Node; use PhpParser\Node\Stmt; class Trait_ extends Declaration { protected string $name; /** @var list<Stmt\TraitUse> */ protected array $uses = []; /** @var list<Stmt\ClassConst> */ protected array $constants = []; /** @var list<Stmt\Property> */ protected array $properties = []; /** @var list<Stmt\ClassMethod> */ protected array $methods = []; /** @var list<Node\AttributeGroup> */ protected array $attributeGroups = []; /** * Creates an interface builder. * * @param string $name Name of the interface */ public function __construct(string $name) { $this->name = $name; } /** * Adds a statement. * * @param Stmt|PhpParser\Builder $stmt The statement to add * * @return $this The builder instance (for fluid interface) */ public function addStmt($stmt) { $stmt = BuilderHelpers::normalizeNode($stmt); if ($stmt instanceof Stmt\Property) { $this->properties[] = $stmt; } elseif ($stmt instanceof Stmt\ClassMethod) { $this->methods[] = $stmt; } elseif ($stmt instanceof Stmt\TraitUse) { $this->uses[] = $stmt; } elseif ($stmt instanceof Stmt\ClassConst) { $this->constants[] = $stmt; } else { throw new \LogicException(sprintf('Unexpected node of type "%s"', $stmt->getType())); } return $this; } /** * Adds an attribute group. * * @param Node\Attribute|Node\AttributeGroup $attribute * * @return $this The builder instance (for fluid interface) */ public function addAttribute($attribute) { $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } /** * Returns the built trait node. * * @return Stmt\Trait_ The built interface node */ public function getNode(): PhpParser\Node { return new Stmt\Trait_( $this->name, [ 'stmts' => array_merge($this->uses, $this->constants, $this->properties, $this->methods), 'attrGroups' => $this->attributeGroups, ], $this->attributes ); } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Builder/ClassConst.php
lib/PhpParser/Builder/ClassConst.php
<?php declare(strict_types=1); namespace PhpParser\Builder; use PhpParser; use PhpParser\BuilderHelpers; use PhpParser\Modifiers; use PhpParser\Node; use PhpParser\Node\Const_; use PhpParser\Node\Identifier; use PhpParser\Node\Stmt; class ClassConst implements PhpParser\Builder { protected int $flags = 0; /** @var array<string, mixed> */ protected array $attributes = []; /** @var list<Const_> */ protected array $constants = []; /** @var list<Node\AttributeGroup> */ protected array $attributeGroups = []; /** @var Identifier|Node\Name|Node\ComplexType|null */ protected ?Node $type = null; /** * Creates a class constant builder * * @param string|Identifier $name Name * @param Node\Expr|bool|null|int|float|string|array|\UnitEnum $value Value */ public function __construct($name, $value) { $this->constants = [new Const_($name, BuilderHelpers::normalizeValue($value))]; } /** * Add another constant to const group * * @param string|Identifier $name Name * @param Node\Expr|bool|null|int|float|string|array|\UnitEnum $value Value * * @return $this The builder instance (for fluid interface) */ public function addConst($name, $value) { $this->constants[] = new Const_($name, BuilderHelpers::normalizeValue($value)); return $this; } /** * Makes the constant public. * * @return $this The builder instance (for fluid interface) */ public function makePublic() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PUBLIC); return $this; } /** * Makes the constant protected. * * @return $this The builder instance (for fluid interface) */ public function makeProtected() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED); return $this; } /** * Makes the constant private. * * @return $this The builder instance (for fluid interface) */ public function makePrivate() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE); return $this; } /** * Makes the constant final. * * @return $this The builder instance (for fluid interface) */ public function makeFinal() { $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::FINAL); return $this; } /** * Sets doc comment for the constant. * * @param PhpParser\Comment\Doc|string $docComment Doc comment to set * * @return $this The builder instance (for fluid interface) */ public function setDocComment($docComment) { $this->attributes = [ 'comments' => [BuilderHelpers::normalizeDocComment($docComment)] ]; return $this; } /** * Adds an attribute group. * * @param Node\Attribute|Node\AttributeGroup $attribute * * @return $this The builder instance (for fluid interface) */ public function addAttribute($attribute) { $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute); return $this; } /** * Sets the constant type. * * @param string|Node\Name|Identifier|Node\ComplexType $type * * @return $this */ public function setType($type) { $this->type = BuilderHelpers::normalizeType($type); return $this; } /** * Returns the built class node. * * @return Stmt\ClassConst The built constant node */ public function getNode(): PhpParser\Node { return new Stmt\ClassConst( $this->constants, $this->flags, $this->attributes, $this->attributeGroups, $this->type ); } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Lexer/Emulative.php
lib/PhpParser/Lexer/Emulative.php
<?php declare(strict_types=1); namespace PhpParser\Lexer; use PhpParser\Error; use PhpParser\ErrorHandler; use PhpParser\Lexer; use PhpParser\Lexer\TokenEmulator\AsymmetricVisibilityTokenEmulator; use PhpParser\Lexer\TokenEmulator\AttributeEmulator; use PhpParser\Lexer\TokenEmulator\EnumTokenEmulator; use PhpParser\Lexer\TokenEmulator\ExplicitOctalEmulator; use PhpParser\Lexer\TokenEmulator\MatchTokenEmulator; use PhpParser\Lexer\TokenEmulator\NullsafeTokenEmulator; use PhpParser\Lexer\TokenEmulator\PipeOperatorEmulator; use PhpParser\Lexer\TokenEmulator\PropertyTokenEmulator; use PhpParser\Lexer\TokenEmulator\ReadonlyFunctionTokenEmulator; use PhpParser\Lexer\TokenEmulator\ReadonlyTokenEmulator; use PhpParser\Lexer\TokenEmulator\ReverseEmulator; use PhpParser\Lexer\TokenEmulator\TokenEmulator; use PhpParser\Lexer\TokenEmulator\VoidCastEmulator; use PhpParser\PhpVersion; use PhpParser\Token; class Emulative extends Lexer { /** @var array{int, string, string}[] Patches used to reverse changes introduced in the code */ private array $patches = []; /** @var list<TokenEmulator> */ private array $emulators = []; private PhpVersion $targetPhpVersion; private PhpVersion $hostPhpVersion; /** * @param PhpVersion|null $phpVersion PHP version to emulate. Defaults to newest supported. */ public function __construct(?PhpVersion $phpVersion = null) { $this->targetPhpVersion = $phpVersion ?? PhpVersion::getNewestSupported(); $this->hostPhpVersion = PhpVersion::getHostVersion(); $emulators = [ new MatchTokenEmulator(), new NullsafeTokenEmulator(), new AttributeEmulator(), new EnumTokenEmulator(), new ReadonlyTokenEmulator(), new ExplicitOctalEmulator(), new ReadonlyFunctionTokenEmulator(), new PropertyTokenEmulator(), new AsymmetricVisibilityTokenEmulator(), new PipeOperatorEmulator(), new VoidCastEmulator(), ]; // Collect emulators that are relevant for the PHP version we're running // and the PHP version we're targeting for emulation. foreach ($emulators as $emulator) { $emulatorPhpVersion = $emulator->getPhpVersion(); if ($this->isForwardEmulationNeeded($emulatorPhpVersion)) { $this->emulators[] = $emulator; } elseif ($this->isReverseEmulationNeeded($emulatorPhpVersion)) { $this->emulators[] = new ReverseEmulator($emulator); } } } public function tokenize(string $code, ?ErrorHandler $errorHandler = null): array { $emulators = array_filter($this->emulators, function ($emulator) use ($code) { return $emulator->isEmulationNeeded($code); }); if (empty($emulators)) { // Nothing to emulate, yay return parent::tokenize($code, $errorHandler); } if ($errorHandler === null) { $errorHandler = new ErrorHandler\Throwing(); } $this->patches = []; foreach ($emulators as $emulator) { $code = $emulator->preprocessCode($code, $this->patches); } $collector = new ErrorHandler\Collecting(); $tokens = parent::tokenize($code, $collector); $this->sortPatches(); $tokens = $this->fixupTokens($tokens); $errors = $collector->getErrors(); if (!empty($errors)) { $this->fixupErrors($errors); foreach ($errors as $error) { $errorHandler->handleError($error); } } foreach ($emulators as $emulator) { $tokens = $emulator->emulate($code, $tokens); } return $tokens; } private function isForwardEmulationNeeded(PhpVersion $emulatorPhpVersion): bool { return $this->hostPhpVersion->older($emulatorPhpVersion) && $this->targetPhpVersion->newerOrEqual($emulatorPhpVersion); } private function isReverseEmulationNeeded(PhpVersion $emulatorPhpVersion): bool { return $this->hostPhpVersion->newerOrEqual($emulatorPhpVersion) && $this->targetPhpVersion->older($emulatorPhpVersion); } private function sortPatches(): void { // Patches may be contributed by different emulators. // Make sure they are sorted by increasing patch position. usort($this->patches, function ($p1, $p2) { return $p1[0] <=> $p2[0]; }); } /** * @param list<Token> $tokens * @return list<Token> */ private function fixupTokens(array $tokens): array { if (\count($this->patches) === 0) { return $tokens; } // Load first patch $patchIdx = 0; list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx]; // We use a manual loop over the tokens, because we modify the array on the fly $posDelta = 0; $lineDelta = 0; for ($i = 0, $c = \count($tokens); $i < $c; $i++) { $token = $tokens[$i]; $pos = $token->pos; $token->pos += $posDelta; $token->line += $lineDelta; $localPosDelta = 0; $len = \strlen($token->text); while ($patchPos >= $pos && $patchPos < $pos + $len) { $patchTextLen = \strlen($patchText); if ($patchType === 'remove') { if ($patchPos === $pos && $patchTextLen === $len) { // Remove token entirely array_splice($tokens, $i, 1, []); $i--; $c--; } else { // Remove from token string $token->text = substr_replace( $token->text, '', $patchPos - $pos + $localPosDelta, $patchTextLen ); $localPosDelta -= $patchTextLen; } $lineDelta -= \substr_count($patchText, "\n"); } elseif ($patchType === 'add') { // Insert into the token string $token->text = substr_replace( $token->text, $patchText, $patchPos - $pos + $localPosDelta, 0 ); $localPosDelta += $patchTextLen; $lineDelta += \substr_count($patchText, "\n"); } elseif ($patchType === 'replace') { // Replace inside the token string $token->text = substr_replace( $token->text, $patchText, $patchPos - $pos + $localPosDelta, $patchTextLen ); } else { assert(false); } // Fetch the next patch $patchIdx++; if ($patchIdx >= \count($this->patches)) { // No more patches. However, we still need to adjust position. $patchPos = \PHP_INT_MAX; break; } list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx]; } $posDelta += $localPosDelta; } return $tokens; } /** * Fixup line and position information in errors. * * @param Error[] $errors */ private function fixupErrors(array $errors): void { foreach ($errors as $error) { $attrs = $error->getAttributes(); $posDelta = 0; $lineDelta = 0; foreach ($this->patches as $patch) { list($patchPos, $patchType, $patchText) = $patch; if ($patchPos >= $attrs['startFilePos']) { // No longer relevant break; } if ($patchType === 'add') { $posDelta += strlen($patchText); $lineDelta += substr_count($patchText, "\n"); } elseif ($patchType === 'remove') { $posDelta -= strlen($patchText); $lineDelta -= substr_count($patchText, "\n"); } } $attrs['startFilePos'] += $posDelta; $attrs['endFilePos'] += $posDelta; $attrs['startLine'] += $lineDelta; $attrs['endLine'] += $lineDelta; $error->setAttributes($attrs); } } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php
lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php
<?php declare(strict_types=1); namespace PhpParser\Lexer\TokenEmulator; use PhpParser\PhpVersion; final class EnumTokenEmulator extends KeywordEmulator { public function getPhpVersion(): PhpVersion { return PhpVersion::fromComponents(8, 1); } public function getKeywordString(): string { return 'enum'; } public function getKeywordToken(): int { return \T_ENUM; } protected function isKeywordContext(array $tokens, int $pos): bool { return parent::isKeywordContext($tokens, $pos) && isset($tokens[$pos + 2]) && $tokens[$pos + 1]->id === \T_WHITESPACE && $tokens[$pos + 2]->id === \T_STRING; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Lexer/TokenEmulator/KeywordEmulator.php
lib/PhpParser/Lexer/TokenEmulator/KeywordEmulator.php
<?php declare(strict_types=1); namespace PhpParser\Lexer\TokenEmulator; use PhpParser\Token; abstract class KeywordEmulator extends TokenEmulator { abstract public function getKeywordString(): string; abstract public function getKeywordToken(): int; public function isEmulationNeeded(string $code): bool { return strpos(strtolower($code), $this->getKeywordString()) !== false; } /** @param Token[] $tokens */ protected function isKeywordContext(array $tokens, int $pos): bool { $prevToken = $this->getPreviousNonSpaceToken($tokens, $pos); if ($prevToken === null) { return false; } return $prevToken->id !== \T_OBJECT_OPERATOR && $prevToken->id !== \T_NULLSAFE_OBJECT_OPERATOR; } public function emulate(string $code, array $tokens): array { $keywordString = $this->getKeywordString(); foreach ($tokens as $i => $token) { if ($token->id === T_STRING && strtolower($token->text) === $keywordString && $this->isKeywordContext($tokens, $i)) { $token->id = $this->getKeywordToken(); } } return $tokens; } /** @param Token[] $tokens */ private function getPreviousNonSpaceToken(array $tokens, int $start): ?Token { for ($i = $start - 1; $i >= 0; --$i) { if ($tokens[$i]->id === T_WHITESPACE) { continue; } return $tokens[$i]; } return null; } public function reverseEmulate(string $code, array $tokens): array { $keywordToken = $this->getKeywordToken(); foreach ($tokens as $token) { if ($token->id === $keywordToken) { $token->id = \T_STRING; } } return $tokens; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php
lib/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php
<?php declare(strict_types=1); namespace PhpParser\Lexer\TokenEmulator; use PhpParser\PhpVersion; use PhpParser\Token; final class NullsafeTokenEmulator extends TokenEmulator { public function getPhpVersion(): PhpVersion { return PhpVersion::fromComponents(8, 0); } public function isEmulationNeeded(string $code): bool { return strpos($code, '?->') !== false; } public function emulate(string $code, array $tokens): array { // We need to manually iterate and manage a count because we'll change // the tokens array on the way for ($i = 0, $c = count($tokens); $i < $c; ++$i) { $token = $tokens[$i]; if ($token->text === '?' && isset($tokens[$i + 1]) && $tokens[$i + 1]->id === \T_OBJECT_OPERATOR) { array_splice($tokens, $i, 2, [ new Token(\T_NULLSAFE_OBJECT_OPERATOR, '?->', $token->line, $token->pos), ]); $c--; continue; } // Handle ?-> inside encapsed string. if ($token->id === \T_ENCAPSED_AND_WHITESPACE && isset($tokens[$i - 1]) && $tokens[$i - 1]->id === \T_VARIABLE && preg_match('/^\?->([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)/', $token->text, $matches) ) { $replacement = [ new Token(\T_NULLSAFE_OBJECT_OPERATOR, '?->', $token->line, $token->pos), new Token(\T_STRING, $matches[1], $token->line, $token->pos + 3), ]; $matchLen = \strlen($matches[0]); if ($matchLen !== \strlen($token->text)) { $replacement[] = new Token( \T_ENCAPSED_AND_WHITESPACE, \substr($token->text, $matchLen), $token->line, $token->pos + $matchLen ); } array_splice($tokens, $i, 1, $replacement); $c += \count($replacement) - 1; continue; } } return $tokens; } public function reverseEmulate(string $code, array $tokens): array { // ?-> was not valid code previously, don't bother. return $tokens; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Lexer/TokenEmulator/PropertyTokenEmulator.php
lib/PhpParser/Lexer/TokenEmulator/PropertyTokenEmulator.php
<?php declare(strict_types=1); namespace PhpParser\Lexer\TokenEmulator; use PhpParser\PhpVersion; final class PropertyTokenEmulator extends KeywordEmulator { public function getPhpVersion(): PhpVersion { return PhpVersion::fromComponents(8, 4); } public function getKeywordString(): string { return '__property__'; } public function getKeywordToken(): int { return \T_PROPERTY_C; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Lexer/TokenEmulator/VoidCastEmulator.php
lib/PhpParser/Lexer/TokenEmulator/VoidCastEmulator.php
<?php declare(strict_types=1); namespace PhpParser\Lexer\TokenEmulator; use PhpParser\PhpVersion; use PhpParser\Token; class VoidCastEmulator extends TokenEmulator { public function getPhpVersion(): PhpVersion { return PhpVersion::fromComponents(8, 5); } public function isEmulationNeeded(string $code): bool { return (bool)\preg_match('/\([ \t]*void[ \t]*\)/i', $code); } public function emulate(string $code, array $tokens): array { for ($i = 0, $c = count($tokens); $i < $c; ++$i) { $token = $tokens[$i]; if ($token->text !== '(') { continue; } $numTokens = 1; $text = '('; $j = $i + 1; if ($j < $c && $tokens[$j]->id === \T_WHITESPACE && preg_match('/[ \t]+/', $tokens[$j]->text)) { $text .= $tokens[$j]->text; $numTokens++; $j++; } if ($j >= $c || $tokens[$j]->id !== \T_STRING || \strtolower($tokens[$j]->text) !== 'void') { continue; } $text .= $tokens[$j]->text; $numTokens++; $k = $j + 1; if ($k < $c && $tokens[$k]->id === \T_WHITESPACE && preg_match('/[ \t]+/', $tokens[$k]->text)) { $text .= $tokens[$k]->text; $numTokens++; $k++; } if ($k >= $c || $tokens[$k]->text !== ')') { continue; } $text .= ')'; $numTokens++; array_splice($tokens, $i, $numTokens, [ new Token(\T_VOID_CAST, $text, $token->line, $token->pos), ]); $c -= $numTokens - 1; } return $tokens; } public function reverseEmulate(string $code, array $tokens): array { for ($i = 0, $c = count($tokens); $i < $c; ++$i) { $token = $tokens[$i]; if ($token->id !== \T_VOID_CAST) { continue; } if (!preg_match('/^\(([ \t]*)(void)([ \t]*)\)$/i', $token->text, $match)) { throw new \LogicException('Unexpected T_VOID_CAST contents'); } $newTokens = []; $pos = $token->pos; $newTokens[] = new Token(\ord('('), '(', $token->line, $pos); $pos++; if ($match[1] !== '') { $newTokens[] = new Token(\T_WHITESPACE, $match[1], $token->line, $pos); $pos += \strlen($match[1]); } $newTokens[] = new Token(\T_STRING, $match[2], $token->line, $pos); $pos += \strlen($match[2]); if ($match[3] !== '') { $newTokens[] = new Token(\T_WHITESPACE, $match[3], $token->line, $pos); $pos += \strlen($match[3]); } $newTokens[] = new Token(\ord(')'), ')', $token->line, $pos); array_splice($tokens, $i, 1, $newTokens); $i += \count($newTokens) - 1; $c += \count($newTokens) - 1; } return $tokens; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Lexer/TokenEmulator/ExplicitOctalEmulator.php
lib/PhpParser/Lexer/TokenEmulator/ExplicitOctalEmulator.php
<?php declare(strict_types=1); namespace PhpParser\Lexer\TokenEmulator; use PhpParser\PhpVersion; use PhpParser\Token; class ExplicitOctalEmulator extends TokenEmulator { public function getPhpVersion(): PhpVersion { return PhpVersion::fromComponents(8, 1); } public function isEmulationNeeded(string $code): bool { return strpos($code, '0o') !== false || strpos($code, '0O') !== false; } public function emulate(string $code, array $tokens): array { for ($i = 0, $c = count($tokens); $i < $c; ++$i) { $token = $tokens[$i]; if ($token->id == \T_LNUMBER && $token->text === '0' && isset($tokens[$i + 1]) && $tokens[$i + 1]->id == \T_STRING && preg_match('/[oO][0-7]+(?:_[0-7]+)*/', $tokens[$i + 1]->text) ) { $tokenKind = $this->resolveIntegerOrFloatToken($tokens[$i + 1]->text); array_splice($tokens, $i, 2, [ new Token($tokenKind, '0' . $tokens[$i + 1]->text, $token->line, $token->pos), ]); $c--; } } return $tokens; } private function resolveIntegerOrFloatToken(string $str): int { $str = substr($str, 1); $str = str_replace('_', '', $str); $num = octdec($str); return is_float($num) ? \T_DNUMBER : \T_LNUMBER; } public function reverseEmulate(string $code, array $tokens): array { // Explicit octals were not legal code previously, don't bother. return $tokens; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php
lib/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php
<?php declare(strict_types=1); namespace PhpParser\Lexer\TokenEmulator; use PhpParser\PhpVersion; final class MatchTokenEmulator extends KeywordEmulator { public function getPhpVersion(): PhpVersion { return PhpVersion::fromComponents(8, 0); } public function getKeywordString(): string { return 'match'; } public function getKeywordToken(): int { return \T_MATCH; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Lexer/TokenEmulator/ReadonlyTokenEmulator.php
lib/PhpParser/Lexer/TokenEmulator/ReadonlyTokenEmulator.php
<?php declare(strict_types=1); namespace PhpParser\Lexer\TokenEmulator; use PhpParser\PhpVersion; final class ReadonlyTokenEmulator extends KeywordEmulator { public function getPhpVersion(): PhpVersion { return PhpVersion::fromComponents(8, 1); } public function getKeywordString(): string { return 'readonly'; } public function getKeywordToken(): int { return \T_READONLY; } protected function isKeywordContext(array $tokens, int $pos): bool { if (!parent::isKeywordContext($tokens, $pos)) { return false; } // Support "function readonly(" return !(isset($tokens[$pos + 1]) && ($tokens[$pos + 1]->text === '(' || ($tokens[$pos + 1]->id === \T_WHITESPACE && isset($tokens[$pos + 2]) && $tokens[$pos + 2]->text === '('))); } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Lexer/TokenEmulator/ReverseEmulator.php
lib/PhpParser/Lexer/TokenEmulator/ReverseEmulator.php
<?php declare(strict_types=1); namespace PhpParser\Lexer\TokenEmulator; use PhpParser\PhpVersion; /** * Reverses emulation direction of the inner emulator. */ final class ReverseEmulator extends TokenEmulator { /** @var TokenEmulator Inner emulator */ private TokenEmulator $emulator; public function __construct(TokenEmulator $emulator) { $this->emulator = $emulator; } public function getPhpVersion(): PhpVersion { return $this->emulator->getPhpVersion(); } public function isEmulationNeeded(string $code): bool { return $this->emulator->isEmulationNeeded($code); } public function emulate(string $code, array $tokens): array { return $this->emulator->reverseEmulate($code, $tokens); } public function reverseEmulate(string $code, array $tokens): array { return $this->emulator->emulate($code, $tokens); } public function preprocessCode(string $code, array &$patches): string { return $code; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Lexer/TokenEmulator/TokenEmulator.php
lib/PhpParser/Lexer/TokenEmulator/TokenEmulator.php
<?php declare(strict_types=1); namespace PhpParser\Lexer\TokenEmulator; use PhpParser\PhpVersion; use PhpParser\Token; /** @internal */ abstract class TokenEmulator { abstract public function getPhpVersion(): PhpVersion; abstract public function isEmulationNeeded(string $code): bool; /** * @param Token[] $tokens Original tokens * @return Token[] Modified Tokens */ abstract public function emulate(string $code, array $tokens): array; /** * @param Token[] $tokens Original tokens * @return Token[] Modified Tokens */ abstract public function reverseEmulate(string $code, array $tokens): array; /** @param array{int, string, string}[] $patches */ public function preprocessCode(string $code, array &$patches): string { return $code; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Lexer/TokenEmulator/PipeOperatorEmulator.php
lib/PhpParser/Lexer/TokenEmulator/PipeOperatorEmulator.php
<?php declare(strict_types=1); namespace PhpParser\Lexer\TokenEmulator; use PhpParser\Lexer\TokenEmulator\TokenEmulator; use PhpParser\PhpVersion; use PhpParser\Token; class PipeOperatorEmulator extends TokenEmulator { public function getPhpVersion(): PhpVersion { return PhpVersion::fromComponents(8, 5); } public function isEmulationNeeded(string $code): bool { return \strpos($code, '|>') !== false; } public function emulate(string $code, array $tokens): array { for ($i = 0, $c = count($tokens); $i < $c; ++$i) { $token = $tokens[$i]; if ($token->text === '|' && isset($tokens[$i + 1]) && $tokens[$i + 1]->text === '>') { array_splice($tokens, $i, 2, [ new Token(\T_PIPE, '|>', $token->line, $token->pos), ]); $c--; } } return $tokens; } public function reverseEmulate(string $code, array $tokens): array { for ($i = 0, $c = count($tokens); $i < $c; ++$i) { $token = $tokens[$i]; if ($token->id === \T_PIPE) { array_splice($tokens, $i, 1, [ new Token(\ord('|'), '|', $token->line, $token->pos), new Token(\ord('>'), '>', $token->line, $token->pos + 1), ]); $i++; $c++; } } return $tokens; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php
lib/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php
<?php declare(strict_types=1); namespace PhpParser\Lexer\TokenEmulator; use PhpParser\PhpVersion; use PhpParser\Token; final class AttributeEmulator extends TokenEmulator { public function getPhpVersion(): PhpVersion { return PhpVersion::fromComponents(8, 0); } public function isEmulationNeeded(string $code): bool { return strpos($code, '#[') !== false; } public function emulate(string $code, array $tokens): array { // We need to manually iterate and manage a count because we'll change // the tokens array on the way. for ($i = 0, $c = count($tokens); $i < $c; ++$i) { $token = $tokens[$i]; if ($token->text === '#' && isset($tokens[$i + 1]) && $tokens[$i + 1]->text === '[') { array_splice($tokens, $i, 2, [ new Token(\T_ATTRIBUTE, '#[', $token->line, $token->pos), ]); $c--; continue; } } return $tokens; } public function reverseEmulate(string $code, array $tokens): array { // TODO return $tokens; } public function preprocessCode(string $code, array &$patches): string { $pos = 0; while (false !== $pos = strpos($code, '#[', $pos)) { // Replace #[ with %[ $code[$pos] = '%'; $patches[] = [$pos, 'replace', '#']; $pos += 2; } return $code; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Lexer/TokenEmulator/ReadonlyFunctionTokenEmulator.php
lib/PhpParser/Lexer/TokenEmulator/ReadonlyFunctionTokenEmulator.php
<?php declare(strict_types=1); namespace PhpParser\Lexer\TokenEmulator; use PhpParser\PhpVersion; /* * In PHP 8.1, "readonly(" was special cased in the lexer in order to support functions with * name readonly. In PHP 8.2, this may conflict with readonly properties having a DNF type. For * this reason, PHP 8.2 instead treats this as T_READONLY and then handles it specially in the * parser. This emulator only exists to handle this special case, which is skipped by the * PHP 8.1 ReadonlyTokenEmulator. */ class ReadonlyFunctionTokenEmulator extends KeywordEmulator { public function getKeywordString(): string { return 'readonly'; } public function getKeywordToken(): int { return \T_READONLY; } public function getPhpVersion(): PhpVersion { return PhpVersion::fromComponents(8, 2); } public function reverseEmulate(string $code, array $tokens): array { // Don't bother return $tokens; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Lexer/TokenEmulator/AsymmetricVisibilityTokenEmulator.php
lib/PhpParser/Lexer/TokenEmulator/AsymmetricVisibilityTokenEmulator.php
<?php declare(strict_types=1); namespace PhpParser\Lexer\TokenEmulator; use PhpParser\PhpVersion; use PhpParser\Token; final class AsymmetricVisibilityTokenEmulator extends TokenEmulator { public function getPhpVersion(): PhpVersion { return PhpVersion::fromComponents(8, 4); } public function isEmulationNeeded(string $code): bool { $code = strtolower($code); return strpos($code, 'public(set)') !== false || strpos($code, 'protected(set)') !== false || strpos($code, 'private(set)') !== false; } public function emulate(string $code, array $tokens): array { $map = [ \T_PUBLIC => \T_PUBLIC_SET, \T_PROTECTED => \T_PROTECTED_SET, \T_PRIVATE => \T_PRIVATE_SET, ]; for ($i = 0, $c = count($tokens); $i < $c; ++$i) { $token = $tokens[$i]; if (isset($map[$token->id]) && $i + 3 < $c && $tokens[$i + 1]->text === '(' && $tokens[$i + 2]->id === \T_STRING && \strtolower($tokens[$i + 2]->text) === 'set' && $tokens[$i + 3]->text === ')' && $this->isKeywordContext($tokens, $i) ) { array_splice($tokens, $i, 4, [ new Token( $map[$token->id], $token->text . '(' . $tokens[$i + 2]->text . ')', $token->line, $token->pos), ]); $c -= 3; } } return $tokens; } public function reverseEmulate(string $code, array $tokens): array { $reverseMap = [ \T_PUBLIC_SET => \T_PUBLIC, \T_PROTECTED_SET => \T_PROTECTED, \T_PRIVATE_SET => \T_PRIVATE, ]; for ($i = 0, $c = count($tokens); $i < $c; ++$i) { $token = $tokens[$i]; if (isset($reverseMap[$token->id]) && \preg_match('/(public|protected|private)\((set)\)/i', $token->text, $matches) ) { [, $modifier, $set] = $matches; $modifierLen = \strlen($modifier); array_splice($tokens, $i, 1, [ new Token($reverseMap[$token->id], $modifier, $token->line, $token->pos), new Token(\ord('('), '(', $token->line, $token->pos + $modifierLen), new Token(\T_STRING, $set, $token->line, $token->pos + $modifierLen + 1), new Token(\ord(')'), ')', $token->line, $token->pos + $modifierLen + 4), ]); $i += 3; $c += 3; } } return $tokens; } /** @param Token[] $tokens */ protected function isKeywordContext(array $tokens, int $pos): bool { $prevToken = $this->getPreviousNonSpaceToken($tokens, $pos); if ($prevToken === null) { return false; } return $prevToken->id !== \T_OBJECT_OPERATOR && $prevToken->id !== \T_NULLSAFE_OBJECT_OPERATOR; } /** @param Token[] $tokens */ private function getPreviousNonSpaceToken(array $tokens, int $start): ?Token { for ($i = $start - 1; $i >= 0; --$i) { if ($tokens[$i]->id === T_WHITESPACE) { continue; } return $tokens[$i]; } return null; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/NodeVisitor/NodeConnectingVisitor.php
lib/PhpParser/NodeVisitor/NodeConnectingVisitor.php
<?php declare(strict_types=1); namespace PhpParser\NodeVisitor; use PhpParser\Node; use PhpParser\NodeVisitorAbstract; /** * Visitor that connects a child node to its parent node * as well as its sibling nodes. * * With <code>$weakReferences=false</code> on the child node, the parent node can be accessed through * <code>$node->getAttribute('parent')</code>, the previous * node can be accessed through <code>$node->getAttribute('previous')</code>, * and the next node can be accessed through <code>$node->getAttribute('next')</code>. * * With <code>$weakReferences=true</code> attribute names are prefixed by "weak_", e.g. "weak_parent". */ final class NodeConnectingVisitor extends NodeVisitorAbstract { /** * @var Node[] */ private array $stack = []; /** * @var ?Node */ private $previous; private bool $weakReferences; public function __construct(bool $weakReferences = false) { $this->weakReferences = $weakReferences; } public function beforeTraverse(array $nodes) { $this->stack = []; $this->previous = null; } public function enterNode(Node $node) { if (!empty($this->stack)) { $parent = $this->stack[count($this->stack) - 1]; if ($this->weakReferences) { $node->setAttribute('weak_parent', \WeakReference::create($parent)); } else { $node->setAttribute('parent', $parent); } } if ($this->previous !== null) { if ( $this->weakReferences ) { if ($this->previous->getAttribute('weak_parent') === $node->getAttribute('weak_parent')) { $node->setAttribute('weak_previous', \WeakReference::create($this->previous)); $this->previous->setAttribute('weak_next', \WeakReference::create($node)); } } elseif ($this->previous->getAttribute('parent') === $node->getAttribute('parent')) { $node->setAttribute('previous', $this->previous); $this->previous->setAttribute('next', $node); } } $this->stack[] = $node; } public function leaveNode(Node $node) { $this->previous = $node; array_pop($this->stack); } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/NodeVisitor/NameResolver.php
lib/PhpParser/NodeVisitor/NameResolver.php
<?php declare(strict_types=1); namespace PhpParser\NodeVisitor; use PhpParser\ErrorHandler; use PhpParser\NameContext; use PhpParser\Node; use PhpParser\Node\Expr; use PhpParser\Node\Name; use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\Stmt; use PhpParser\NodeVisitorAbstract; class NameResolver extends NodeVisitorAbstract { /** @var NameContext Naming context */ protected NameContext $nameContext; /** @var bool Whether to preserve original names */ protected bool $preserveOriginalNames; /** @var bool Whether to replace resolved nodes in place, or to add resolvedNode attributes */ protected bool $replaceNodes; /** * Constructs a name resolution visitor. * * Options: * * preserveOriginalNames (default false): An "originalName" attribute will be added to * all name nodes that underwent resolution. * * replaceNodes (default true): Resolved names are replaced in-place. Otherwise, a * resolvedName attribute is added. (Names that cannot be statically resolved receive a * namespacedName attribute, as usual.) * * @param ErrorHandler|null $errorHandler Error handler * @param array{preserveOriginalNames?: bool, replaceNodes?: bool} $options Options */ public function __construct(?ErrorHandler $errorHandler = null, array $options = []) { $this->nameContext = new NameContext($errorHandler ?? new ErrorHandler\Throwing()); $this->preserveOriginalNames = $options['preserveOriginalNames'] ?? false; $this->replaceNodes = $options['replaceNodes'] ?? true; } /** * Get name resolution context. */ public function getNameContext(): NameContext { return $this->nameContext; } public function beforeTraverse(array $nodes): ?array { $this->nameContext->startNamespace(); return null; } public function enterNode(Node $node) { if ($node instanceof Stmt\Namespace_) { $this->nameContext->startNamespace($node->name); } elseif ($node instanceof Stmt\Use_) { foreach ($node->uses as $use) { $this->addAlias($use, $node->type, null); } } elseif ($node instanceof Stmt\GroupUse) { foreach ($node->uses as $use) { $this->addAlias($use, $node->type, $node->prefix); } } elseif ($node instanceof Stmt\Class_) { if (null !== $node->extends) { $node->extends = $this->resolveClassName($node->extends); } foreach ($node->implements as &$interface) { $interface = $this->resolveClassName($interface); } $this->resolveAttrGroups($node); if (null !== $node->name) { $this->addNamespacedName($node); } else { $node->namespacedName = null; } } elseif ($node instanceof Stmt\Interface_) { foreach ($node->extends as &$interface) { $interface = $this->resolveClassName($interface); } $this->resolveAttrGroups($node); $this->addNamespacedName($node); } elseif ($node instanceof Stmt\Enum_) { foreach ($node->implements as &$interface) { $interface = $this->resolveClassName($interface); } $this->resolveAttrGroups($node); $this->addNamespacedName($node); } elseif ($node instanceof Stmt\Trait_) { $this->resolveAttrGroups($node); $this->addNamespacedName($node); } elseif ($node instanceof Stmt\Function_) { $this->resolveSignature($node); $this->resolveAttrGroups($node); $this->addNamespacedName($node); } elseif ($node instanceof Stmt\ClassMethod || $node instanceof Expr\Closure || $node instanceof Expr\ArrowFunction ) { $this->resolveSignature($node); $this->resolveAttrGroups($node); } elseif ($node instanceof Stmt\Property) { if (null !== $node->type) { $node->type = $this->resolveType($node->type); } $this->resolveAttrGroups($node); } elseif ($node instanceof Node\PropertyHook) { foreach ($node->params as $param) { $param->type = $this->resolveType($param->type); $this->resolveAttrGroups($param); } $this->resolveAttrGroups($node); } elseif ($node instanceof Stmt\Const_) { foreach ($node->consts as $const) { $this->addNamespacedName($const); } $this->resolveAttrGroups($node); } elseif ($node instanceof Stmt\ClassConst) { if (null !== $node->type) { $node->type = $this->resolveType($node->type); } $this->resolveAttrGroups($node); } elseif ($node instanceof Stmt\EnumCase) { $this->resolveAttrGroups($node); } elseif ($node instanceof Expr\StaticCall || $node instanceof Expr\StaticPropertyFetch || $node instanceof Expr\ClassConstFetch || $node instanceof Expr\New_ || $node instanceof Expr\Instanceof_ ) { if ($node->class instanceof Name) { $node->class = $this->resolveClassName($node->class); } } elseif ($node instanceof Stmt\Catch_) { foreach ($node->types as &$type) { $type = $this->resolveClassName($type); } } elseif ($node instanceof Expr\FuncCall) { if ($node->name instanceof Name) { $node->name = $this->resolveName($node->name, Stmt\Use_::TYPE_FUNCTION); } } elseif ($node instanceof Expr\ConstFetch) { $node->name = $this->resolveName($node->name, Stmt\Use_::TYPE_CONSTANT); } elseif ($node instanceof Stmt\TraitUse) { foreach ($node->traits as &$trait) { $trait = $this->resolveClassName($trait); } foreach ($node->adaptations as $adaptation) { if (null !== $adaptation->trait) { $adaptation->trait = $this->resolveClassName($adaptation->trait); } if ($adaptation instanceof Stmt\TraitUseAdaptation\Precedence) { foreach ($adaptation->insteadof as &$insteadof) { $insteadof = $this->resolveClassName($insteadof); } } } } return null; } /** @param Stmt\Use_::TYPE_* $type */ private function addAlias(Node\UseItem $use, int $type, ?Name $prefix = null): void { // Add prefix for group uses $name = $prefix ? Name::concat($prefix, $use->name) : $use->name; // Type is determined either by individual element or whole use declaration $type |= $use->type; $this->nameContext->addAlias( $name, (string) $use->getAlias(), $type, $use->getAttributes() ); } /** @param Stmt\Function_|Stmt\ClassMethod|Expr\Closure|Expr\ArrowFunction $node */ private function resolveSignature($node): void { foreach ($node->params as $param) { $param->type = $this->resolveType($param->type); $this->resolveAttrGroups($param); } $node->returnType = $this->resolveType($node->returnType); } /** * @template T of Node\Identifier|Name|Node\ComplexType|null * @param T $node * @return T */ private function resolveType(?Node $node): ?Node { if ($node instanceof Name) { return $this->resolveClassName($node); } if ($node instanceof Node\NullableType) { $node->type = $this->resolveType($node->type); return $node; } if ($node instanceof Node\UnionType || $node instanceof Node\IntersectionType) { foreach ($node->types as &$type) { $type = $this->resolveType($type); } return $node; } return $node; } /** * Resolve name, according to name resolver options. * * @param Name $name Function or constant name to resolve * @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_* * * @return Name Resolved name, or original name with attribute */ protected function resolveName(Name $name, int $type): Name { if (!$this->replaceNodes) { $resolvedName = $this->nameContext->getResolvedName($name, $type); if (null !== $resolvedName) { $name->setAttribute('resolvedName', $resolvedName); } else { $name->setAttribute('namespacedName', FullyQualified::concat( $this->nameContext->getNamespace(), $name, $name->getAttributes())); } return $name; } if ($this->preserveOriginalNames) { // Save the original name $originalName = $name; $name = clone $originalName; $name->setAttribute('originalName', $originalName); } $resolvedName = $this->nameContext->getResolvedName($name, $type); if (null !== $resolvedName) { return $resolvedName; } // unqualified names inside a namespace cannot be resolved at compile-time // add the namespaced version of the name as an attribute $name->setAttribute('namespacedName', FullyQualified::concat( $this->nameContext->getNamespace(), $name, $name->getAttributes())); return $name; } protected function resolveClassName(Name $name): Name { return $this->resolveName($name, Stmt\Use_::TYPE_NORMAL); } protected function addNamespacedName(Node $node): void { $node->namespacedName = Name::concat( $this->nameContext->getNamespace(), (string) $node->name); } protected function resolveAttrGroups(Node $node): void { foreach ($node->attrGroups as $attrGroup) { foreach ($attrGroup->attrs as $attr) { $attr->name = $this->resolveClassName($attr->name); } } } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/NodeVisitor/CloningVisitor.php
lib/PhpParser/NodeVisitor/CloningVisitor.php
<?php declare(strict_types=1); namespace PhpParser\NodeVisitor; use PhpParser\Node; use PhpParser\NodeVisitorAbstract; /** * Visitor cloning all nodes and linking to the original nodes using an attribute. * * This visitor is required to perform format-preserving pretty prints. */ class CloningVisitor extends NodeVisitorAbstract { public function enterNode(Node $origNode) { $node = clone $origNode; $node->setAttribute('origNode', $origNode); return $node; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php
lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php
<?php declare(strict_types=1); namespace PhpParser\NodeVisitor; use PhpParser\Node; use PhpParser\NodeVisitorAbstract; use function array_pop; use function count; /** * Visitor that connects a child node to its parent node. * * With <code>$weakReferences=false</code> on the child node, the parent node can be accessed through * <code>$node->getAttribute('parent')</code>. * * With <code>$weakReferences=true</code> the attribute name is "weak_parent" instead. */ final class ParentConnectingVisitor extends NodeVisitorAbstract { /** * @var Node[] */ private array $stack = []; private bool $weakReferences; public function __construct(bool $weakReferences = false) { $this->weakReferences = $weakReferences; } public function beforeTraverse(array $nodes) { $this->stack = []; } public function enterNode(Node $node) { if (!empty($this->stack)) { $parent = $this->stack[count($this->stack) - 1]; if ($this->weakReferences) { $node->setAttribute('weak_parent', \WeakReference::create($parent)); } else { $node->setAttribute('parent', $parent); } } $this->stack[] = $node; } public function leaveNode(Node $node) { array_pop($this->stack); } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/NodeVisitor/CommentAnnotatingVisitor.php
lib/PhpParser/NodeVisitor/CommentAnnotatingVisitor.php
<?php declare(strict_types=1); namespace PhpParser\NodeVisitor; use PhpParser\Comment; use PhpParser\Node; use PhpParser\NodeVisitorAbstract; use PhpParser\Token; class CommentAnnotatingVisitor extends NodeVisitorAbstract { /** @var int Last seen token start position */ private int $pos = 0; /** @var Token[] Token array */ private array $tokens; /** @var list<int> Token positions of comments */ private array $commentPositions = []; /** * Create a comment annotation visitor. * * @param Token[] $tokens Token array */ public function __construct(array $tokens) { $this->tokens = $tokens; // Collect positions of comments. We use this to avoid traversing parts of the AST where // there are no comments. foreach ($tokens as $i => $token) { if ($token->id === \T_COMMENT || $token->id === \T_DOC_COMMENT) { $this->commentPositions[] = $i; } } } public function enterNode(Node $node) { $nextCommentPos = current($this->commentPositions); if ($nextCommentPos === false) { // No more comments. return self::STOP_TRAVERSAL; } $oldPos = $this->pos; $this->pos = $pos = $node->getStartTokenPos(); if ($nextCommentPos > $oldPos && $nextCommentPos < $pos) { $comments = []; while (--$pos >= $oldPos) { $token = $this->tokens[$pos]; if ($token->id === \T_DOC_COMMENT) { $comments[] = new Comment\Doc( $token->text, $token->line, $token->pos, $pos, $token->getEndLine(), $token->getEndPos() - 1, $pos); continue; } if ($token->id === \T_COMMENT) { $comments[] = new Comment( $token->text, $token->line, $token->pos, $pos, $token->getEndLine(), $token->getEndPos() - 1, $pos); continue; } if ($token->id !== \T_WHITESPACE) { break; } } if (!empty($comments)) { $node->setAttribute('comments', array_reverse($comments)); } do { $nextCommentPos = next($this->commentPositions); } while ($nextCommentPos !== false && $nextCommentPos < $this->pos); } $endPos = $node->getEndTokenPos(); if ($nextCommentPos > $endPos) { // Skip children if there are no comments located inside this node. $this->pos = $endPos; return self::DONT_TRAVERSE_CHILDREN; } return null; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/NodeVisitor/FirstFindingVisitor.php
lib/PhpParser/NodeVisitor/FirstFindingVisitor.php
<?php declare(strict_types=1); namespace PhpParser\NodeVisitor; use PhpParser\Node; use PhpParser\NodeVisitor; use PhpParser\NodeVisitorAbstract; /** * This visitor can be used to find the first node satisfying some criterion determined by * a filter callback. */ class FirstFindingVisitor extends NodeVisitorAbstract { /** @var callable Filter callback */ protected $filterCallback; /** @var null|Node Found node */ protected ?Node $foundNode; public function __construct(callable $filterCallback) { $this->filterCallback = $filterCallback; } /** * Get found node satisfying the filter callback. * * Returns null if no node satisfies the filter callback. * * @return null|Node Found node (or null if not found) */ public function getFoundNode(): ?Node { return $this->foundNode; } public function beforeTraverse(array $nodes): ?array { $this->foundNode = null; return null; } public function enterNode(Node $node) { $filterCallback = $this->filterCallback; if ($filterCallback($node)) { $this->foundNode = $node; return NodeVisitor::STOP_TRAVERSAL; } return null; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/NodeVisitor/FindingVisitor.php
lib/PhpParser/NodeVisitor/FindingVisitor.php
<?php declare(strict_types=1); namespace PhpParser\NodeVisitor; use PhpParser\Node; use PhpParser\NodeVisitorAbstract; /** * This visitor can be used to find and collect all nodes satisfying some criterion determined by * a filter callback. */ class FindingVisitor extends NodeVisitorAbstract { /** @var callable Filter callback */ protected $filterCallback; /** @var list<Node> Found nodes */ protected array $foundNodes; public function __construct(callable $filterCallback) { $this->filterCallback = $filterCallback; } /** * Get found nodes satisfying the filter callback. * * Nodes are returned in pre-order. * * @return list<Node> Found nodes */ public function getFoundNodes(): array { return $this->foundNodes; } public function beforeTraverse(array $nodes): ?array { $this->foundNodes = []; return null; } public function enterNode(Node $node) { $filterCallback = $this->filterCallback; if ($filterCallback($node)) { $this->foundNodes[] = $node; } return null; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Name.php
lib/PhpParser/Node/Name.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\NodeAbstract; class Name extends NodeAbstract { /** * @psalm-var non-empty-string * @var string Name as string */ public string $name; /** @var array<string, bool> */ private static array $specialClassNames = [ 'self' => true, 'parent' => true, 'static' => true, ]; /** * Constructs a name node. * * @param string|string[]|self $name Name as string, part array or Name instance (copy ctor) * @param array<string, mixed> $attributes Additional attributes */ final public function __construct($name, array $attributes = []) { $this->attributes = $attributes; $this->name = self::prepareName($name); } public function getSubNodeNames(): array { return ['name']; } /** * Get parts of name (split by the namespace separator). * * @psalm-return non-empty-list<string> * @return string[] Parts of name */ public function getParts(): array { return \explode('\\', $this->name); } /** * Gets the first part of the name, i.e. everything before the first namespace separator. * * @return string First part of the name */ public function getFirst(): string { if (false !== $pos = \strpos($this->name, '\\')) { return \substr($this->name, 0, $pos); } return $this->name; } /** * Gets the last part of the name, i.e. everything after the last namespace separator. * * @return string Last part of the name */ public function getLast(): string { if (false !== $pos = \strrpos($this->name, '\\')) { return \substr($this->name, $pos + 1); } return $this->name; } /** * Checks whether the name is unqualified. (E.g. Name) * * @return bool Whether the name is unqualified */ public function isUnqualified(): bool { return false === \strpos($this->name, '\\'); } /** * Checks whether the name is qualified. (E.g. Name\Name) * * @return bool Whether the name is qualified */ public function isQualified(): bool { return false !== \strpos($this->name, '\\'); } /** * Checks whether the name is fully qualified. (E.g. \Name) * * @return bool Whether the name is fully qualified */ public function isFullyQualified(): bool { return false; } /** * Checks whether the name is explicitly relative to the current namespace. (E.g. namespace\Name) * * @return bool Whether the name is relative */ public function isRelative(): bool { return false; } /** * Returns a string representation of the name itself, without taking the name type into * account (e.g., not including a leading backslash for fully qualified names). * * @psalm-return non-empty-string * @return string String representation */ public function toString(): string { return $this->name; } /** * Returns a string representation of the name as it would occur in code (e.g., including * leading backslash for fully qualified names. * * @psalm-return non-empty-string * @return string String representation */ public function toCodeString(): string { return $this->toString(); } /** * Returns lowercased string representation of the name, without taking the name type into * account (e.g., no leading backslash for fully qualified names). * * @psalm-return non-empty-string&lowercase-string * @return string Lowercased string representation */ public function toLowerString(): string { return strtolower($this->name); } /** * Checks whether the identifier is a special class name (self, parent or static). * * @return bool Whether identifier is a special class name */ public function isSpecialClassName(): bool { return isset(self::$specialClassNames[strtolower($this->name)]); } /** * Returns a string representation of the name by imploding the namespace parts with the * namespace separator. * * @psalm-return non-empty-string * @return string String representation */ public function __toString(): string { return $this->name; } /** * Gets a slice of a name (similar to array_slice). * * This method returns a new instance of the same type as the original and with the same * attributes. * * If the slice is empty, null is returned. The null value will be correctly handled in * concatenations using concat(). * * Offset and length have the same meaning as in array_slice(). * * @param int $offset Offset to start the slice at (may be negative) * @param int|null $length Length of the slice (may be negative) * * @return static|null Sliced name */ public function slice(int $offset, ?int $length = null) { if ($offset === 1 && $length === null) { // Short-circuit the common case. if (false !== $pos = \strpos($this->name, '\\')) { return new static(\substr($this->name, $pos + 1)); } return null; } $parts = \explode('\\', $this->name); $numParts = \count($parts); $realOffset = $offset < 0 ? $offset + $numParts : $offset; if ($realOffset < 0 || $realOffset > $numParts) { throw new \OutOfBoundsException(sprintf('Offset %d is out of bounds', $offset)); } if (null === $length) { $realLength = $numParts - $realOffset; } else { $realLength = $length < 0 ? $length + $numParts - $realOffset : $length; if ($realLength < 0 || $realLength > $numParts - $realOffset) { throw new \OutOfBoundsException(sprintf('Length %d is out of bounds', $length)); } } if ($realLength === 0) { // Empty slice is represented as null return null; } return new static(array_slice($parts, $realOffset, $realLength), $this->attributes); } /** * Concatenate two names, yielding a new Name instance. * * The type of the generated instance depends on which class this method is called on, for * example Name\FullyQualified::concat() will yield a Name\FullyQualified instance. * * If one of the arguments is null, a new instance of the other name will be returned. If both * arguments are null, null will be returned. As such, writing * Name::concat($namespace, $shortName) * where $namespace is a Name node or null will work as expected. * * @param string|string[]|self|null $name1 The first name * @param string|string[]|self|null $name2 The second name * @param array<string, mixed> $attributes Attributes to assign to concatenated name * * @return static|null Concatenated name */ public static function concat($name1, $name2, array $attributes = []) { if (null === $name1 && null === $name2) { return null; } if (null === $name1) { return new static($name2, $attributes); } if (null === $name2) { return new static($name1, $attributes); } else { return new static( self::prepareName($name1) . '\\' . self::prepareName($name2), $attributes ); } } /** * Prepares a (string, array or Name node) name for use in name changing methods by converting * it to a string. * * @param string|string[]|self $name Name to prepare * * @psalm-return non-empty-string * @return string Prepared name */ private static function prepareName($name): string { if (\is_string($name)) { if ('' === $name) { throw new \InvalidArgumentException('Name cannot be empty'); } return $name; } if (\is_array($name)) { if (empty($name)) { throw new \InvalidArgumentException('Name cannot be empty'); } return implode('\\', $name); } if ($name instanceof self) { return $name->name; } throw new \InvalidArgumentException( 'Expected string, array of parts or Name instance' ); } public function getType(): string { return 'Name'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/ArrayItem.php
lib/PhpParser/Node/ArrayItem.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\NodeAbstract; class ArrayItem extends NodeAbstract { /** @var null|Expr Key */ public ?Expr $key; /** @var Expr Value */ public Expr $value; /** @var bool Whether to assign by reference */ public bool $byRef; /** @var bool Whether to unpack the argument */ public bool $unpack; /** * Constructs an array item node. * * @param Expr $value Value * @param null|Expr $key Key * @param bool $byRef Whether to assign by reference * @param array<string, mixed> $attributes Additional attributes */ public function __construct(Expr $value, ?Expr $key = null, bool $byRef = false, array $attributes = [], bool $unpack = false) { $this->attributes = $attributes; $this->key = $key; $this->value = $value; $this->byRef = $byRef; $this->unpack = $unpack; } public function getSubNodeNames(): array { return ['key', 'value', 'byRef', 'unpack']; } public function getType(): string { return 'ArrayItem'; } } // @deprecated compatibility alias class_alias(ArrayItem::class, Expr\ArrayItem::class);
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/PropertyHook.php
lib/PhpParser/Node/PropertyHook.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\Modifiers; use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\PropertyFetch; use PhpParser\Node\Expr\Variable; use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\Return_; use PhpParser\NodeAbstract; class PropertyHook extends NodeAbstract implements FunctionLike { /** @var AttributeGroup[] PHP attribute groups */ public array $attrGroups; /** @var int Modifiers */ public int $flags; /** @var bool Whether hook returns by reference */ public bool $byRef; /** @var Identifier Hook name */ public Identifier $name; /** @var Param[] Parameters */ public array $params; /** @var null|Expr|Stmt[] Hook body */ public $body; /** * Constructs a property hook node. * * @param string|Identifier $name Hook name * @param null|Expr|Stmt[] $body Hook body * @param array{ * flags?: int, * byRef?: bool, * params?: Param[], * attrGroups?: AttributeGroup[], * } $subNodes Array of the following optional subnodes: * 'flags => 0 : Flags * 'byRef' => false : Whether hook returns by reference * 'params' => array(): Parameters * 'attrGroups' => array(): PHP attribute groups * @param array<string, mixed> $attributes Additional attributes */ public function __construct($name, $body, array $subNodes = [], array $attributes = []) { $this->attributes = $attributes; $this->name = \is_string($name) ? new Identifier($name) : $name; $this->body = $body; $this->flags = $subNodes['flags'] ?? 0; $this->byRef = $subNodes['byRef'] ?? false; $this->params = $subNodes['params'] ?? []; $this->attrGroups = $subNodes['attrGroups'] ?? []; } public function returnsByRef(): bool { return $this->byRef; } public function getParams(): array { return $this->params; } public function getReturnType() { return null; } /** * Whether the property hook is final. */ public function isFinal(): bool { return (bool) ($this->flags & Modifiers::FINAL); } public function getStmts(): ?array { if ($this->body instanceof Expr) { $name = $this->name->toLowerString(); if ($name === 'get') { return [new Return_($this->body)]; } if ($name === 'set') { if (!$this->hasAttribute('propertyName')) { throw new \LogicException( 'Can only use getStmts() on a "set" hook if the "propertyName" attribute is set'); } $propName = $this->getAttribute('propertyName'); $prop = new PropertyFetch(new Variable('this'), (string) $propName); return [new Expression(new Assign($prop, $this->body))]; } throw new \LogicException('Unknown property hook "' . $name . '"'); } return $this->body; } public function getAttrGroups(): array { return $this->attrGroups; } public function getType(): string { return 'PropertyHook'; } public function getSubNodeNames(): array { return ['attrGroups', 'flags', 'byRef', 'name', 'params', 'body']; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/PropertyItem.php
lib/PhpParser/Node/PropertyItem.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\Node; use PhpParser\NodeAbstract; class PropertyItem extends NodeAbstract { /** @var Node\VarLikeIdentifier Name */ public VarLikeIdentifier $name; /** @var null|Node\Expr Default */ public ?Expr $default; /** * Constructs a class property item node. * * @param string|Node\VarLikeIdentifier $name Name * @param null|Node\Expr $default Default value * @param array<string, mixed> $attributes Additional attributes */ public function __construct($name, ?Node\Expr $default = null, array $attributes = []) { $this->attributes = $attributes; $this->name = \is_string($name) ? new Node\VarLikeIdentifier($name) : $name; $this->default = $default; } public function getSubNodeNames(): array { return ['name', 'default']; } public function getType(): string { return 'PropertyItem'; } } // @deprecated compatibility alias class_alias(PropertyItem::class, Stmt\PropertyProperty::class);
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/StaticVar.php
lib/PhpParser/Node/StaticVar.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\Node; use PhpParser\NodeAbstract; class StaticVar extends NodeAbstract { /** @var Expr\Variable Variable */ public Expr\Variable $var; /** @var null|Node\Expr Default value */ public ?Expr $default; /** * Constructs a static variable node. * * @param Expr\Variable $var Name * @param null|Node\Expr $default Default value * @param array<string, mixed> $attributes Additional attributes */ public function __construct( Expr\Variable $var, ?Node\Expr $default = null, array $attributes = [] ) { $this->attributes = $attributes; $this->var = $var; $this->default = $default; } public function getSubNodeNames(): array { return ['var', 'default']; } public function getType(): string { return 'StaticVar'; } } // @deprecated compatibility alias class_alias(StaticVar::class, Stmt\StaticVar::class);
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/UnionType.php
lib/PhpParser/Node/UnionType.php
<?php declare(strict_types=1); namespace PhpParser\Node; class UnionType extends ComplexType { /** @var (Identifier|Name|IntersectionType)[] Types */ public array $types; /** * Constructs a union type. * * @param (Identifier|Name|IntersectionType)[] $types Types * @param array<string, mixed> $attributes Additional attributes */ public function __construct(array $types, array $attributes = []) { $this->attributes = $attributes; $this->types = $types; } public function getSubNodeNames(): array { return ['types']; } public function getType(): string { return 'UnionType'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Attribute.php
lib/PhpParser/Node/Attribute.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\Node; use PhpParser\NodeAbstract; class Attribute extends NodeAbstract { /** @var Name Attribute name */ public Name $name; /** @var list<Arg> Attribute arguments */ public array $args; /** * @param Node\Name $name Attribute name * @param list<Arg> $args Attribute arguments * @param array<string, mixed> $attributes Additional node attributes */ public function __construct(Name $name, array $args = [], array $attributes = []) { $this->attributes = $attributes; $this->name = $name; $this->args = $args; } public function getSubNodeNames(): array { return ['name', 'args']; } public function getType(): string { return 'Attribute'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Identifier.php
lib/PhpParser/Node/Identifier.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\NodeAbstract; /** * Represents a non-namespaced name. Namespaced names are represented using Name nodes. */ class Identifier extends NodeAbstract { /** * @psalm-var non-empty-string * @var string Identifier as string */ public string $name; /** @var array<string, bool> */ private static array $specialClassNames = [ 'self' => true, 'parent' => true, 'static' => true, ]; /** * Constructs an identifier node. * * @param string $name Identifier as string * @param array<string, mixed> $attributes Additional attributes */ public function __construct(string $name, array $attributes = []) { if ($name === '') { throw new \InvalidArgumentException('Identifier name cannot be empty'); } $this->attributes = $attributes; $this->name = $name; } public function getSubNodeNames(): array { return ['name']; } /** * Get identifier as string. * * @psalm-return non-empty-string * @return string Identifier as string. */ public function toString(): string { return $this->name; } /** * Get lowercased identifier as string. * * @psalm-return non-empty-string&lowercase-string * @return string Lowercased identifier as string */ public function toLowerString(): string { return strtolower($this->name); } /** * Checks whether the identifier is a special class name (self, parent or static). * * @return bool Whether identifier is a special class name */ public function isSpecialClassName(): bool { return isset(self::$specialClassNames[strtolower($this->name)]); } /** * Get identifier as string. * * @psalm-return non-empty-string * @return string Identifier as string */ public function __toString(): string { return $this->name; } public function getType(): string { return 'Identifier'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Arg.php
lib/PhpParser/Node/Arg.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\NodeAbstract; class Arg extends NodeAbstract { /** @var Identifier|null Parameter name (for named parameters) */ public ?Identifier $name; /** @var Expr Value to pass */ public Expr $value; /** @var bool Whether to pass by ref */ public bool $byRef; /** @var bool Whether to unpack the argument */ public bool $unpack; /** * Constructs a function call argument node. * * @param Expr $value Value to pass * @param bool $byRef Whether to pass by ref * @param bool $unpack Whether to unpack the argument * @param array<string, mixed> $attributes Additional attributes * @param Identifier|null $name Parameter name (for named parameters) */ public function __construct( Expr $value, bool $byRef = false, bool $unpack = false, array $attributes = [], ?Identifier $name = null ) { $this->attributes = $attributes; $this->name = $name; $this->value = $value; $this->byRef = $byRef; $this->unpack = $unpack; } public function getSubNodeNames(): array { return ['name', 'value', 'byRef', 'unpack']; } public function getType(): string { return 'Arg'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/IntersectionType.php
lib/PhpParser/Node/IntersectionType.php
<?php declare(strict_types=1); namespace PhpParser\Node; class IntersectionType extends ComplexType { /** @var (Identifier|Name)[] Types */ public array $types; /** * Constructs an intersection type. * * @param (Identifier|Name)[] $types Types * @param array<string, mixed> $attributes Additional attributes */ public function __construct(array $types, array $attributes = []) { $this->attributes = $attributes; $this->types = $types; } public function getSubNodeNames(): array { return ['types']; } public function getType(): string { return 'IntersectionType'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/NullableType.php
lib/PhpParser/Node/NullableType.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\Node; class NullableType extends ComplexType { /** @var Identifier|Name Type */ public Node $type; /** * Constructs a nullable type (wrapping another type). * * @param Identifier|Name $type Type * @param array<string, mixed> $attributes Additional attributes */ public function __construct(Node $type, array $attributes = []) { $this->attributes = $attributes; $this->type = $type; } public function getSubNodeNames(): array { return ['type']; } public function getType(): string { return 'NullableType'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt.php
lib/PhpParser/Node/Stmt.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\NodeAbstract; abstract class Stmt extends NodeAbstract { }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Expr.php
lib/PhpParser/Node/Expr.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\NodeAbstract; abstract class Expr extends NodeAbstract { }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Const_.php
lib/PhpParser/Node/Const_.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\NodeAbstract; class Const_ extends NodeAbstract { /** @var Identifier Name */ public Identifier $name; /** @var Expr Value */ public Expr $value; /** @var Name|null Namespaced name (if using NameResolver) */ public ?Name $namespacedName; /** * Constructs a const node for use in class const and const statements. * * @param string|Identifier $name Name * @param Expr $value Value * @param array<string, mixed> $attributes Additional attributes */ public function __construct($name, Expr $value, array $attributes = []) { $this->attributes = $attributes; $this->name = \is_string($name) ? new Identifier($name) : $name; $this->value = $value; } public function getSubNodeNames(): array { return ['name', 'value']; } public function getType(): string { return 'Const'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Scalar.php
lib/PhpParser/Node/Scalar.php
<?php declare(strict_types=1); namespace PhpParser\Node; abstract class Scalar extends Expr { }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Param.php
lib/PhpParser/Node/Param.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\Modifiers; use PhpParser\Node; use PhpParser\NodeAbstract; class Param extends NodeAbstract { /** @var null|Identifier|Name|ComplexType Type declaration */ public ?Node $type; /** @var bool Whether parameter is passed by reference */ public bool $byRef; /** @var bool Whether this is a variadic argument */ public bool $variadic; /** @var Expr\Variable|Expr\Error Parameter variable */ public Expr $var; /** @var null|Expr Default value */ public ?Expr $default; /** @var int Optional visibility flags */ public int $flags; /** @var AttributeGroup[] PHP attribute groups */ public array $attrGroups; /** @var PropertyHook[] Property hooks for promoted properties */ public array $hooks; /** * Constructs a parameter node. * * @param Expr\Variable|Expr\Error $var Parameter variable * @param null|Expr $default Default value * @param null|Identifier|Name|ComplexType $type Type declaration * @param bool $byRef Whether is passed by reference * @param bool $variadic Whether this is a variadic argument * @param array<string, mixed> $attributes Additional attributes * @param int $flags Optional visibility flags * @param list<AttributeGroup> $attrGroups PHP attribute groups * @param PropertyHook[] $hooks Property hooks for promoted properties */ public function __construct( Expr $var, ?Expr $default = null, ?Node $type = null, bool $byRef = false, bool $variadic = false, array $attributes = [], int $flags = 0, array $attrGroups = [], array $hooks = [] ) { $this->attributes = $attributes; $this->type = $type; $this->byRef = $byRef; $this->variadic = $variadic; $this->var = $var; $this->default = $default; $this->flags = $flags; $this->attrGroups = $attrGroups; $this->hooks = $hooks; } public function getSubNodeNames(): array { return ['attrGroups', 'flags', 'type', 'byRef', 'variadic', 'var', 'default', 'hooks']; } public function getType(): string { return 'Param'; } /** * Whether this parameter uses constructor property promotion. */ public function isPromoted(): bool { return $this->flags !== 0 || $this->hooks !== []; } public function isFinal(): bool { return (bool) ($this->flags & Modifiers::FINAL); } public function isPublic(): bool { $public = (bool) ($this->flags & Modifiers::PUBLIC); if ($public) { return true; } if (!$this->isPromoted()) { return false; } return ($this->flags & Modifiers::VISIBILITY_MASK) === 0; } public function isProtected(): bool { return (bool) ($this->flags & Modifiers::PROTECTED); } public function isPrivate(): bool { return (bool) ($this->flags & Modifiers::PRIVATE); } public function isReadonly(): bool { return (bool) ($this->flags & Modifiers::READONLY); } /** * Whether the promoted property has explicit public(set) visibility. */ public function isPublicSet(): bool { return (bool) ($this->flags & Modifiers::PUBLIC_SET); } /** * Whether the promoted property has explicit protected(set) visibility. */ public function isProtectedSet(): bool { return (bool) ($this->flags & Modifiers::PROTECTED_SET); } /** * Whether the promoted property has explicit private(set) visibility. */ public function isPrivateSet(): bool { return (bool) ($this->flags & Modifiers::PRIVATE_SET); } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/AttributeGroup.php
lib/PhpParser/Node/AttributeGroup.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\NodeAbstract; class AttributeGroup extends NodeAbstract { /** @var Attribute[] Attributes */ public array $attrs; /** * @param Attribute[] $attrs PHP attributes * @param array<string, mixed> $attributes Additional node attributes */ public function __construct(array $attrs, array $attributes = []) { $this->attributes = $attributes; $this->attrs = $attrs; } public function getSubNodeNames(): array { return ['attrs']; } public function getType(): string { return 'AttributeGroup'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/ComplexType.php
lib/PhpParser/Node/ComplexType.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\NodeAbstract; /** * This is a base class for complex types, including nullable types and union types. * * It does not provide any shared behavior and exists only for type-checking purposes. */ abstract class ComplexType extends NodeAbstract { }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/VarLikeIdentifier.php
lib/PhpParser/Node/VarLikeIdentifier.php
<?php declare(strict_types=1); namespace PhpParser\Node; /** * Represents a name that is written in source code with a leading dollar, * but is not a proper variable. The leading dollar is not stored as part of the name. * * Examples: Names in property declarations are formatted as variables. Names in static property * lookups are also formatted as variables. */ class VarLikeIdentifier extends Identifier { public function getType(): string { return 'VarLikeIdentifier'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/DeclareItem.php
lib/PhpParser/Node/DeclareItem.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\Node; use PhpParser\NodeAbstract; class DeclareItem extends NodeAbstract { /** @var Node\Identifier Key */ public Identifier $key; /** @var Node\Expr Value */ public Expr $value; /** * Constructs a declare key=>value pair node. * * @param string|Node\Identifier $key Key * @param Node\Expr $value Value * @param array<string, mixed> $attributes Additional attributes */ public function __construct($key, Node\Expr $value, array $attributes = []) { $this->attributes = $attributes; $this->key = \is_string($key) ? new Node\Identifier($key) : $key; $this->value = $value; } public function getSubNodeNames(): array { return ['key', 'value']; } public function getType(): string { return 'DeclareItem'; } } // @deprecated compatibility alias class_alias(DeclareItem::class, Stmt\DeclareDeclare::class);
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/ClosureUse.php
lib/PhpParser/Node/ClosureUse.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\NodeAbstract; class ClosureUse extends NodeAbstract { /** @var Expr\Variable Variable to use */ public Expr\Variable $var; /** @var bool Whether to use by reference */ public bool $byRef; /** * Constructs a closure use node. * * @param Expr\Variable $var Variable to use * @param bool $byRef Whether to use by reference * @param array<string, mixed> $attributes Additional attributes */ public function __construct(Expr\Variable $var, bool $byRef = false, array $attributes = []) { $this->attributes = $attributes; $this->var = $var; $this->byRef = $byRef; } public function getSubNodeNames(): array { return ['var', 'byRef']; } public function getType(): string { return 'ClosureUse'; } } // @deprecated compatibility alias class_alias(ClosureUse::class, Expr\ClosureUse::class);
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/InterpolatedStringPart.php
lib/PhpParser/Node/InterpolatedStringPart.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\NodeAbstract; class InterpolatedStringPart extends NodeAbstract { /** @var string String value */ public string $value; /** * Constructs a node representing a string part of an interpolated string. * * @param string $value String value * @param array<string, mixed> $attributes Additional attributes */ public function __construct(string $value, array $attributes = []) { $this->attributes = $attributes; $this->value = $value; } public function getSubNodeNames(): array { return ['value']; } public function getType(): string { return 'InterpolatedStringPart'; } } // @deprecated compatibility alias class_alias(InterpolatedStringPart::class, Scalar\EncapsedStringPart::class);
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/FunctionLike.php
lib/PhpParser/Node/FunctionLike.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\Node; interface FunctionLike extends Node { /** * Whether to return by reference */ public function returnsByRef(): bool; /** * List of parameters * * @return Param[] */ public function getParams(): array; /** * Get the declared return type or null * * @return null|Identifier|Name|ComplexType */ public function getReturnType(); /** * The function body * * @return Stmt[]|null */ public function getStmts(): ?array; /** * Get PHP attribute groups. * * @return AttributeGroup[] */ public function getAttrGroups(): array; }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/VariadicPlaceholder.php
lib/PhpParser/Node/VariadicPlaceholder.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\NodeAbstract; /** * Represents the "..." in "foo(...)" of the first-class callable syntax. */ class VariadicPlaceholder extends NodeAbstract { /** * Create a variadic argument placeholder (first-class callable syntax). * * @param array<string, mixed> $attributes Additional attributes */ public function __construct(array $attributes = []) { $this->attributes = $attributes; } public function getType(): string { return 'VariadicPlaceholder'; } public function getSubNodeNames(): array { return []; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/MatchArm.php
lib/PhpParser/Node/MatchArm.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\Node; use PhpParser\NodeAbstract; class MatchArm extends NodeAbstract { /** @var null|list<Node\Expr> */ public ?array $conds; public Expr $body; /** * @param null|list<Node\Expr> $conds */ public function __construct(?array $conds, Node\Expr $body, array $attributes = []) { $this->conds = $conds; $this->body = $body; $this->attributes = $attributes; } public function getSubNodeNames(): array { return ['conds', 'body']; } public function getType(): string { return 'MatchArm'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/UseItem.php
lib/PhpParser/Node/UseItem.php
<?php declare(strict_types=1); namespace PhpParser\Node; use PhpParser\Node; use PhpParser\NodeAbstract; use PhpParser\Node\Stmt\Use_; class UseItem extends NodeAbstract { /** * @var Use_::TYPE_* One of the Stmt\Use_::TYPE_* constants. Will only differ from TYPE_UNKNOWN for mixed group uses */ public int $type; /** @var Node\Name Namespace, class, function or constant to alias */ public Name $name; /** @var Identifier|null Alias */ public ?Identifier $alias; /** * Constructs an alias (use) item node. * * @param Node\Name $name Namespace/Class to alias * @param null|string|Identifier $alias Alias * @param Use_::TYPE_* $type Type of the use element (for mixed group use only) * @param array<string, mixed> $attributes Additional attributes */ public function __construct(Node\Name $name, $alias = null, int $type = Use_::TYPE_UNKNOWN, array $attributes = []) { $this->attributes = $attributes; $this->type = $type; $this->name = $name; $this->alias = \is_string($alias) ? new Identifier($alias) : $alias; } public function getSubNodeNames(): array { return ['type', 'name', 'alias']; } /** * Get alias. If not explicitly given this is the last component of the used name. */ public function getAlias(): Identifier { if (null !== $this->alias) { return $this->alias; } return new Identifier($this->name->getLast()); } public function getType(): string { return 'UseItem'; } } // @deprecated compatibility alias class_alias(UseItem::class, Stmt\UseUse::class);
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/UseUse.php
lib/PhpParser/Node/Stmt/UseUse.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node\UseItem; require __DIR__ . '/../UseItem.php'; if (false) { /** * For classmap-authoritative support. * * @deprecated use \PhpParser\Node\UseItem instead. */ class UseUse extends UseItem { } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/TraitUseAdaptation.php
lib/PhpParser/Node/Stmt/TraitUseAdaptation.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; abstract class TraitUseAdaptation extends Node\Stmt { /** @var Node\Name|null Trait name */ public ?Node\Name $trait; /** @var Node\Identifier Method name */ public Node\Identifier $method; }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Class_.php
lib/PhpParser/Node/Stmt/Class_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Modifiers; use PhpParser\Node; class Class_ extends ClassLike { /** @deprecated Use Modifiers::PUBLIC instead */ public const MODIFIER_PUBLIC = 1; /** @deprecated Use Modifiers::PROTECTED instead */ public const MODIFIER_PROTECTED = 2; /** @deprecated Use Modifiers::PRIVATE instead */ public const MODIFIER_PRIVATE = 4; /** @deprecated Use Modifiers::STATIC instead */ public const MODIFIER_STATIC = 8; /** @deprecated Use Modifiers::ABSTRACT instead */ public const MODIFIER_ABSTRACT = 16; /** @deprecated Use Modifiers::FINAL instead */ public const MODIFIER_FINAL = 32; /** @deprecated Use Modifiers::READONLY instead */ public const MODIFIER_READONLY = 64; /** @deprecated Use Modifiers::VISIBILITY_MASK instead */ public const VISIBILITY_MODIFIER_MASK = 7; // 1 | 2 | 4 /** @var int Modifiers */ public int $flags; /** @var null|Node\Name Name of extended class */ public ?Node\Name $extends; /** @var Node\Name[] Names of implemented interfaces */ public array $implements; /** * Constructs a class node. * * @param string|Node\Identifier|null $name Name * @param array{ * flags?: int, * extends?: Node\Name|null, * implements?: Node\Name[], * stmts?: Node\Stmt[], * attrGroups?: Node\AttributeGroup[], * } $subNodes Array of the following optional subnodes: * 'flags' => 0 : Flags * 'extends' => null : Name of extended class * 'implements' => array(): Names of implemented interfaces * 'stmts' => array(): Statements * 'attrGroups' => array(): PHP attribute groups * @param array<string, mixed> $attributes Additional attributes */ public function __construct($name, array $subNodes = [], array $attributes = []) { $this->attributes = $attributes; $this->flags = $subNodes['flags'] ?? $subNodes['type'] ?? 0; $this->name = \is_string($name) ? new Node\Identifier($name) : $name; $this->extends = $subNodes['extends'] ?? null; $this->implements = $subNodes['implements'] ?? []; $this->stmts = $subNodes['stmts'] ?? []; $this->attrGroups = $subNodes['attrGroups'] ?? []; } public function getSubNodeNames(): array { return ['attrGroups', 'flags', 'name', 'extends', 'implements', 'stmts']; } /** * Whether the class is explicitly abstract. */ public function isAbstract(): bool { return (bool) ($this->flags & Modifiers::ABSTRACT); } /** * Whether the class is final. */ public function isFinal(): bool { return (bool) ($this->flags & Modifiers::FINAL); } public function isReadonly(): bool { return (bool) ($this->flags & Modifiers::READONLY); } /** * Whether the class is anonymous. */ public function isAnonymous(): bool { return null === $this->name; } public function getType(): string { return 'Stmt_Class'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Return_.php
lib/PhpParser/Node/Stmt/Return_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; class Return_ extends Node\Stmt { /** @var null|Node\Expr Expression */ public ?Node\Expr $expr; /** * Constructs a return node. * * @param null|Node\Expr $expr Expression * @param array<string, mixed> $attributes Additional attributes */ public function __construct(?Node\Expr $expr = null, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; } public function getSubNodeNames(): array { return ['expr']; } public function getType(): string { return 'Stmt_Return'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Foreach_.php
lib/PhpParser/Node/Stmt/Foreach_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; class Foreach_ extends Node\Stmt { /** @var Node\Expr Expression to iterate */ public Node\Expr $expr; /** @var null|Node\Expr Variable to assign key to */ public ?Node\Expr $keyVar; /** @var bool Whether to assign value by reference */ public bool $byRef; /** @var Node\Expr Variable to assign value to */ public Node\Expr $valueVar; /** @var Node\Stmt[] Statements */ public array $stmts; /** * Constructs a foreach node. * * @param Node\Expr $expr Expression to iterate * @param Node\Expr $valueVar Variable to assign value to * @param array{ * keyVar?: Node\Expr|null, * byRef?: bool, * stmts?: Node\Stmt[], * } $subNodes Array of the following optional subnodes: * 'keyVar' => null : Variable to assign key to * 'byRef' => false : Whether to assign value by reference * 'stmts' => array(): Statements * @param array<string, mixed> $attributes Additional attributes */ public function __construct(Node\Expr $expr, Node\Expr $valueVar, array $subNodes = [], array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; $this->keyVar = $subNodes['keyVar'] ?? null; $this->byRef = $subNodes['byRef'] ?? false; $this->valueVar = $valueVar; $this->stmts = $subNodes['stmts'] ?? []; } public function getSubNodeNames(): array { return ['expr', 'keyVar', 'byRef', 'valueVar', 'stmts']; } public function getType(): string { return 'Stmt_Foreach'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Interface_.php
lib/PhpParser/Node/Stmt/Interface_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; class Interface_ extends ClassLike { /** @var Node\Name[] Extended interfaces */ public array $extends; /** * Constructs a class node. * * @param string|Node\Identifier $name Name * @param array{ * extends?: Node\Name[], * stmts?: Node\Stmt[], * attrGroups?: Node\AttributeGroup[], * } $subNodes Array of the following optional subnodes: * 'extends' => array(): Name of extended interfaces * 'stmts' => array(): Statements * 'attrGroups' => array(): PHP attribute groups * @param array<string, mixed> $attributes Additional attributes */ public function __construct($name, array $subNodes = [], array $attributes = []) { $this->attributes = $attributes; $this->name = \is_string($name) ? new Node\Identifier($name) : $name; $this->extends = $subNodes['extends'] ?? []; $this->stmts = $subNodes['stmts'] ?? []; $this->attrGroups = $subNodes['attrGroups'] ?? []; } public function getSubNodeNames(): array { return ['attrGroups', 'name', 'extends', 'stmts']; } public function getType(): string { return 'Stmt_Interface'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Expression.php
lib/PhpParser/Node/Stmt/Expression.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; /** * Represents statements of type "expr;" */ class Expression extends Node\Stmt { /** @var Node\Expr Expression */ public Node\Expr $expr; /** * Constructs an expression statement. * * @param Node\Expr $expr Expression * @param array<string, mixed> $attributes Additional attributes */ public function __construct(Node\Expr $expr, array $attributes = []) { $this->attributes = $attributes; $this->expr = $expr; } public function getSubNodeNames(): array { return ['expr']; } public function getType(): string { return 'Stmt_Expression'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/EnumCase.php
lib/PhpParser/Node/Stmt/EnumCase.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; use PhpParser\Node\AttributeGroup; class EnumCase extends Node\Stmt { /** @var Node\Identifier Enum case name */ public Node\Identifier $name; /** @var Node\Expr|null Enum case expression */ public ?Node\Expr $expr; /** @var Node\AttributeGroup[] PHP attribute groups */ public array $attrGroups; /** * @param string|Node\Identifier $name Enum case name * @param Node\Expr|null $expr Enum case expression * @param list<AttributeGroup> $attrGroups PHP attribute groups * @param array<string, mixed> $attributes Additional attributes */ public function __construct($name, ?Node\Expr $expr = null, array $attrGroups = [], array $attributes = []) { parent::__construct($attributes); $this->name = \is_string($name) ? new Node\Identifier($name) : $name; $this->expr = $expr; $this->attrGroups = $attrGroups; } public function getSubNodeNames(): array { return ['attrGroups', 'name', 'expr']; } public function getType(): string { return 'Stmt_EnumCase'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Unset_.php
lib/PhpParser/Node/Stmt/Unset_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; class Unset_ extends Node\Stmt { /** @var Node\Expr[] Variables to unset */ public array $vars; /** * Constructs an unset node. * * @param Node\Expr[] $vars Variables to unset * @param array<string, mixed> $attributes Additional attributes */ public function __construct(array $vars, array $attributes = []) { $this->attributes = $attributes; $this->vars = $vars; } public function getSubNodeNames(): array { return ['vars']; } public function getType(): string { return 'Stmt_Unset'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Use_.php
lib/PhpParser/Node/Stmt/Use_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node\Stmt; use PhpParser\Node\UseItem; class Use_ extends Stmt { /** * Unknown type. Both Stmt\Use_ / Stmt\GroupUse and Stmt\UseUse have a $type property, one of them will always be * TYPE_UNKNOWN while the other has one of the three other possible types. For normal use statements the type on the * Stmt\UseUse is unknown. It's only the other way around for mixed group use declarations. */ public const TYPE_UNKNOWN = 0; /** Class or namespace import */ public const TYPE_NORMAL = 1; /** Function import */ public const TYPE_FUNCTION = 2; /** Constant import */ public const TYPE_CONSTANT = 3; /** @var self::TYPE_* Type of alias */ public int $type; /** @var UseItem[] Aliases */ public array $uses; /** * Constructs an alias (use) list node. * * @param UseItem[] $uses Aliases * @param Stmt\Use_::TYPE_* $type Type of alias * @param array<string, mixed> $attributes Additional attributes */ public function __construct(array $uses, int $type = self::TYPE_NORMAL, array $attributes = []) { $this->attributes = $attributes; $this->type = $type; $this->uses = $uses; } public function getSubNodeNames(): array { return ['type', 'uses']; } public function getType(): string { return 'Stmt_Use'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Nop.php
lib/PhpParser/Node/Stmt/Nop.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; /** Nop/empty statement (;). */ class Nop extends Node\Stmt { public function getSubNodeNames(): array { return []; } public function getType(): string { return 'Stmt_Nop'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Case_.php
lib/PhpParser/Node/Stmt/Case_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; class Case_ extends Node\Stmt { /** @var null|Node\Expr Condition (null for default) */ public ?Node\Expr $cond; /** @var Node\Stmt[] Statements */ public array $stmts; /** * Constructs a case node. * * @param null|Node\Expr $cond Condition (null for default) * @param Node\Stmt[] $stmts Statements * @param array<string, mixed> $attributes Additional attributes */ public function __construct(?Node\Expr $cond, array $stmts = [], array $attributes = []) { $this->attributes = $attributes; $this->cond = $cond; $this->stmts = $stmts; } public function getSubNodeNames(): array { return ['cond', 'stmts']; } public function getType(): string { return 'Stmt_Case'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/StaticVar.php
lib/PhpParser/Node/Stmt/StaticVar.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; require __DIR__ . '/../StaticVar.php'; if (false) { /** * For classmap-authoritative support. * * @deprecated use \PhpParser\Node\StaticVar instead. */ class StaticVar extends \PhpParser\Node\StaticVar { } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/For_.php
lib/PhpParser/Node/Stmt/For_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; class For_ extends Node\Stmt { /** @var Node\Expr[] Init expressions */ public array $init; /** @var Node\Expr[] Loop conditions */ public array $cond; /** @var Node\Expr[] Loop expressions */ public array $loop; /** @var Node\Stmt[] Statements */ public array $stmts; /** * Constructs a for loop node. * * @param array{ * init?: Node\Expr[], * cond?: Node\Expr[], * loop?: Node\Expr[], * stmts?: Node\Stmt[], * } $subNodes Array of the following optional subnodes: * 'init' => array(): Init expressions * 'cond' => array(): Loop conditions * 'loop' => array(): Loop expressions * 'stmts' => array(): Statements * @param array<string, mixed> $attributes Additional attributes */ public function __construct(array $subNodes = [], array $attributes = []) { $this->attributes = $attributes; $this->init = $subNodes['init'] ?? []; $this->cond = $subNodes['cond'] ?? []; $this->loop = $subNodes['loop'] ?? []; $this->stmts = $subNodes['stmts'] ?? []; } public function getSubNodeNames(): array { return ['init', 'cond', 'loop', 'stmts']; } public function getType(): string { return 'Stmt_For'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/If_.php
lib/PhpParser/Node/Stmt/If_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; class If_ extends Node\Stmt { /** @var Node\Expr Condition expression */ public Node\Expr $cond; /** @var Node\Stmt[] Statements */ public array $stmts; /** @var ElseIf_[] Elseif clauses */ public array $elseifs; /** @var null|Else_ Else clause */ public ?Else_ $else; /** * Constructs an if node. * * @param Node\Expr $cond Condition * @param array{ * stmts?: Node\Stmt[], * elseifs?: ElseIf_[], * else?: Else_|null, * } $subNodes Array of the following optional subnodes: * 'stmts' => array(): Statements * 'elseifs' => array(): Elseif clauses * 'else' => null : Else clause * @param array<string, mixed> $attributes Additional attributes */ public function __construct(Node\Expr $cond, array $subNodes = [], array $attributes = []) { $this->attributes = $attributes; $this->cond = $cond; $this->stmts = $subNodes['stmts'] ?? []; $this->elseifs = $subNodes['elseifs'] ?? []; $this->else = $subNodes['else'] ?? null; } public function getSubNodeNames(): array { return ['cond', 'stmts', 'elseifs', 'else']; } public function getType(): string { return 'Stmt_If'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Property.php
lib/PhpParser/Node/Stmt/Property.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Modifiers; use PhpParser\Node; use PhpParser\Node\ComplexType; use PhpParser\Node\Identifier; use PhpParser\Node\Name; use PhpParser\Node\PropertyItem; class Property extends Node\Stmt { /** @var int Modifiers */ public int $flags; /** @var PropertyItem[] Properties */ public array $props; /** @var null|Identifier|Name|ComplexType Type declaration */ public ?Node $type; /** @var Node\AttributeGroup[] PHP attribute groups */ public array $attrGroups; /** @var Node\PropertyHook[] Property hooks */ public array $hooks; /** * Constructs a class property list node. * * @param int $flags Modifiers * @param PropertyItem[] $props Properties * @param array<string, mixed> $attributes Additional attributes * @param null|Identifier|Name|ComplexType $type Type declaration * @param Node\AttributeGroup[] $attrGroups PHP attribute groups * @param Node\PropertyHook[] $hooks Property hooks */ public function __construct(int $flags, array $props, array $attributes = [], ?Node $type = null, array $attrGroups = [], array $hooks = []) { $this->attributes = $attributes; $this->flags = $flags; $this->props = $props; $this->type = $type; $this->attrGroups = $attrGroups; $this->hooks = $hooks; } public function getSubNodeNames(): array { return ['attrGroups', 'flags', 'type', 'props', 'hooks']; } /** * Whether the property is explicitly or implicitly public. */ public function isPublic(): bool { return ($this->flags & Modifiers::PUBLIC) !== 0 || ($this->flags & Modifiers::VISIBILITY_MASK) === 0; } /** * Whether the property is protected. */ public function isProtected(): bool { return (bool) ($this->flags & Modifiers::PROTECTED); } /** * Whether the property is private. */ public function isPrivate(): bool { return (bool) ($this->flags & Modifiers::PRIVATE); } /** * Whether the property is static. */ public function isStatic(): bool { return (bool) ($this->flags & Modifiers::STATIC); } /** * Whether the property is readonly. */ public function isReadonly(): bool { return (bool) ($this->flags & Modifiers::READONLY); } /** * Whether the property is abstract. */ public function isAbstract(): bool { return (bool) ($this->flags & Modifiers::ABSTRACT); } /** * Whether the property is final. */ public function isFinal(): bool { return (bool) ($this->flags & Modifiers::FINAL); } /** * Whether the property has explicit public(set) visibility. */ public function isPublicSet(): bool { return (bool) ($this->flags & Modifiers::PUBLIC_SET); } /** * Whether the property has explicit protected(set) visibility. */ public function isProtectedSet(): bool { return (bool) ($this->flags & Modifiers::PROTECTED_SET); } /** * Whether the property has explicit private(set) visibility. */ public function isPrivateSet(): bool { return (bool) ($this->flags & Modifiers::PRIVATE_SET); } public function getType(): string { return 'Stmt_Property'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Label.php
lib/PhpParser/Node/Stmt/Label.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node\Identifier; use PhpParser\Node\Stmt; class Label extends Stmt { /** @var Identifier Name */ public Identifier $name; /** * Constructs a label node. * * @param string|Identifier $name Name * @param array<string, mixed> $attributes Additional attributes */ public function __construct($name, array $attributes = []) { $this->attributes = $attributes; $this->name = \is_string($name) ? new Identifier($name) : $name; } public function getSubNodeNames(): array { return ['name']; } public function getType(): string { return 'Stmt_Label'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Declare_.php
lib/PhpParser/Node/Stmt/Declare_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; use PhpParser\Node\DeclareItem; class Declare_ extends Node\Stmt { /** @var DeclareItem[] List of declares */ public array $declares; /** @var Node\Stmt[]|null Statements */ public ?array $stmts; /** * Constructs a declare node. * * @param DeclareItem[] $declares List of declares * @param Node\Stmt[]|null $stmts Statements * @param array<string, mixed> $attributes Additional attributes */ public function __construct(array $declares, ?array $stmts = null, array $attributes = []) { $this->attributes = $attributes; $this->declares = $declares; $this->stmts = $stmts; } public function getSubNodeNames(): array { return ['declares', 'stmts']; } public function getType(): string { return 'Stmt_Declare'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Continue_.php
lib/PhpParser/Node/Stmt/Continue_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; class Continue_ extends Node\Stmt { /** @var null|Node\Expr Number of loops to continue */ public ?Node\Expr $num; /** * Constructs a continue node. * * @param null|Node\Expr $num Number of loops to continue * @param array<string, mixed> $attributes Additional attributes */ public function __construct(?Node\Expr $num = null, array $attributes = []) { $this->attributes = $attributes; $this->num = $num; } public function getSubNodeNames(): array { return ['num']; } public function getType(): string { return 'Stmt_Continue'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Const_.php
lib/PhpParser/Node/Stmt/Const_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; class Const_ extends Node\Stmt { /** @var Node\Const_[] Constant declarations */ public array $consts; /** @var Node\AttributeGroup[] PHP attribute groups */ public array $attrGroups; /** * Constructs a const list node. * * @param Node\Const_[] $consts Constant declarations * @param array<string, mixed> $attributes Additional attributes * @param list<Node\AttributeGroup> $attrGroups PHP attribute groups */ public function __construct( array $consts, array $attributes = [], array $attrGroups = [] ) { $this->attributes = $attributes; $this->attrGroups = $attrGroups; $this->consts = $consts; } public function getSubNodeNames(): array { return ['attrGroups', 'consts']; } public function getType(): string { return 'Stmt_Const'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Catch_.php
lib/PhpParser/Node/Stmt/Catch_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; use PhpParser\Node\Expr; class Catch_ extends Node\Stmt { /** @var Node\Name[] Types of exceptions to catch */ public array $types; /** @var Expr\Variable|null Variable for exception */ public ?Expr\Variable $var; /** @var Node\Stmt[] Statements */ public array $stmts; /** * Constructs a catch node. * * @param Node\Name[] $types Types of exceptions to catch * @param Expr\Variable|null $var Variable for exception * @param Node\Stmt[] $stmts Statements * @param array<string, mixed> $attributes Additional attributes */ public function __construct( array $types, ?Expr\Variable $var = null, array $stmts = [], array $attributes = [] ) { $this->attributes = $attributes; $this->types = $types; $this->var = $var; $this->stmts = $stmts; } public function getSubNodeNames(): array { return ['types', 'var', 'stmts']; } public function getType(): string { return 'Stmt_Catch'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Namespace_.php
lib/PhpParser/Node/Stmt/Namespace_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; class Namespace_ extends Node\Stmt { /* For use in the "kind" attribute */ public const KIND_SEMICOLON = 1; public const KIND_BRACED = 2; /** @var null|Node\Name Name */ public ?Node\Name $name; /** @var Node\Stmt[] Statements */ public $stmts; /** * Constructs a namespace node. * * @param null|Node\Name $name Name * @param null|Node\Stmt[] $stmts Statements * @param array<string, mixed> $attributes Additional attributes */ public function __construct(?Node\Name $name = null, ?array $stmts = [], array $attributes = []) { $this->attributes = $attributes; $this->name = $name; $this->stmts = $stmts; } public function getSubNodeNames(): array { return ['name', 'stmts']; } public function getType(): string { return 'Stmt_Namespace'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/ClassLike.php
lib/PhpParser/Node/Stmt/ClassLike.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; use PhpParser\Node\PropertyItem; abstract class ClassLike extends Node\Stmt { /** @var Node\Identifier|null Name */ public ?Node\Identifier $name; /** @var Node\Stmt[] Statements */ public array $stmts; /** @var Node\AttributeGroup[] PHP attribute groups */ public array $attrGroups; /** @var Node\Name|null Namespaced name (if using NameResolver) */ public ?Node\Name $namespacedName; /** * @return list<TraitUse> */ public function getTraitUses(): array { $traitUses = []; foreach ($this->stmts as $stmt) { if ($stmt instanceof TraitUse) { $traitUses[] = $stmt; } } return $traitUses; } /** * @return list<ClassConst> */ public function getConstants(): array { $constants = []; foreach ($this->stmts as $stmt) { if ($stmt instanceof ClassConst) { $constants[] = $stmt; } } return $constants; } /** * @return list<Property> */ public function getProperties(): array { $properties = []; foreach ($this->stmts as $stmt) { if ($stmt instanceof Property) { $properties[] = $stmt; } } return $properties; } /** * Gets property with the given name defined directly in this class/interface/trait. * * @param string $name Name of the property * * @return Property|null Property node or null if the property does not exist */ public function getProperty(string $name): ?Property { foreach ($this->stmts as $stmt) { if ($stmt instanceof Property) { foreach ($stmt->props as $prop) { if ($prop instanceof PropertyItem && $name === $prop->name->toString()) { return $stmt; } } } } return null; } /** * Gets all methods defined directly in this class/interface/trait * * @return list<ClassMethod> */ public function getMethods(): array { $methods = []; foreach ($this->stmts as $stmt) { if ($stmt instanceof ClassMethod) { $methods[] = $stmt; } } return $methods; } /** * Gets method with the given name defined directly in this class/interface/trait. * * @param string $name Name of the method (compared case-insensitively) * * @return ClassMethod|null Method node or null if the method does not exist */ public function getMethod(string $name): ?ClassMethod { $lowerName = strtolower($name); foreach ($this->stmts as $stmt) { if ($stmt instanceof ClassMethod && $lowerName === $stmt->name->toLowerString()) { return $stmt; } } return null; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Finally_.php
lib/PhpParser/Node/Stmt/Finally_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; class Finally_ extends Node\Stmt { /** @var Node\Stmt[] Statements */ public array $stmts; /** * Constructs a finally node. * * @param Node\Stmt[] $stmts Statements * @param array<string, mixed> $attributes Additional attributes */ public function __construct(array $stmts = [], array $attributes = []) { $this->attributes = $attributes; $this->stmts = $stmts; } public function getSubNodeNames(): array { return ['stmts']; } public function getType(): string { return 'Stmt_Finally'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/TraitUse.php
lib/PhpParser/Node/Stmt/TraitUse.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; class TraitUse extends Node\Stmt { /** @var Node\Name[] Traits */ public array $traits; /** @var TraitUseAdaptation[] Adaptations */ public array $adaptations; /** * Constructs a trait use node. * * @param Node\Name[] $traits Traits * @param TraitUseAdaptation[] $adaptations Adaptations * @param array<string, mixed> $attributes Additional attributes */ public function __construct(array $traits, array $adaptations = [], array $attributes = []) { $this->attributes = $attributes; $this->traits = $traits; $this->adaptations = $adaptations; } public function getSubNodeNames(): array { return ['traits', 'adaptations']; } public function getType(): string { return 'Stmt_TraitUse'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/InlineHTML.php
lib/PhpParser/Node/Stmt/InlineHTML.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node\Stmt; class InlineHTML extends Stmt { /** @var string String */ public string $value; /** * Constructs an inline HTML node. * * @param string $value String * @param array<string, mixed> $attributes Additional attributes */ public function __construct(string $value, array $attributes = []) { $this->attributes = $attributes; $this->value = $value; } public function getSubNodeNames(): array { return ['value']; } public function getType(): string { return 'Stmt_InlineHTML'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Switch_.php
lib/PhpParser/Node/Stmt/Switch_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; class Switch_ extends Node\Stmt { /** @var Node\Expr Condition */ public Node\Expr $cond; /** @var Case_[] Case list */ public array $cases; /** * Constructs a case node. * * @param Node\Expr $cond Condition * @param Case_[] $cases Case list * @param array<string, mixed> $attributes Additional attributes */ public function __construct(Node\Expr $cond, array $cases, array $attributes = []) { $this->attributes = $attributes; $this->cond = $cond; $this->cases = $cases; } public function getSubNodeNames(): array { return ['cond', 'cases']; } public function getType(): string { return 'Stmt_Switch'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/GroupUse.php
lib/PhpParser/Node/Stmt/GroupUse.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node\Name; use PhpParser\Node\Stmt; use PhpParser\Node\UseItem; class GroupUse extends Stmt { /** * @var Use_::TYPE_* Type of group use */ public int $type; /** @var Name Prefix for uses */ public Name $prefix; /** @var UseItem[] Uses */ public array $uses; /** * Constructs a group use node. * * @param Name $prefix Prefix for uses * @param UseItem[] $uses Uses * @param Use_::TYPE_* $type Type of group use * @param array<string, mixed> $attributes Additional attributes */ public function __construct(Name $prefix, array $uses, int $type = Use_::TYPE_NORMAL, array $attributes = []) { $this->attributes = $attributes; $this->type = $type; $this->prefix = $prefix; $this->uses = $uses; } public function getSubNodeNames(): array { return ['type', 'prefix', 'uses']; } public function getType(): string { return 'Stmt_GroupUse'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Else_.php
lib/PhpParser/Node/Stmt/Else_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; class Else_ extends Node\Stmt { /** @var Node\Stmt[] Statements */ public array $stmts; /** * Constructs an else node. * * @param Node\Stmt[] $stmts Statements * @param array<string, mixed> $attributes Additional attributes */ public function __construct(array $stmts = [], array $attributes = []) { $this->attributes = $attributes; $this->stmts = $stmts; } public function getSubNodeNames(): array { return ['stmts']; } public function getType(): string { return 'Stmt_Else'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Break_.php
lib/PhpParser/Node/Stmt/Break_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; class Break_ extends Node\Stmt { /** @var null|Node\Expr Number of loops to break */ public ?Node\Expr $num; /** * Constructs a break node. * * @param null|Node\Expr $num Number of loops to break * @param array<string, mixed> $attributes Additional attributes */ public function __construct(?Node\Expr $num = null, array $attributes = []) { $this->attributes = $attributes; $this->num = $num; } public function getSubNodeNames(): array { return ['num']; } public function getType(): string { return 'Stmt_Break'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Global_.php
lib/PhpParser/Node/Stmt/Global_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; class Global_ extends Node\Stmt { /** @var Node\Expr[] Variables */ public array $vars; /** * Constructs a global variables list node. * * @param Node\Expr[] $vars Variables to unset * @param array<string, mixed> $attributes Additional attributes */ public function __construct(array $vars, array $attributes = []) { $this->attributes = $attributes; $this->vars = $vars; } public function getSubNodeNames(): array { return ['vars']; } public function getType(): string { return 'Stmt_Global'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Echo_.php
lib/PhpParser/Node/Stmt/Echo_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; class Echo_ extends Node\Stmt { /** @var Node\Expr[] Expressions */ public array $exprs; /** * Constructs an echo node. * * @param Node\Expr[] $exprs Expressions * @param array<string, mixed> $attributes Additional attributes */ public function __construct(array $exprs, array $attributes = []) { $this->attributes = $attributes; $this->exprs = $exprs; } public function getSubNodeNames(): array { return ['exprs']; } public function getType(): string { return 'Stmt_Echo'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/While_.php
lib/PhpParser/Node/Stmt/While_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; class While_ extends Node\Stmt { /** @var Node\Expr Condition */ public Node\Expr $cond; /** @var Node\Stmt[] Statements */ public array $stmts; /** * Constructs a while node. * * @param Node\Expr $cond Condition * @param Node\Stmt[] $stmts Statements * @param array<string, mixed> $attributes Additional attributes */ public function __construct(Node\Expr $cond, array $stmts = [], array $attributes = []) { $this->attributes = $attributes; $this->cond = $cond; $this->stmts = $stmts; } public function getSubNodeNames(): array { return ['cond', 'stmts']; } public function getType(): string { return 'Stmt_While'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/Enum_.php
lib/PhpParser/Node/Stmt/Enum_.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node; class Enum_ extends ClassLike { /** @var null|Node\Identifier Scalar Type */ public ?Node $scalarType; /** @var Node\Name[] Names of implemented interfaces */ public array $implements; /** * @param string|Node\Identifier|null $name Name * @param array{ * scalarType?: Node\Identifier|null, * implements?: Node\Name[], * stmts?: Node\Stmt[], * attrGroups?: Node\AttributeGroup[], * } $subNodes Array of the following optional subnodes: * 'scalarType' => null : Scalar type * 'implements' => array() : Names of implemented interfaces * 'stmts' => array() : Statements * 'attrGroups' => array() : PHP attribute groups * @param array<string, mixed> $attributes Additional attributes */ public function __construct($name, array $subNodes = [], array $attributes = []) { $this->name = \is_string($name) ? new Node\Identifier($name) : $name; $this->scalarType = $subNodes['scalarType'] ?? null; $this->implements = $subNodes['implements'] ?? []; $this->stmts = $subNodes['stmts'] ?? []; $this->attrGroups = $subNodes['attrGroups'] ?? []; parent::__construct($attributes); } public function getSubNodeNames(): array { return ['attrGroups', 'name', 'scalarType', 'implements', 'stmts']; } public function getType(): string { return 'Stmt_Enum'; } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/PropertyProperty.php
lib/PhpParser/Node/Stmt/PropertyProperty.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node\PropertyItem; require __DIR__ . '/../PropertyItem.php'; if (false) { /** * For classmap-authoritative support. * * @deprecated use \PhpParser\Node\PropertyItem instead. */ class PropertyProperty extends PropertyItem { } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false
nikic/PHP-Parser
https://github.com/nikic/PHP-Parser/blob/8c360e27327c8bd29e1c57721574709d0d706118/lib/PhpParser/Node/Stmt/DeclareDeclare.php
lib/PhpParser/Node/Stmt/DeclareDeclare.php
<?php declare(strict_types=1); namespace PhpParser\Node\Stmt; use PhpParser\Node\DeclareItem; require __DIR__ . '/../DeclareItem.php'; if (false) { /** * For classmap-authoritative support. * * @deprecated use \PhpParser\Node\DeclareItem instead. */ class DeclareDeclare extends DeclareItem { } }
php
BSD-3-Clause
8c360e27327c8bd29e1c57721574709d0d706118
2026-01-04T15:02:34.433891Z
false