first commit

This commit is contained in:
Sampanna Rimal
2024-08-27 17:48:06 +05:45
commit 53c0140f58
10839 changed files with 1125847 additions and 0 deletions

View File

@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Stmt;
use PhpParser\Node\Stmt;
class Block extends Stmt {
/** @var Stmt[] Statements */
public array $stmts;
/**
* A block of statements.
*
* @param 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 getType(): string {
return 'Stmt_Block';
}
public function getSubNodeNames(): array {
return ['stmts'];
}
}

View File

@ -0,0 +1,29 @@
<?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';
}
}

View File

@ -0,0 +1,33 @@
<?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';
}
}

View File

@ -0,0 +1,40 @@
<?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';
}
}

View File

@ -0,0 +1,77 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Stmt;
use PhpParser\Modifiers;
use PhpParser\Node;
class ClassConst extends Node\Stmt {
/** @var int Modifiers */
public int $flags;
/** @var Node\Const_[] Constant declarations */
public array $consts;
/** @var Node\AttributeGroup[] PHP attribute groups */
public array $attrGroups;
/** @var Node\Identifier|Node\Name|Node\ComplexType|null Type declaration */
public ?Node $type;
/**
* Constructs a class const list node.
*
* @param Node\Const_[] $consts Constant declarations
* @param int $flags Modifiers
* @param array<string, mixed> $attributes Additional attributes
* @param list<Node\AttributeGroup> $attrGroups PHP attribute groups
* @param null|Node\Identifier|Node\Name|Node\ComplexType $type Type declaration
*/
public function __construct(
array $consts,
int $flags = 0,
array $attributes = [],
array $attrGroups = [],
?Node $type = null
) {
$this->attributes = $attributes;
$this->flags = $flags;
$this->consts = $consts;
$this->attrGroups = $attrGroups;
$this->type = $type;
}
public function getSubNodeNames(): array {
return ['attrGroups', 'flags', 'type', 'consts'];
}
/**
* Whether constant is explicitly or implicitly public.
*/
public function isPublic(): bool {
return ($this->flags & Modifiers::PUBLIC) !== 0
|| ($this->flags & Modifiers::VISIBILITY_MASK) === 0;
}
/**
* Whether constant is protected.
*/
public function isProtected(): bool {
return (bool) ($this->flags & Modifiers::PROTECTED);
}
/**
* Whether constant is private.
*/
public function isPrivate(): bool {
return (bool) ($this->flags & Modifiers::PRIVATE);
}
/**
* Whether constant is final.
*/
public function isFinal(): bool {
return (bool) ($this->flags & Modifiers::FINAL);
}
public function getType(): string {
return 'Stmt_ClassConst';
}
}

View File

