Aggiornato Composer

This commit is contained in:
Paolo A
2024-05-17 12:24:19 +00:00
parent 4ac62108b5
commit ec201d75b2
2238 changed files with 38684 additions and 59785 deletions

View File

@@ -4,27 +4,26 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class Break_ extends Node\Stmt
{
class Break_ extends Node\Stmt {
/** @var null|Node\Expr Number of loops to break */
public $num;
public ?Node\Expr $num;
/**
* Constructs a break node.
*
* @param null|Node\Expr $num Number of loops to break
* @param array $attributes Additional attributes
* @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 = []) {
public function __construct(?Node\Expr $num = null, array $attributes = []) {
$this->attributes = $attributes;
$this->num = $num;
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['num'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Break';
}
}

View File

@@ -4,31 +4,30 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class Case_ extends Node\Stmt
{
class Case_ extends Node\Stmt {
/** @var null|Node\Expr Condition (null for default) */
public $cond;
public ?Node\Expr $cond;
/** @var Node\Stmt[] Statements */
public $stmts;
public array $stmts;
/**
* Constructs a case node.
*
* @param null|Node\Expr $cond Condition (null for default)
* @param Node\Stmt[] $stmts Statements
* @param array $attributes Additional attributes
* @param null|Node\Expr $cond Condition (null for default)
* @param Node\Stmt[] $stmts Statements
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct($cond, array $stmts = [], array $attributes = []) {
public function __construct(?Node\Expr $cond, array $stmts = [], array $attributes = []) {
$this->attributes = $attributes;
$this->cond = $cond;
$this->stmts = $stmts;
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['cond', 'stmts'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Case';
}
}

View File

@@ -5,25 +5,24 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
use PhpParser\Node\Expr;
class Catch_ extends Node\Stmt
{
class Catch_ extends Node\Stmt {
/** @var Node\Name[] Types of exceptions to catch */
public $types;
public array $types;
/** @var Expr\Variable|null Variable for exception */
public $var;
public ?Expr\Variable $var;
/** @var Node\Stmt[] Statements */
public $stmts;
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 $attributes Additional attributes
* @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 = []
array $types, ?Expr\Variable $var = null, array $stmts = [], array $attributes = []
) {
$this->attributes = $attributes;
$this->types = $types;
@@ -31,11 +30,11 @@ class Catch_ extends Node\Stmt
$this->stmts = $stmts;
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['types', 'var', 'stmts'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Catch';
}
}

View File

@@ -2,79 +2,76 @@
namespace PhpParser\Node\Stmt;
use PhpParser\Modifiers;
use PhpParser\Node;
class ClassConst extends Node\Stmt
{
class ClassConst extends Node\Stmt {
/** @var int Modifiers */
public $flags;
public int $flags;
/** @var Node\Const_[] Constant declarations */
public $consts;
/** @var Node\AttributeGroup[] */
public $attrGroups;
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 $attributes Additional attributes
* @param Node\AttributeGroup[] $attrGroups PHP attribute groups
* @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 = []
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', 'consts'];
public function getSubNodeNames(): array {
return ['attrGroups', 'flags', 'type', 'consts'];
}
/**
* Whether constant is explicitly or implicitly public.
*
* @return bool
*/
public function isPublic() : bool {
return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0
|| ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0;
public function isPublic(): bool {
return ($this->flags & Modifiers::PUBLIC) !== 0
|| ($this->flags & Modifiers::VISIBILITY_MASK) === 0;
}
/**
* Whether constant is protected.
*
* @return bool
*/
public function isProtected() : bool {
return (bool) ($this->flags & Class_::MODIFIER_PROTECTED);
public function isProtected(): bool {
return (bool) ($this->flags & Modifiers::PROTECTED);
}
/**
* Whether constant is private.
*
* @return bool
*/
public function isPrivate() : bool {
return (bool) ($this->flags & Class_::MODIFIER_PRIVATE);
public function isPrivate(): bool {
return (bool) ($this->flags & Modifiers::PRIVATE);
}
/**
* Whether constant is final.
*
* @return bool
*/
public function isFinal() : bool {
return (bool) ($this->flags & Class_::MODIFIER_FINAL);
public function isFinal(): bool {
return (bool) ($this->flags & Modifiers::FINAL);
}
public function getType() : string {
public function getType(): string {
return 'Stmt_ClassConst';
}
}

View File

@@ -3,23 +3,23 @@
namespace PhpParser\Node\Stmt;
use PhpParser\Node;
use PhpParser\Node\PropertyItem;
abstract class ClassLike extends Node\Stmt
{
abstract class ClassLike extends Node\Stmt {
/** @var Node\Identifier|null Name */
public $name;
public ?Node\Identifier $name;
/** @var Node\Stmt[] Statements */
public $stmts;
public array $stmts;
/** @var Node\AttributeGroup[] PHP attribute groups */
public $attrGroups;
public array $attrGroups;
/** @var Node\Name Namespaced name (if using NameResolver) */
public $namespacedName;
/** @var Node\Name|null Namespaced name (if using NameResolver) */
public ?Node\Name $namespacedName;
/**
* @return TraitUse[]
*/
public function getTraitUses() : array {
public function getTraitUses(): array {
$traitUses = [];
foreach ($this->stmts as $stmt) {
if ($stmt instanceof TraitUse) {
@@ -32,7 +32,7 @@ abstract class ClassLike extends Node\Stmt
/**
* @return ClassConst[]
*/
public function getConstants() : array {
public function getConstants(): array {
$constants = [];
foreach ($this->stmts as $stmt) {
if ($stmt instanceof ClassConst) {
@@ -45,7 +45,7 @@ abstract class ClassLike extends Node\Stmt
/**
* @return Property[]
*/
public function getProperties() : array {
public function getProperties(): array {
$properties = [];
foreach ($this->stmts as $stmt) {
if ($stmt instanceof Property) {
@@ -62,11 +62,11 @@ abstract class ClassLike extends Node\Stmt
*
* @return Property|null Property node or null if the property does not exist
*/
public function getProperty(string $name) {
public function getProperty(string $name): ?Property {
foreach ($this->stmts as $stmt) {
if ($stmt instanceof Property) {
foreach ($stmt->props as $prop) {
if ($prop instanceof PropertyProperty && $name === $prop->name->toString()) {
if ($prop instanceof PropertyItem && $name === $prop->name->toString()) {
return $stmt;
}
}
@@ -80,7 +80,7 @@ abstract class ClassLike extends Node\Stmt
*
* @return ClassMethod[]
*/
public function getMethods() : array {
public function getMethods(): array {
$methods = [];
foreach ($this->stmts as $stmt) {
if ($stmt instanceof ClassMethod) {
@@ -97,7 +97,7 @@ abstract class ClassLike extends Node\Stmt
*
* @return ClassMethod|null Method node or null if the method does not exist
*/
public function getMethod(string $name) {
public function getMethod(string $name): ?ClassMethod {
$lowerName = strtolower($name);
foreach ($this->stmts as $stmt) {
if ($stmt instanceof ClassMethod && $lowerName === $stmt->name->toLowerString()) {

View File

@@ -2,56 +2,66 @@
namespace PhpParser\Node\Stmt;
use PhpParser\Modifiers;
use PhpParser\Node;
use PhpParser\Node\FunctionLike;
class ClassMethod extends Node\Stmt implements FunctionLike
{
class ClassMethod extends Node\Stmt implements FunctionLike {
/** @var int Flags */
public $flags;
public int $flags;
/** @var bool Whether to return by reference */
public $byRef;
public bool $byRef;
/** @var Node\Identifier Name */
public $name;
public Node\Identifier $name;
/** @var Node\Param[] Parameters */
public $params;
public array $params;
/** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */
public $returnType;
public ?Node $returnType;
/** @var Node\Stmt[]|null Statements */
public $stmts;
public ?array $stmts;
/** @var Node\AttributeGroup[] PHP attribute groups */
public $attrGroups;
public array $attrGroups;
private static $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,
/** @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 $subNodes Array of the following optional subnodes:
* 'flags => MODIFIER_PUBLIC: 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 $attributes Additional attributes
* @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;
@@ -59,21 +69,20 @@ class ClassMethod extends Node\Stmt implements FunctionLike
$this->byRef = $subNodes['byRef'] ?? false;
$this->name = \is_string($name) ? new Node\Identifier($name) : $name;
$this->params = $subNodes['params'] ?? [];
$returnType = $subNodes['returnType'] ?? null;
$this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType;
$this->returnType = $subNodes['returnType'] ?? null;
$this->stmts = array_key_exists('stmts', $subNodes) ? $subNodes['stmts'] : [];
$this->attrGroups = $subNodes['attrGroups'] ?? [];
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['attrGroups', 'flags', 'byRef', 'name', 'params', 'returnType', 'stmts'];
}
public function returnsByRef() : bool {
public function returnsByRef(): bool {
return $this->byRef;
}
public function getParams() : array {
public function getParams(): array {
return $this->params;
}
@@ -81,79 +90,65 @@ class ClassMethod extends Node\Stmt implements FunctionLike
return $this->returnType;
}
public function getStmts() {
public function getStmts(): ?array {
return $this->stmts;
}
public function getAttrGroups() : array {
public function getAttrGroups(): array {
return $this->attrGroups;
}
/**
* Whether the method is explicitly or implicitly public.
*
* @return bool
*/
public function isPublic() : bool {
return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0
|| ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0;
public function isPublic(): bool {
return ($this->flags & Modifiers::PUBLIC) !== 0
|| ($this->flags & Modifiers::VISIBILITY_MASK) === 0;
}
/**
* Whether the method is protected.
*
* @return bool
*/
public function isProtected() : bool {
return (bool) ($this->flags & Class_::MODIFIER_PROTECTED);
public function isProtected(): bool {
return (bool) ($this->flags & Modifiers::PROTECTED);
}
/**
* Whether the method is private.
*
* @return bool
*/
public function isPrivate() : bool {
return (bool) ($this->flags & Class_::MODIFIER_PRIVATE);
public function isPrivate(): bool {
return (bool) ($this->flags & Modifiers::PRIVATE);
}
/**
* Whether the method is abstract.
*
* @return bool
*/
public function isAbstract() : bool {
return (bool) ($this->flags & Class_::MODIFIER_ABSTRACT);
public function isAbstract(): bool {
return (bool) ($this->flags & Modifiers::ABSTRACT);
}
/**
* Whether the method is final.
*
* @return bool
*/
public function isFinal() : bool {
return (bool) ($this->flags & Class_::MODIFIER_FINAL);
public function isFinal(): bool {
return (bool) ($this->flags & Modifiers::FINAL);
}
/**
* Whether the method is static.
*
* @return bool
*/
public function isStatic() : bool {
return (bool) ($this->flags & Class_::MODIFIER_STATIC);
public function isStatic(): bool {
return (bool) ($this->flags & Modifiers::STATIC);
}
/**
* Whether the method is magic.
*
* @return bool
*/
public function isMagic() : bool {
public function isMagic(): bool {
return isset(self::$magicNames[$this->name->toLowerString()]);
}
public function getType() : string {
public function getType(): string {
return 'Stmt_ClassMethod';
}
}

View File

@@ -2,39 +2,52 @@
namespace PhpParser\Node\Stmt;
use PhpParser\Error;
use PhpParser\Modifiers;
use PhpParser\Node;
class Class_ extends ClassLike
{
const MODIFIER_PUBLIC = 1;
const MODIFIER_PROTECTED = 2;
const MODIFIER_PRIVATE = 4;
const MODIFIER_STATIC = 8;
const MODIFIER_ABSTRACT = 16;
const MODIFIER_FINAL = 32;
const MODIFIER_READONLY = 64;
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;
const VISIBILITY_MODIFIER_MASK = 7; // 1 | 2 | 4
/** @deprecated Use Modifiers::VISIBILITY_MASK instead */
public const VISIBILITY_MODIFIER_MASK = 7; // 1 | 2 | 4
/** @var int Type */
public $flags;
/** @var int Modifiers */
public int $flags;
/** @var null|Node\Name Name of extended class */
public $extends;
public ?Node\Name $extends;
/** @var Node\Name[] Names of implemented interfaces */
public $implements;
public array $implements;
/**
* Constructs a class node.
*
* @param string|Node\Identifier|null $name Name
* @param array $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 $attributes Additional attributes
* @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;
@@ -46,67 +59,36 @@ class Class_ extends ClassLike
$this->attrGroups = $subNodes['attrGroups'] ?? [];
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['attrGroups', 'flags', 'name', 'extends', 'implements', 'stmts'];
}
/**
* Whether the class is explicitly abstract.
*
* @return bool
*/
public function isAbstract() : bool {
return (bool) ($this->flags & self::MODIFIER_ABSTRACT);
public function isAbstract(): bool {
return (bool) ($this->flags & Modifiers::ABSTRACT);
}
/**
* Whether the class is final.
*
* @return bool
*/
public function isFinal() : bool {
return (bool) ($this->flags & self::MODIFIER_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.
*
* @return bool
*/
public function isAnonymous() : bool {
public function isAnonymous(): bool {
return null === $this->name;
}
/**
* @internal
*/
public static function verifyModifier($a, $b) {
if ($a & self::VISIBILITY_MODIFIER_MASK && $b & self::VISIBILITY_MODIFIER_MASK) {
throw new Error('Multiple access type modifiers are not allowed');
}
if ($a & self::MODIFIER_ABSTRACT && $b & self::MODIFIER_ABSTRACT) {
throw new Error('Multiple abstract modifiers are not allowed');
}
if ($a & self::MODIFIER_STATIC && $b & self::MODIFIER_STATIC) {
throw new Error('Multiple static modifiers are not allowed');
}
if ($a & self::MODIFIER_FINAL && $b & self::MODIFIER_FINAL) {
throw new Error('Multiple final modifiers are not allowed');
}
if ($a & self::MODIFIER_READONLY && $b & self::MODIFIER_READONLY) {
throw new Error('Multiple readonly modifiers are not allowed');
}
if ($a & 48 && $b & 48) {
throw new Error('Cannot use the final modifier on an abstract class member');
}
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Class';
}
}

View File

@@ -4,27 +4,26 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class Const_ extends Node\Stmt
{
class Const_ extends Node\Stmt {
/** @var Node\Const_[] Constant declarations */
public $consts;
public array $consts;
/**
* Constructs a const list node.
*
* @param Node\Const_[] $consts Constant declarations
* @param array $attributes Additional attributes
* @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 {
public function getSubNodeNames(): array {
return ['consts'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Const';
}
}

View File

@@ -4,27 +4,26 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class Continue_ extends Node\Stmt
{
class Continue_ extends Node\Stmt {
/** @var null|Node\Expr Number of loops to continue */
public $num;
public ?Node\Expr $num;
/**
* Constructs a continue node.
*
* @param null|Node\Expr $num Number of loops to continue
* @param array $attributes Additional attributes
* @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 = []) {
public function __construct(?Node\Expr $num = null, array $attributes = []) {
$this->attributes = $attributes;
$this->num = $num;
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['num'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Continue';
}
}

View File

@@ -1,34 +1,3 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class DeclareDeclare extends Node\Stmt
{
/** @var Node\Identifier Key */
public $key;
/** @var Node\Expr Value */
public $value;
/**
* Constructs a declare key=>value pair node.
*
* @param string|Node\Identifier $key Key
* @param Node\Expr $value Value
* @param array $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 'Stmt_DeclareDeclare';
}
}
require __DIR__ . '/../DeclareItem.php';

View File

@@ -3,32 +3,32 @@
namespace PhpParser\Node\Stmt;
use PhpParser\Node;
use PhpParser\Node\DeclareItem;
class Declare_ extends Node\Stmt
{
/** @var DeclareDeclare[] List of declares */
public $declares;
class Declare_ extends Node\Stmt {
/** @var DeclareItem[] List of declares */
public array $declares;
/** @var Node\Stmt[]|null Statements */
public $stmts;
public ?array $stmts;
/**
* Constructs a declare node.
*
* @param DeclareDeclare[] $declares List of declares
* @param Node\Stmt[]|null $stmts Statements
* @param array $attributes Additional attributes
* @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 = []) {
public function __construct(array $declares, ?array $stmts = null, array $attributes = []) {
$this->attributes = $attributes;
$this->declares = $declares;
$this->stmts = $stmts;
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['declares', 'stmts'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Declare';
}
}

View File

@@ -4,19 +4,18 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class Do_ extends Node\Stmt
{
class Do_ extends Node\Stmt {
/** @var Node\Stmt[] Statements */
public $stmts;
public array $stmts;
/** @var Node\Expr Condition */
public $cond;
public Node\Expr $cond;
/**
* Constructs a do while node.
*
* @param Node\Expr $cond Condition
* @param Node\Stmt[] $stmts Statements
* @param array $attributes Additional attributes
* @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;
@@ -24,11 +23,11 @@ class Do_ extends Node\Stmt
$this->stmts = $stmts;
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['stmts', 'cond'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Do';
}
}

View File

@@ -4,27 +4,26 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class Echo_ extends Node\Stmt
{
class Echo_ extends Node\Stmt {
/** @var Node\Expr[] Expressions */
public $exprs;
public array $exprs;
/**
* Constructs an echo node.
*
* @param Node\Expr[] $exprs Expressions
* @param array $attributes Additional attributes
* @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 {
public function getSubNodeNames(): array {
return ['exprs'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Echo';
}
}

View File

@@ -4,19 +4,18 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class ElseIf_ extends Node\Stmt
{
class ElseIf_ extends Node\Stmt {
/** @var Node\Expr Condition */
public $cond;
public Node\Expr $cond;
/** @var Node\Stmt[] Statements */
public $stmts;
public array $stmts;
/**
* Constructs an elseif node.
*
* @param Node\Expr $cond Condition
* @param Node\Stmt[] $stmts Statements
* @param array $attributes Additional attributes
* @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;
@@ -24,11 +23,11 @@ class ElseIf_ extends Node\Stmt
$this->stmts = $stmts;
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['cond', 'stmts'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_ElseIf';
}
}

View File

@@ -4,27 +4,26 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class Else_ extends Node\Stmt
{
class Else_ extends Node\Stmt {
/** @var Node\Stmt[] Statements */
public $stmts;
public array $stmts;
/**
* Constructs an else node.
*
* @param Node\Stmt[] $stmts Statements
* @param array $attributes Additional attributes
* @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 {
public function getSubNodeNames(): array {
return ['stmts'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Else';
}
}

View File

@@ -5,33 +5,32 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
use PhpParser\Node\AttributeGroup;
class EnumCase extends Node\Stmt
{
class EnumCase extends Node\Stmt {
/** @var Node\Identifier Enum case name */
public $name;
public Node\Identifier $name;
/** @var Node\Expr|null Enum case expression */
public $expr;
public ?Node\Expr $expr;
/** @var Node\AttributeGroup[] PHP attribute groups */
public $attrGroups;
public array $attrGroups;
/**
* @param string|Node\Identifier $name Enum case name
* @param Node\Expr|null $expr Enum case expression
* @param AttributeGroup[] $attrGroups PHP attribute groups
* @param array $attributes Additional attributes
* @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 = []) {
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 {
public function getSubNodeNames(): array {
return ['attrGroups', 'name', 'expr'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_EnumCase';
}
}

View File

@@ -4,21 +4,25 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class Enum_ extends ClassLike
{
class Enum_ extends ClassLike {
/** @var null|Node\Identifier Scalar Type */
public $scalarType;
public ?Node $scalarType;
/** @var Node\Name[] Names of implemented interfaces */
public $implements;
public array $implements;
/**
* @param string|Node\Identifier|null $name Name
* @param array $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 $attributes Additional attributes
* @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;
@@ -30,11 +34,11 @@ class Enum_ extends ClassLike
parent::__construct($attributes);
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['attrGroups', 'name', 'scalarType', 'implements', 'stmts'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Enum';
}
}

View File

@@ -7,27 +7,26 @@ use PhpParser\Node;
/**
* Represents statements of type "expr;"
*/
class Expression extends Node\Stmt
{
class Expression extends Node\Stmt {
/** @var Node\Expr Expression */
public $expr;
public Node\Expr $expr;
/**
* Constructs an expression statement.
*
* @param Node\Expr $expr Expression
* @param array $attributes Additional attributes
* @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 {
public function getSubNodeNames(): array {
return ['expr'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Expression';
}
}

View File

@@ -4,27 +4,26 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class Finally_ extends Node\Stmt
{
class Finally_ extends Node\Stmt {
/** @var Node\Stmt[] Statements */
public $stmts;
public array $stmts;
/**
* Constructs a finally node.
*
* @param Node\Stmt[] $stmts Statements
* @param array $attributes Additional attributes
* @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 {
public function getSubNodeNames(): array {
return ['stmts'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Finally';
}
}

View File

@@ -4,26 +4,30 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class For_ extends Node\Stmt
{
class For_ extends Node\Stmt {
/** @var Node\Expr[] Init expressions */
public $init;
public array $init;
/** @var Node\Expr[] Loop conditions */
public $cond;
public array $cond;
/** @var Node\Expr[] Loop expressions */
public $loop;
public array $loop;
/** @var Node\Stmt[] Statements */
public $stmts;
public array $stmts;
/**
* Constructs a for loop node.
*
* @param array $subNodes Array of the following optional subnodes:
* 'init' => array(): Init expressions
* 'cond' => array(): Loop conditions
* 'loop' => array(): Loop expressions
* 'stmts' => array(): Statements
* @param array $attributes Additional attributes
* @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;
@@ -33,11 +37,11 @@ class For_ extends Node\Stmt
$this->stmts = $subNodes['stmts'] ?? [];
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['init', 'cond', 'loop', 'stmts'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_For';
}
}

View File

@@ -4,29 +4,32 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class Foreach_ extends Node\Stmt
{
class Foreach_ extends Node\Stmt {
/** @var Node\Expr Expression to iterate */
public $expr;
public Node\Expr $expr;
/** @var null|Node\Expr Variable to assign key to */
public $keyVar;
public ?Node\Expr $keyVar;
/** @var bool Whether to assign value by reference */
public $byRef;
public bool $byRef;
/** @var Node\Expr Variable to assign value to */
public $valueVar;
public Node\Expr $valueVar;
/** @var Node\Stmt[] Statements */
public $stmts;
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 $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 $attributes Additional attributes
* @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;
@@ -37,11 +40,11 @@ class Foreach_ extends Node\Stmt
$this->stmts = $subNodes['stmts'] ?? [];
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['expr', 'keyVar', 'byRef', 'valueVar', 'stmts'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Foreach';
}
}

View File

@@ -5,56 +5,60 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
use PhpParser\Node\FunctionLike;
class Function_ extends Node\Stmt implements FunctionLike
{
class Function_ extends Node\Stmt implements FunctionLike {
/** @var bool Whether function returns by reference */
public $byRef;
public bool $byRef;
/** @var Node\Identifier Name */
public $name;
public Node\Identifier $name;
/** @var Node\Param[] Parameters */
public $params;
public array $params;
/** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */
public $returnType;
public ?Node $returnType;
/** @var Node\Stmt[] Statements */
public $stmts;
public array $stmts;
/** @var Node\AttributeGroup[] PHP attribute groups */
public $attrGroups;
public array $attrGroups;
/** @var Node\Name Namespaced name (if using NameResolver) */
public $namespacedName;
/** @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 $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 $attributes Additional attributes
* @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'] ?? [];
$returnType = $subNodes['returnType'] ?? null;
$this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType;
$this->returnType = $subNodes['returnType'] ?? null;
$this->stmts = $subNodes['stmts'] ?? [];
$this->attrGroups = $subNodes['attrGroups'] ?? [];
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['attrGroups', 'byRef', 'name', 'params', 'returnType', 'stmts'];
}
public function returnsByRef() : bool {
public function returnsByRef(): bool {
return $this->byRef;
}
public function getParams() : array {
public function getParams(): array {
return $this->params;
}
@@ -62,16 +66,16 @@ class Function_ extends Node\Stmt implements FunctionLike
return $this->returnType;
}
public function getAttrGroups() : array {
public function getAttrGroups(): array {
return $this->attrGroups;
}
/** @return Node\Stmt[] */
public function getStmts() : array {
public function getStmts(): array {
return $this->stmts;
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Function';
}
}

View File

@@ -4,27 +4,26 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class Global_ extends Node\Stmt
{
class Global_ extends Node\Stmt {
/** @var Node\Expr[] Variables */
public $vars;
public array $vars;
/**
* Constructs a global variables list node.
*
* @param Node\Expr[] $vars Variables to unset
* @param array $attributes Additional attributes
* @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 {
public function getSubNodeNames(): array {
return ['vars'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Global';
}
}

View File

@@ -5,27 +5,26 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node\Identifier;
use PhpParser\Node\Stmt;
class Goto_ extends Stmt
{
class Goto_ extends Stmt {
/** @var Identifier Name of label to jump to */
public $name;
public Identifier $name;
/**
* Constructs a goto node.
*
* @param string|Identifier $name Name of label to jump to
* @param array $attributes Additional attributes
* @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 {
public function getSubNodeNames(): array {
return ['name'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Goto';
}
}

View File

@@ -4,23 +4,25 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt;
use PhpParser\Node\UseItem;
class GroupUse extends Stmt
{
/** @var int Type of group use */
public $type;
class GroupUse extends Stmt {
/**
* @var Use_::TYPE_* Type of group use
*/
public int $type;
/** @var Name Prefix for uses */
public $prefix;
/** @var UseUse[] Uses */
public $uses;
public Name $prefix;
/** @var UseItem[] Uses */
public array $uses;
/**
* Constructs a group use node.
*
* @param Name $prefix Prefix for uses
* @param UseUse[] $uses Uses
* @param int $type Type of group use
* @param array $attributes Additional attributes
* @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;
@@ -29,11 +31,11 @@ class GroupUse extends Stmt
$this->uses = $uses;
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['type', 'prefix', 'uses'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_GroupUse';
}
}

View File

@@ -4,27 +4,26 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node\Stmt;
class HaltCompiler extends Stmt
{
class HaltCompiler extends Stmt {
/** @var string Remaining text after halt compiler statement. */
public $remaining;
public string $remaining;
/**
* Constructs a __halt_compiler node.
*
* @param string $remaining Remaining text after halt compiler statement.
* @param array $attributes Additional attributes
* @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 {
public function getSubNodeNames(): array {
return ['remaining'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_HaltCompiler';
}
}

View File

@@ -4,26 +4,29 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class If_ extends Node\Stmt
{
class If_ extends Node\Stmt {
/** @var Node\Expr Condition expression */
public $cond;
public Node\Expr $cond;
/** @var Node\Stmt[] Statements */
public $stmts;
public array $stmts;
/** @var ElseIf_[] Elseif clauses */
public $elseifs;
public array $elseifs;
/** @var null|Else_ Else clause */
public $else;
public ?Else_ $else;
/**
* Constructs an if node.
*
* @param Node\Expr $cond Condition
* @param array $subNodes Array of the following optional subnodes:
* 'stmts' => array(): Statements
* 'elseifs' => array(): Elseif clauses
* 'else' => null : Else clause
* @param array $attributes Additional attributes
* @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;
@@ -33,11 +36,11 @@ class If_ extends Node\Stmt
$this->else = $subNodes['else'] ?? null;
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['cond', 'stmts', 'elseifs', 'else'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_If';
}
}

View File

@@ -4,27 +4,26 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node\Stmt;
class InlineHTML extends Stmt
{
class InlineHTML extends Stmt {
/** @var string String */
public $value;
public string $value;
/**
* Constructs an inline HTML node.
*
* @param string $value String
* @param array $attributes Additional attributes
* @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 {
public function getSubNodeNames(): array {
return ['value'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_InlineHTML';
}
}

View File

@@ -4,20 +4,23 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class Interface_ extends ClassLike
{
class Interface_ extends ClassLike {
/** @var Node\Name[] Extended interfaces */
public $extends;
public array $extends;
/**
* Constructs a class node.
*
* @param string|Node\Identifier $name Name
* @param array $subNodes Array of the following optional subnodes:
* 'extends' => array(): Name of extended interfaces
* 'stmts' => array(): Statements
* 'attrGroups' => array(): PHP attribute groups
* @param array $attributes Additional attributes
* @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;
@@ -27,11 +30,11 @@ class Interface_ extends ClassLike
$this->attrGroups = $subNodes['attrGroups'] ?? [];
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['attrGroups', 'name', 'extends', 'stmts'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Interface';
}
}

View File

@@ -5,27 +5,26 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node\Identifier;
use PhpParser\Node\Stmt;
class Label extends Stmt
{
class Label extends Stmt {
/** @var Identifier Name */
public $name;
public Identifier $name;
/**
* Constructs a label node.
*
* @param string|Identifier $name Name
* @param array $attributes Additional attributes
* @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 {
public function getSubNodeNames(): array {
return ['name'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Label';
}
}

View File

@@ -4,35 +4,34 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class Namespace_ extends Node\Stmt
{
class Namespace_ extends Node\Stmt {
/* For use in the "kind" attribute */
const KIND_SEMICOLON = 1;
const KIND_BRACED = 2;
public const KIND_SEMICOLON = 1;
public const KIND_BRACED = 2;
/** @var null|Node\Name Name */
public $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 $attributes Additional attributes
* @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, $stmts = [], array $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 {
public function getSubNodeNames(): array {
return ['name', 'stmts'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Namespace';
}
}

View File

@@ -5,13 +5,12 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
/** Nop/empty statement (;). */
class Nop extends Node\Stmt
{
public function getSubNodeNames() : array {
class Nop extends Node\Stmt {
public function getSubNodeNames(): array {
return [];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Nop';
}
}

View File

@@ -2,90 +2,81 @@
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
{
class Property extends Node\Stmt {
/** @var int Modifiers */
public $flags;
/** @var PropertyProperty[] Properties */
public $props;
public int $flags;
/** @var PropertyItem[] Properties */
public array $props;
/** @var null|Identifier|Name|ComplexType Type declaration */
public $type;
public ?Node $type;
/** @var Node\AttributeGroup[] PHP attribute groups */
public $attrGroups;
public array $attrGroups;
/**
* Constructs a class property list node.
*
* @param int $flags Modifiers
* @param PropertyProperty[] $props Properties
* @param array $attributes Additional attributes
* @param null|string|Identifier|Name|ComplexType $type Type declaration
* @param Node\AttributeGroup[] $attrGroups PHP attribute groups
* @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 = [], $type = null, array $attrGroups = []) {
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 = \is_string($type) ? new Identifier($type) : $type;
$this->type = $type;
$this->attrGroups = $attrGroups;
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['attrGroups', 'flags', 'type', 'props'];
}
/**
* Whether the property is explicitly or implicitly public.
*
* @return bool
*/
public function isPublic() : bool {
return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0
|| ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0;
public function isPublic(): bool {
return ($this->flags & Modifiers::PUBLIC) !== 0
|| ($this->flags & Modifiers::VISIBILITY_MASK) === 0;
}
/**
* Whether the property is protected.
*
* @return bool
*/
public function isProtected() : bool {
return (bool) ($this->flags & Class_::MODIFIER_PROTECTED);
public function isProtected(): bool {
return (bool) ($this->flags & Modifiers::PROTECTED);
}
/**
* Whether the property is private.
*
* @return bool
*/
public function isPrivate() : bool {
return (bool) ($this->flags & Class_::MODIFIER_PRIVATE);
public function isPrivate(): bool {
return (bool) ($this->flags & Modifiers::PRIVATE);
}
/**
* Whether the property is static.
*
* @return bool
*/
public function isStatic() : bool {
return (bool) ($this->flags & Class_::MODIFIER_STATIC);
public function isStatic(): bool {
return (bool) ($this->flags & Modifiers::STATIC);
}
/**
* Whether the property is readonly.
*
* @return bool
*/
public function isReadonly() : bool {
return (bool) ($this->flags & Class_::MODIFIER_READONLY);
public function isReadonly(): bool {
return (bool) ($this->flags & Modifiers::READONLY);
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Property';
}
}

View File

@@ -1,34 +1,3 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class PropertyProperty extends Node\Stmt
{
/** @var Node\VarLikeIdentifier Name */
public $name;
/** @var null|Node\Expr Default */
public $default;
/**
* Constructs a class property node.
*
* @param string|Node\VarLikeIdentifier $name Name
* @param null|Node\Expr $default Default value
* @param array $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 'Stmt_PropertyProperty';
}
}
require __DIR__ . '/../PropertyItem.php';

View File

@@ -4,27 +4,26 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class Return_ extends Node\Stmt
{
class Return_ extends Node\Stmt {
/** @var null|Node\Expr Expression */
public $expr;
public ?Node\Expr $expr;
/**
* Constructs a return node.
*
* @param null|Node\Expr $expr Expression
* @param array $attributes Additional attributes
* @param null|Node\Expr $expr Expression
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Node\Expr $expr = null, array $attributes = []) {
public function __construct(?Node\Expr $expr = null, array $attributes = []) {
$this->attributes = $attributes;
$this->expr = $expr;
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['expr'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Return';
}
}

View File

@@ -1,37 +1,3 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Stmt;
use PhpParser\Node;
use PhpParser\Node\Expr;
class StaticVar extends Node\Stmt
{
/** @var Expr\Variable Variable */
public $var;
/** @var null|Node\Expr Default value */
public $default;
/**
* Constructs a static variable node.
*
* @param Expr\Variable $var Name
* @param null|Node\Expr $default Default value
* @param array $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 'Stmt_StaticVar';
}
}
require __DIR__ . '/../StaticVar.php';

View File

@@ -2,29 +2,29 @@
namespace PhpParser\Node\Stmt;
use PhpParser\Node\StaticVar;
use PhpParser\Node\Stmt;
class Static_ extends Stmt
{
class Static_ extends Stmt {
/** @var StaticVar[] Variable definitions */
public $vars;
public array $vars;
/**
* Constructs a static variables list node.
*
* @param StaticVar[] $vars Variable definitions
* @param array $attributes Additional attributes
* @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 {
public function getSubNodeNames(): array {
return ['vars'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Static';
}
}

View File

@@ -4,19 +4,18 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class Switch_ extends Node\Stmt
{
class Switch_ extends Node\Stmt {
/** @var Node\Expr Condition */
public $cond;
public Node\Expr $cond;
/** @var Case_[] Case list */
public $cases;
public array $cases;
/**
* Constructs a case node.
*
* @param Node\Expr $cond Condition
* @param Case_[] $cases Case list
* @param array $attributes Additional attributes
* @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;
@@ -24,11 +23,11 @@ class Switch_ extends Node\Stmt
$this->cases = $cases;
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['cond', 'cases'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Switch';
}
}

View File

@@ -1,30 +0,0 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class Throw_ extends Node\Stmt
{
/** @var Node\Expr Expression */
public $expr;
/**
* Constructs a legacy throw statement node.
*
* @param Node\Expr $expr Expression
* @param array $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_Throw';
}
}

View File

@@ -4,19 +4,18 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class TraitUse extends Node\Stmt
{
class TraitUse extends Node\Stmt {
/** @var Node\Name[] Traits */
public $traits;
public array $traits;
/** @var TraitUseAdaptation[] Adaptations */
public $adaptations;
public array $adaptations;
/**
* Constructs a trait use node.
*
* @param Node\Name[] $traits Traits
* @param Node\Name[] $traits Traits
* @param TraitUseAdaptation[] $adaptations Adaptations
* @param array $attributes Additional attributes
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(array $traits, array $adaptations = [], array $attributes = []) {
$this->attributes = $attributes;
@@ -24,11 +23,11 @@ class TraitUse extends Node\Stmt
$this->adaptations = $adaptations;
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['traits', 'adaptations'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_TraitUse';
}
}

View File

@@ -4,10 +4,9 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
abstract class TraitUseAdaptation extends Node\Stmt
{
abstract class TraitUseAdaptation extends Node\Stmt {
/** @var Node\Name|null Trait name */
public $trait;
public ?Node\Name $trait;
/** @var Node\Identifier Method name */
public $method;
public Node\Identifier $method;
}

View File

@@ -4,23 +4,22 @@ namespace PhpParser\Node\Stmt\TraitUseAdaptation;
use PhpParser\Node;
class Alias extends Node\Stmt\TraitUseAdaptation
{
class Alias extends Node\Stmt\TraitUseAdaptation {
/** @var null|int New modifier */
public $newModifier;
public ?int $newModifier;
/** @var null|Node\Identifier New name */
public $newName;
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 $attributes Additional attributes
* @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($trait, $method, $newModifier, $newName, array $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;
@@ -28,11 +27,11 @@ class Alias extends Node\Stmt\TraitUseAdaptation
$this->newName = \is_string($newName) ? new Node\Identifier($newName) : $newName;
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['trait', 'method', 'newModifier', 'newName'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_TraitUseAdaptation_Alias';
}
}

View File

@@ -4,18 +4,17 @@ namespace PhpParser\Node\Stmt\TraitUseAdaptation;
use PhpParser\Node;
class Precedence extends Node\Stmt\TraitUseAdaptation
{
class Precedence extends Node\Stmt\TraitUseAdaptation {
/** @var Node\Name[] Overwritten traits */
public $insteadof;
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 $attributes Additional attributes
* @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;
@@ -24,11 +23,11 @@ class Precedence extends Node\Stmt\TraitUseAdaptation
$this->insteadof = $insteadof;
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['trait', 'method', 'insteadof'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_TraitUseAdaptation_Precedence';
}
}

View File

@@ -4,16 +4,18 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class Trait_ extends ClassLike
{
class Trait_ extends ClassLike {
/**
* Constructs a trait node.
*
* @param string|Node\Identifier $name Name
* @param array $subNodes Array of the following optional subnodes:
* 'stmts' => array(): Statements
* 'attrGroups' => array(): PHP attribute groups
* @param array $attributes Additional attributes
* @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;
@@ -22,11 +24,11 @@ class Trait_ extends ClassLike
$this->attrGroups = $subNodes['attrGroups'] ?? [];
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['attrGroups', 'name', 'stmts'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Trait';
}
}

View File

@@ -4,35 +4,34 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class TryCatch extends Node\Stmt
{
class TryCatch extends Node\Stmt {
/** @var Node\Stmt[] Statements */
public $stmts;
public array $stmts;
/** @var Catch_[] Catches */
public $catches;
public array $catches;
/** @var null|Finally_ Optional finally node */
public $finally;
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 $attributes Additional attributes
* @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 = []) {
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 {
public function getSubNodeNames(): array {
return ['stmts', 'catches', 'finally'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_TryCatch';
}
}

View File

@@ -4,27 +4,26 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class Unset_ extends Node\Stmt
{
class Unset_ extends Node\Stmt {
/** @var Node\Expr[] Variables to unset */
public $vars;
public array $vars;
/**
* Constructs an unset node.
*
* @param Node\Expr[] $vars Variables to unset
* @param array $attributes Additional attributes
* @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 {
public function getSubNodeNames(): array {
return ['vars'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Unset';
}
}

View File

@@ -1,52 +1,3 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Stmt;
use PhpParser\Node;
use PhpParser\Node\Identifier;
class UseUse extends Node\Stmt
{
/** @var int One of the Stmt\Use_::TYPE_* constants. Will only differ from TYPE_UNKNOWN for mixed group uses */
public $type;
/** @var Node\Name Namespace, class, function or constant to alias */
public $name;
/** @var Identifier|null Alias */
public $alias;
/**
* Constructs an alias (use) node.
*
* @param Node\Name $name Namespace/Class to alias
* @param null|string|Identifier $alias Alias
* @param int $type Type of the use element (for mixed group use only)
* @param array $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.
*
* @return Identifier
*/
public function getAlias() : Identifier {
if (null !== $this->alias) {
return $this->alias;
}
return new Identifier($this->name->getLast());
}
public function getType() : string {
return 'Stmt_UseUse';
}
}
require __DIR__ . '/../UseItem.php';

View File

@@ -3,33 +3,33 @@
namespace PhpParser\Node\Stmt;
use PhpParser\Node\Stmt;
use PhpParser\Node\UseItem;
class Use_ extends Stmt
{
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.
*/
const TYPE_UNKNOWN = 0;
public const TYPE_UNKNOWN = 0;
/** Class or namespace import */
const TYPE_NORMAL = 1;
public const TYPE_NORMAL = 1;
/** Function import */
const TYPE_FUNCTION = 2;
public const TYPE_FUNCTION = 2;
/** Constant import */
const TYPE_CONSTANT = 3;
public const TYPE_CONSTANT = 3;
/** @var int Type of alias */
public $type;
/** @var UseUse[] Aliases */
public $uses;
/** @var self::TYPE_* Type of alias */
public int $type;
/** @var UseItem[] Aliases */
public array $uses;
/**
* Constructs an alias (use) list node.
*
* @param UseUse[] $uses Aliases
* @param int $type Type of alias
* @param array $attributes Additional attributes
* @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;
@@ -37,11 +37,11 @@ class Use_ extends Stmt
$this->uses = $uses;
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['type', 'uses'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_Use';
}
}

View File

@@ -4,19 +4,18 @@ namespace PhpParser\Node\Stmt;
use PhpParser\Node;
class While_ extends Node\Stmt
{
class While_ extends Node\Stmt {
/** @var Node\Expr Condition */
public $cond;
public Node\Expr $cond;
/** @var Node\Stmt[] Statements */
public $stmts;
public array $stmts;
/**
* Constructs a while node.
*
* @param Node\Expr $cond Condition
* @param Node\Stmt[] $stmts Statements
* @param array $attributes Additional attributes
* @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;
@@ -24,11 +23,11 @@ class While_ extends Node\Stmt
$this->stmts = $stmts;
}
public function getSubNodeNames() : array {
public function getSubNodeNames(): array {
return ['cond', 'stmts'];
}
public function getType() : string {
public function getType(): string {
return 'Stmt_While';
}
}