@ -0,0 +1,109 @@
<?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 TraitUse[]
*/
public function getTraitUses(): array {
$traitUses = [];
foreach ($this->stmts as $stmt) {
if ($stmt instanceof TraitUse) {
$traitUses[] = $stmt;
}
}
return $traitUses;
}
/**
* @return ClassConst[]
*/
public function getConstants(): array {
$constants = [];
foreach ($this->stmts as $stmt) {
if ($stmt instanceof ClassConst) {
$constants[] = $stmt;
}
}
return $constants;
}
/**
* @return 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 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;
}
}

View File

@ -0,0 +1,154 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Stmt;
use PhpParser\Modifiers;
use PhpParser\Node;
use PhpParser\Node\FunctionLike;
class ClassMethod extends Node\Stmt implements FunctionLike {
/** @var int Flags */
public int $flags;
/** @var bool Whether to return by reference */
public bool $byRef;
/** @var Node\Identifier Name */
public Node\Identifier $name;
/** @var Node\Param[] Parameters */
public array $params;
/** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */
public ?Node $returnType;
/** @var Node\Stmt[]|null Statements */
public ?array $stmts;
/** @var Node\AttributeGroup[] PHP attribute groups */
public array $attrGroups;
/** @var array<string, bool> */
private static array $magicNames = [
'__construct' => true,
'__destruct' => true,
'__call' => true,
'__callstatic' => true,
'__get' => true,
'__set' => true,
'__isset' => true,
'__unset' => true,
'__sleep' => true,
'__wakeup' => true,
'__tostring' => true,
'__set_state' => true,
'__clone' => true,
'__invoke' => true,
'__debuginfo' => true,
'__serialize' => true,
'__unserialize' => true,
];
/**
* Constructs a class method node.
*
* @param string|Node\Identifier $name Name
* @param array{
* flags?: int,
* byRef?: bool,
* params?: Node\Param[],
* returnType?: null|Node\Identifier|Node\Name|Node\ComplexType,
* stmts?: Node\Stmt[]|null,
* attrGroups?: Node\AttributeGroup[],
* } $subNodes Array of the following optional subnodes:
* 'flags => 0 : Flags
* 'byRef' => false : Whether to return by reference
* 'params' => array() : Parameters
* 'returnType' => null : Return type
* '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->byRef = $subNodes['byRef'] ?? false;
$this->name = \is_string($name) ? new Node\Identifier($name) : $name;
$this->params = $subNodes['params'] ?? [];
$this->returnType = $subNodes['returnType'] ?? null;
$this->stmts = array_key_exists('stmts', $subNodes) ? $subNodes['stmts'] : [];
$this->attrGroups = $subNodes['attrGroups'] ?? [];
}
public function getSubNodeNames(): array {
return ['attrGroups', 'flags', 'byRef', 'name', 'params', 'returnType', 'stmts'];
}
public function returnsByRef(): bool {
return $this->byRef;
}
public function getParams(): array {
return $this->params;
}
public function getReturnType() {
return $this->returnType;
}
public function getStmts(): ?array {
return $this->stmts;
}
public function getAttrGroups(): array {
return $this->attrGroups;
}
/**
* Whether the method is explicitly or implicitly public.
*/
public function isPublic(): bool {
return ($this->flags & Modifiers::PUBLIC) !== 0
|| ($this->flags & Modifiers::VISIBILITY_MASK) === 0;
}
/**
* Whether the method is protected.
*/
public function isProtected(): bool {
return (bool) ($this->flags & Modifiers::PROTECTED);
}
/**
* Whether the method is private.
*/
public function isPrivate(): bool {
return (bool) ($this->flags & Modifiers::PRIVATE);
}
/**
* Whether the method is abstract.
*/
public function isAbstract(): bool {
return (bool) ($this->flags & Modifiers::ABSTRACT);
}
/**
* Whether the method is final.
*/
public function isFinal(): bool {
return (bool) ($this->flags & Modifiers::FINAL);
}
/**
* Whether the method is static.
*/
public function isStatic(): bool {
return (bool) ($this->flags & Modifiers::STATIC);
}
/**
* Whether the method is magic.
*/
public function isMagic(): bool {
return isset(self::$magicNames[$this->name->toLowerString()]);
}
public function getType(): string {
return 'Stmt_ClassMethod';
}
}

View File

@ -0,0 +1,94 @@
<?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';
}
}

View File

@ -0,0 +1,29 @@
<?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;
/**
* Constructs a const list node.
*
* @param Node\Const_[] $consts Constant declarations
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(array $consts, array $attributes = []) {
$this->attributes = $attributes;
$this->consts = $consts;
}
public function getSubNodeNames(): array {
return ['consts'];
}
public function getType(): string {
return 'Stmt_Const';
}
}

View File

@ -0,0 +1,29 @@
<?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';
}
}

View File

@ -0,0 +1,3 @@
<?php declare(strict_types=1);
require __DIR__ . '/../DeclareItem.php';

View File

@ -0,0 +1,34 @@
<?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';
}
}

View File

@ -0,0 +1,33 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class Do_ extends Node\Stmt {
/** @var Node\Stmt[] Statements */
public array $stmts;
/** @var Node\Expr Condition */
public Node\Expr $cond;
/**
* Constructs a do 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 ['stmts', 'cond'];
}
public function getType(): string {
return 'Stmt_Do';
}
}

View File

@ -0,0 +1,29 @@
<?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';
}
}

View File

@ -0,0 +1,33 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class ElseIf_ extends Node\Stmt {
/** @var Node\Expr Condition */
public Node\Expr $cond;
/** @var Node\Stmt[] Statements */
public array $stmts;
/**
* Constructs an elseif 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_ElseIf';
}
}

View File

@ -0,0 +1,29 @@
<?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';
}
}

View File

@ -0,0 +1,36 @@
<?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';
}
}

View File

@ -0,0 +1,44 @@
<?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';
}
}

View File

@ -0,0 +1,32 @@
<?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';
}
}

View File

@ -0,0 +1,29 @@
<?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';
}
}

View File

@ -0,0 +1,47 @@
<?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';
}
}

View File

@ -0,0 +1,50 @@
<?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';
}
}

View File

@ -0,0 +1,81 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Stmt;
use PhpParser\Node;
use PhpParser\Node\FunctionLike;
class Function_ extends Node\Stmt implements FunctionLike {
/** @var bool Whether function returns by reference */
public bool $byRef;
/** @var Node\Identifier Name */
public Node\Identifier $name;
/** @var Node\Param[] Parameters */
public array $params;
/** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */
public ?Node $returnType;
/** @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;
/**
* Constructs a function node.
*
* @param string|Node\Identifier $name Name
* @param array{
* byRef?: bool,
* params?: Node\Param[],
* returnType?: null|Node\Identifier|Node\Name|Node\ComplexType,
* stmts?: Node\Stmt[],
* attrGroups?: Node\AttributeGroup[],
* } $subNodes Array of the following optional subnodes:
* 'byRef' => false : Whether to return by reference
* 'params' => array(): Parameters
* 'returnType' => null : Return type
* '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->byRef = $subNodes['byRef'] ?? false;
$this->name = \is_string($name) ? new Node\Identifier($name) : $name;
$this->params = $subNodes['params'] ?? [];
$this->returnType = $subNodes['returnType'] ?? null;
$this->stmts = $subNodes['stmts'] ?? [];
$this->attrGroups = $subNodes['attrGroups'] ?? [];
}
public function getSubNodeNames(): array {
return ['attrGroups', 'byRef', 'name', 'params', 'returnType', 'stmts'];
}
public function returnsByRef(): bool {
return $this->byRef;
}
public function getParams(): array {
return $this->params;
}
public function getReturnType() {
return $this->returnType;
}
public function getAttrGroups(): array {
return $this->attrGroups;
}
/** @return Node\Stmt[] */
public function getStmts(): array {
return $this->stmts;
}
public function getType(): string {
return 'Stmt_Function';
}
}

View File

@ -0,0 +1,29 @@
<?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';
}
}

View File

@ -0,0 +1,30 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Stmt;
use PhpParser\Node\Identifier;
use PhpParser\Node\Stmt;
class Goto_ extends Stmt {
/** @var Identifier Name of label to jump to */
public Identifier $name;
/**
* Constructs a goto node.
*
* @param string|Identifier $name Name of label to jump to
* @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_Goto';
}
}

View File

@ -0,0 +1,41 @@
<?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';
}
}

View File

@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Stmt;
use PhpParser\Node\Stmt;
class HaltCompiler extends Stmt {
/** @var string Remaining text after halt compiler statement. */
public string $remaining;
/**
* Constructs a __halt_compiler node.
*
* @param string $remaining Remaining text after halt compiler statement.
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(string $remaining, array $attributes = []) {
$this->attributes = $attributes;
$this->remaining = $remaining;
}
public function getSubNodeNames(): array {
return ['remaining'];
}
public function getType(): string {
return 'Stmt_HaltCompiler';
}
}

View File

@ -0,0 +1,46 @@
<?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';
}
}

View File

@ -0,0 +1,29 @@
<?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';
}
}

View File

@ -0,0 +1,40 @@
<?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';
}
}

View File

@ -0,0 +1,30 @@
<?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';
}
}

View File

@ -0,0 +1,37 @@
<?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';
}
}

View File

@ -0,0 +1,16 @@
<?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';
}
}

View File

@ -0,0 +1,82 @@
<?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;
/**
* 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
*/
public function __construct(int $flags, array $props, array $attributes = [], ?Node $type = null, array $attrGroups = []) {
$this->attributes = $attributes;
$this->flags = $flags;
$this->props = $props;
$this->type = $type;
$this->attrGroups = $attrGroups;
}
public function getSubNodeNames(): array {
return ['attrGroups', 'flags', 'type', 'props'];
}
/**
* 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);
}
public function getType(): string {
return 'Stmt_Property';
}
}

View File

@ -0,0 +1,3 @@
<?php declare(strict_types=1);
require __DIR__ . '/../PropertyItem.php';

View File

@ -0,0 +1,29 @@
<?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';
}
}

View File

@ -0,0 +1,3 @@
<?php declare(strict_types=1);
require __DIR__ . '/../StaticVar.php';

View File

@ -0,0 +1,30 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Stmt;
use PhpParser\Node\StaticVar;
use PhpParser\Node\Stmt;
class Static_ extends Stmt {
/** @var StaticVar[] Variable definitions */
public array $vars;
/**
* Constructs a static variables list node.
*
* @param StaticVar[] $vars Variable definitions
* @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_Static';
}
}

View File

@ -0,0 +1,33 @@
<?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';
}
}

View File

@ -0,0 +1,33 @@
<?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';
}
}

View File

@ -0,0 +1,12 @@
<?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;
}

View File

@ -0,0 +1,37 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Stmt\TraitUseAdaptation;
use PhpParser\Node;
class Alias extends Node\Stmt\TraitUseAdaptation {
/** @var null|int New modifier */
public ?int $newModifier;
/** @var null|Node\Identifier New name */
public ?Node\Identifier $newName;
/**
* Constructs a trait use precedence adaptation node.
*
* @param null|Node\Name $trait Trait name
* @param string|Node\Identifier $method Method name
* @param null|int $newModifier New modifier
* @param null|string|Node\Identifier $newName New name
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(?Node\Name $trait, $method, ?int $newModifier, $newName, array $attributes = []) {
$this->attributes = $attributes;
$this->trait = $trait;
$this->method = \is_string($method) ? new Node\Identifier($method) : $method;
$this->newModifier = $newModifier;
$this->newName = \is_string($newName) ? new Node\Identifier($newName) : $newName;
}
public function getSubNodeNames(): array {
return ['trait', 'method', 'newModifier', 'newName'];
}
public function getType(): string {
return 'Stmt_TraitUseAdaptation_Alias';
}
}

View File

@ -0,0 +1,33 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Stmt\TraitUseAdaptation;
use PhpParser\Node;
class Precedence extends Node\Stmt\TraitUseAdaptation {
/** @var Node\Name[] Overwritten traits */
public array $insteadof;
/**
* Constructs a trait use precedence adaptation node.
*
* @param Node\Name $trait Trait name
* @param string|Node\Identifier $method Method name
* @param Node\Name[] $insteadof Overwritten traits
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Node\Name $trait, $method, array $insteadof, array $attributes = []) {
$this->attributes = $attributes;
$this->trait = $trait;
$this->method = \is_string($method) ? new Node\Identifier($method) : $method;
$this->insteadof = $insteadof;
}
public function getSubNodeNames(): array {
return ['trait', 'method', 'insteadof'];
}
public function getType(): string {
return 'Stmt_TraitUseAdaptation_Precedence';
}
}

View File

@ -0,0 +1,34 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class Trait_ extends ClassLike {
/**
* Constructs a trait node.
*
* @param string|Node\Identifier $name Name
* @param array{
* stmts?: Node\Stmt[],
* attrGroups?: Node\AttributeGroup[],
* } $subNodes Array of the following optional subnodes:
* '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->stmts = $subNodes['stmts'] ?? [];
$this->attrGroups = $subNodes['attrGroups'] ?? [];
}
public function getSubNodeNames(): array {
return ['attrGroups', 'name', 'stmts'];
}
public function getType(): string {
return 'Stmt_Trait';
}
}

View File

@ -0,0 +1,37 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class TryCatch extends Node\Stmt {
/** @var Node\Stmt[] Statements */
public array $stmts;
/** @var Catch_[] Catches */
public array $catches;
/** @var null|Finally_ Optional finally node */
public ?Finally_ $finally;
/**
* Constructs a try catch node.
*
* @param Node\Stmt[] $stmts Statements
* @param Catch_[] $catches Catches
* @param null|Finally_ $finally Optional finally node
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(array $stmts, array $catches, ?Finally_ $finally = null, array $attributes = []) {
$this->attributes = $attributes;
$this->stmts = $stmts;
$this->catches = $catches;
$this->finally = $finally;
}
public function getSubNodeNames(): array {
return ['stmts', 'catches', 'finally'];
}
public function getType(): string {
return 'Stmt_TryCatch';
}
}

View File

@ -0,0 +1,29 @@
<?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';
}
}

View File

@ -0,0 +1,3 @@
<?php declare(strict_types=1);
require __DIR__ . '/../UseItem.php';

View File

@ -0,0 +1,47 @@
<?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';
}
}

View File

@ -0,0 +1,33 @@
<?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';
}
}