updated-packages
This commit is contained in:
@@ -16,7 +16,7 @@ class Break_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $num = null, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->num = $num;
|
||||
}
|
||||
|
||||
|
@@ -6,7 +6,7 @@ use PhpParser\Node;
|
||||
|
||||
class Case_ extends Node\Stmt
|
||||
{
|
||||
/** @var null|Node\Expr $cond Condition (null for default) */
|
||||
/** @var null|Node\Expr Condition (null for default) */
|
||||
public $cond;
|
||||
/** @var Node\Stmt[] Statements */
|
||||
public $stmts;
|
||||
@@ -19,7 +19,7 @@ class Case_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($cond, array $stmts = [], array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->cond = $cond;
|
||||
$this->stmts = $stmts;
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ class Catch_ extends Node\Stmt
|
||||
{
|
||||
/** @var Node\Name[] Types of exceptions to catch */
|
||||
public $types;
|
||||
/** @var Expr\Variable Variable for exception */
|
||||
/** @var Expr\Variable|null Variable for exception */
|
||||
public $var;
|
||||
/** @var Node\Stmt[] Statements */
|
||||
public $stmts;
|
||||
@@ -17,15 +17,15 @@ class Catch_ extends Node\Stmt
|
||||
/**
|
||||
* Constructs a catch node.
|
||||
*
|
||||
* @param Node\Name[] $types Types of exceptions to catch
|
||||
* @param Expr\Variable $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 $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(
|
||||
array $types, Expr\Variable $var, array $stmts = [], array $attributes = []
|
||||
array $types, Expr\Variable $var = null, array $stmts = [], array $attributes = []
|
||||
) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->types = $types;
|
||||
$this->var = $var;
|
||||
$this->stmts = $stmts;
|
||||
@@ -34,7 +34,7 @@ class Catch_ extends Node\Stmt
|
||||
public function getSubNodeNames() : array {
|
||||
return ['types', 'var', 'stmts'];
|
||||
}
|
||||
|
||||
|
||||
public function getType() : string {
|
||||
return 'Stmt_Catch';
|
||||
}
|
||||
|
@@ -10,22 +10,31 @@ class ClassConst extends Node\Stmt
|
||||
public $flags;
|
||||
/** @var Node\Const_[] Constant declarations */
|
||||
public $consts;
|
||||
/** @var Node\AttributeGroup[] */
|
||||
public $attrGroups;
|
||||
|
||||
/**
|
||||
* Constructs a class const list node.
|
||||
*
|
||||
* @param Node\Const_[] $consts Constant declarations
|
||||
* @param int $flags Modifiers
|
||||
* @param array $attributes Additional attributes
|
||||
* @param Node\Const_[] $consts Constant declarations
|
||||
* @param int $flags Modifiers
|
||||
* @param array $attributes Additional attributes
|
||||
* @param Node\AttributeGroup[] $attrGroups PHP attribute groups
|
||||
*/
|
||||
public function __construct(array $consts, int $flags = 0, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
public function __construct(
|
||||
array $consts,
|
||||
int $flags = 0,
|
||||
array $attributes = [],
|
||||
array $attrGroups = []
|
||||
) {
|
||||
$this->attributes = $attributes;
|
||||
$this->flags = $flags;
|
||||
$this->consts = $consts;
|
||||
$this->attrGroups = $attrGroups;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
return ['flags', 'consts'];
|
||||
return ['attrGroups', 'flags', 'consts'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,7 +64,16 @@ class ClassConst extends Node\Stmt
|
||||
public function isPrivate() : bool {
|
||||
return (bool) ($this->flags & Class_::MODIFIER_PRIVATE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whether constant is final.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isFinal() : bool {
|
||||
return (bool) ($this->flags & Class_::MODIFIER_FINAL);
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
return 'Stmt_ClassConst';
|
||||
}
|
||||
|
@@ -4,15 +4,76 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property Node\Name $namespacedName Namespaced name (if using NameResolver)
|
||||
*/
|
||||
abstract class ClassLike extends Node\Stmt
|
||||
{
|
||||
/** @var Node\Identifier|null Name */
|
||||
public $name;
|
||||
/** @var Node\Stmt[] Statements */
|
||||
public $stmts;
|
||||
/** @var Node\AttributeGroup[] PHP attribute groups */
|
||||
public $attrGroups;
|
||||
|
||||
/** @var Node\Name|null Namespaced name (if using NameResolver) */
|
||||
public $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) {
|
||||
foreach ($this->stmts as $stmt) {
|
||||
if ($stmt instanceof Property) {
|
||||
foreach ($stmt->props as $prop) {
|
||||
if ($prop instanceof PropertyProperty && $name === $prop->name->toString()) {
|
||||
return $stmt;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all methods defined directly in this class/interface/trait
|
||||
|
@@ -15,27 +15,31 @@ class ClassMethod extends Node\Stmt implements FunctionLike
|
||||
public $name;
|
||||
/** @var Node\Param[] Parameters */
|
||||
public $params;
|
||||
/** @var null|Node\Identifier|Node\Name|Node\NullableType Return type */
|
||||
/** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */
|
||||
public $returnType;
|
||||
/** @var Node\Stmt[]|null Statements */
|
||||
public $stmts;
|
||||
/** @var Node\AttributeGroup[] PHP attribute groups */
|
||||
public $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,
|
||||
'__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,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -48,10 +52,11 @@ class ClassMethod extends Node\Stmt implements FunctionLike
|
||||
* 'params' => array() : Parameters
|
||||
* 'returnType' => null : Return type
|
||||
* 'stmts' => array() : Statements
|
||||
* 'attrGroups' => array() : PHP attribute groups
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, array $subNodes = [], array $attributes = []) {
|
||||
parent::__construct($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;
|
||||
@@ -59,10 +64,11 @@ class ClassMethod extends Node\Stmt implements FunctionLike
|
||||
$returnType = $subNodes['returnType'] ?? null;
|
||||
$this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType;
|
||||
$this->stmts = array_key_exists('stmts', $subNodes) ? $subNodes['stmts'] : [];
|
||||
$this->attrGroups = $subNodes['attrGroups'] ?? [];
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
return ['flags', 'byRef', 'name', 'params', 'returnType', 'stmts'];
|
||||
return ['attrGroups', 'flags', 'byRef', 'name', 'params', 'returnType', 'stmts'];
|
||||
}
|
||||
|
||||
public function returnsByRef() : bool {
|
||||
@@ -81,6 +87,10 @@ class ClassMethod extends Node\Stmt implements FunctionLike
|
||||
return $this->stmts;
|
||||
}
|
||||
|
||||
public function getAttrGroups() : array {
|
||||
return $this->attrGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the method is explicitly or implicitly public.
|
||||
*
|
||||
@@ -120,7 +130,7 @@ class ClassMethod extends Node\Stmt implements FunctionLike
|
||||
|
||||
/**
|
||||
* Whether the method is final.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isFinal() : bool {
|
||||
@@ -144,7 +154,7 @@ class ClassMethod extends Node\Stmt implements FunctionLike
|
||||
public function isMagic() : bool {
|
||||
return isset(self::$magicNames[$this->name->toLowerString()]);
|
||||
}
|
||||
|
||||
|
||||
public function getType() : string {
|
||||
return 'Stmt_ClassMethod';
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ class Class_ extends ClassLike
|
||||
const MODIFIER_STATIC = 8;
|
||||
const MODIFIER_ABSTRACT = 16;
|
||||
const MODIFIER_FINAL = 32;
|
||||
const MODIFIER_READONLY = 64;
|
||||
|
||||
const VISIBILITY_MODIFIER_MASK = 7; // 1 | 2 | 4
|
||||
|
||||
@@ -28,23 +29,25 @@ class Class_ extends ClassLike
|
||||
*
|
||||
* @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
|
||||
* '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
|
||||
*/
|
||||
public function __construct($name, array $subNodes = [], array $attributes = []) {
|
||||
parent::__construct($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 ['flags', 'name', 'extends', 'implements', 'stmts'];
|
||||
return ['attrGroups', 'flags', 'name', 'extends', 'implements', 'stmts'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,6 +68,10 @@ class Class_ extends ClassLike
|
||||
return (bool) ($this->flags & self::MODIFIER_FINAL);
|
||||
}
|
||||
|
||||
public function isReadonly() : bool {
|
||||
return (bool) ($this->flags & self::MODIFIER_READONLY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the class is anonymous.
|
||||
*
|
||||
@@ -74,6 +81,27 @@ class Class_ extends ClassLike
|
||||
return null === $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public static function verifyClassModifier($a, $b) {
|
||||
if ($a & self::MODIFIER_ABSTRACT && $b & self::MODIFIER_ABSTRACT) {
|
||||
throw new Error('Multiple abstract 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');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
@@ -94,11 +122,15 @@ class Class_ extends ClassLike
|
||||
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 {
|
||||
return 'Stmt_Class';
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ class Const_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $consts, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->consts = $consts;
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,7 @@ class Continue_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $num = null, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->num = $num;
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,7 @@ class DeclareDeclare extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($key, Node\Expr $value, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->key = \is_string($key) ? new Node\Identifier($key) : $key;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ class Declare_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $declares, array $stmts = null, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->declares = $declares;
|
||||
$this->stmts = $stmts;
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ class Do_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $cond, array $stmts = [], array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->cond = $cond;
|
||||
$this->stmts = $stmts;
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ class Echo_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $exprs, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->exprs = $exprs;
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,7 @@ class ElseIf_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $cond, array $stmts = [], array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->cond = $cond;
|
||||
$this->stmts = $stmts;
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ class Else_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $stmts = [], array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->stmts = $stmts;
|
||||
}
|
||||
|
||||
|
37
vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/EnumCase.php
vendored
Normal file
37
vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/EnumCase.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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 $name;
|
||||
/** @var Node\Expr|null Enum case expression */
|
||||
public $expr;
|
||||
/** @var Node\AttributeGroup[] PHP attribute groups */
|
||||
public $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
|
||||
*/
|
||||
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';
|
||||
}
|
||||
}
|
40
vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Enum_.php
vendored
Normal file
40
vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Enum_.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
class Enum_ extends ClassLike
|
||||
{
|
||||
/** @var null|Node\Identifier Scalar Type */
|
||||
public $scalarType;
|
||||
/** @var Node\Name[] Names of implemented interfaces */
|
||||
public $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
|
||||
*/
|
||||
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';
|
||||
}
|
||||
}
|
@@ -19,7 +19,7 @@ class Expression extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $expr, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->expr = $expr;
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,7 @@ class Finally_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $stmts = [], array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->stmts = $stmts;
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,7 @@ class For_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $subNodes = [], array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->init = $subNodes['init'] ?? [];
|
||||
$this->cond = $subNodes['cond'] ?? [];
|
||||
$this->loop = $subNodes['loop'] ?? [];
|
||||
|
@@ -29,7 +29,7 @@ class Foreach_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $expr, Node\Expr $valueVar, array $subNodes = [], array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->expr = $expr;
|
||||
$this->keyVar = $subNodes['keyVar'] ?? null;
|
||||
$this->byRef = $subNodes['byRef'] ?? false;
|
||||
|
@@ -5,9 +5,6 @@ namespace PhpParser\Node\Stmt;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\FunctionLike;
|
||||
|
||||
/**
|
||||
* @property Node\Name $namespacedName Namespaced name (if using NameResolver)
|
||||
*/
|
||||
class Function_ extends Node\Stmt implements FunctionLike
|
||||
{
|
||||
/** @var bool Whether function returns by reference */
|
||||
@@ -16,10 +13,15 @@ class Function_ extends Node\Stmt implements FunctionLike
|
||||
public $name;
|
||||
/** @var Node\Param[] Parameters */
|
||||
public $params;
|
||||
/** @var null|Node\Identifier|Node\Name|Node\NullableType Return type */
|
||||
/** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */
|
||||
public $returnType;
|
||||
/** @var Node\Stmt[] Statements */
|
||||
public $stmts;
|
||||
/** @var Node\AttributeGroup[] PHP attribute groups */
|
||||
public $attrGroups;
|
||||
|
||||
/** @var Node\Name|null Namespaced name (if using NameResolver) */
|
||||
public $namespacedName;
|
||||
|
||||
/**
|
||||
* Constructs a function node.
|
||||
@@ -30,20 +32,22 @@ class Function_ extends Node\Stmt implements FunctionLike
|
||||
* 'params' => array(): Parameters
|
||||
* 'returnType' => null : Return type
|
||||
* 'stmts' => array(): Statements
|
||||
* 'attrGroups' => array(): PHP attribute groups
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, array $subNodes = [], array $attributes = []) {
|
||||
parent::__construct($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->stmts = $subNodes['stmts'] ?? [];
|
||||
$this->attrGroups = $subNodes['attrGroups'] ?? [];
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
return ['byRef', 'name', 'params', 'returnType', 'stmts'];
|
||||
return ['attrGroups', 'byRef', 'name', 'params', 'returnType', 'stmts'];
|
||||
}
|
||||
|
||||
public function returnsByRef() : bool {
|
||||
@@ -58,11 +62,15 @@ class Function_ extends Node\Stmt implements FunctionLike
|
||||
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';
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ class Global_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $vars, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->vars = $vars;
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,7 @@ class Goto_ extends Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->name = \is_string($name) ? new Identifier($name) : $name;
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,7 @@ class GroupUse extends Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Name $prefix, array $uses, int $type = Use_::TYPE_NORMAL, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->type = $type;
|
||||
$this->prefix = $prefix;
|
||||
$this->uses = $uses;
|
||||
|
@@ -16,7 +16,7 @@ class HaltCompiler extends Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(string $remaining, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->remaining = $remaining;
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,7 @@ class If_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $cond, array $subNodes = [], array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->cond = $cond;
|
||||
$this->stmts = $subNodes['stmts'] ?? [];
|
||||
$this->elseifs = $subNodes['elseifs'] ?? [];
|
||||
|
@@ -16,7 +16,7 @@ class InlineHTML extends Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(string $value, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
|
@@ -14,21 +14,23 @@ class Interface_ extends ClassLike
|
||||
*
|
||||
* @param string|Node\Identifier $name Name
|
||||
* @param array $subNodes Array of the following optional subnodes:
|
||||
* 'extends' => array(): Name of extended interfaces
|
||||
* 'stmts' => array(): Statements
|
||||
* 'extends' => array(): Name of extended interfaces
|
||||
* 'stmts' => array(): Statements
|
||||
* 'attrGroups' => array(): PHP attribute groups
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, array $subNodes = [], array $attributes = []) {
|
||||
parent::__construct($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 ['name', 'extends', 'stmts'];
|
||||
return ['attrGroups', 'name', 'extends', 'stmts'];
|
||||
}
|
||||
|
||||
|
||||
public function getType() : string {
|
||||
return 'Stmt_Interface';
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ class Label extends Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->name = \is_string($name) ? new Identifier($name) : $name;
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,7 @@ class Namespace_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Name $name = null, $stmts = [], array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->name = $name;
|
||||
$this->stmts = $stmts;
|
||||
}
|
||||
|
@@ -3,6 +3,9 @@
|
||||
namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\ComplexType;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Name;
|
||||
|
||||
class Property extends Node\Stmt
|
||||
{
|
||||
@@ -10,22 +13,30 @@ class Property extends Node\Stmt
|
||||
public $flags;
|
||||
/** @var PropertyProperty[] Properties */
|
||||
public $props;
|
||||
/** @var null|Identifier|Name|ComplexType Type declaration */
|
||||
public $type;
|
||||
/** @var Node\AttributeGroup[] PHP attribute groups */
|
||||
public $attrGroups;
|
||||
|
||||
/**
|
||||
* Constructs a class property list node.
|
||||
*
|
||||
* @param int $flags Modifiers
|
||||
* @param PropertyProperty[] $props Properties
|
||||
* @param array $attributes Additional attributes
|
||||
* @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
|
||||
*/
|
||||
public function __construct(int $flags, array $props, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
public function __construct(int $flags, array $props, array $attributes = [], $type = null, array $attrGroups = []) {
|
||||
$this->attributes = $attributes;
|
||||
$this->flags = $flags;
|
||||
$this->props = $props;
|
||||
$this->type = \is_string($type) ? new Identifier($type) : $type;
|
||||
$this->attrGroups = $attrGroups;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
return ['flags', 'props'];
|
||||
return ['attrGroups', 'flags', 'type', 'props'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,7 +75,16 @@ class Property extends Node\Stmt
|
||||
public function isStatic() : bool {
|
||||
return (bool) ($this->flags & Class_::MODIFIER_STATIC);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whether the property is readonly.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isReadonly() : bool {
|
||||
return (bool) ($this->flags & Class_::MODIFIER_READONLY);
|
||||
}
|
||||
|
||||
public function getType() : string {
|
||||
return 'Stmt_Property';
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ class PropertyProperty extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, Node\Expr $default = null, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->name = \is_string($name) ? new Node\VarLikeIdentifier($name) : $name;
|
||||
$this->default = $default;
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ class Return_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $expr = null, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->expr = $expr;
|
||||
}
|
||||
|
||||
|
@@ -22,7 +22,7 @@ class StaticVar extends Node\Stmt
|
||||
public function __construct(
|
||||
Expr\Variable $var, Node\Expr $default = null, array $attributes = []
|
||||
) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->var = $var;
|
||||
$this->default = $default;
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ class Static_ extends Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $vars, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->vars = $vars;
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,7 @@ class Switch_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $cond, array $cases, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->cond = $cond;
|
||||
$this->cases = $cases;
|
||||
}
|
||||
|
@@ -10,13 +10,13 @@ class Throw_ extends Node\Stmt
|
||||
public $expr;
|
||||
|
||||
/**
|
||||
* Constructs a throw node.
|
||||
* Constructs a legacy throw statement node.
|
||||
*
|
||||
* @param Node\Expr $expr Expression
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $expr, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->expr = $expr;
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,7 @@ class TraitUse extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $traits, array $adaptations = [], array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->traits = $traits;
|
||||
$this->adaptations = $adaptations;
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ class Alias extends Node\Stmt\TraitUseAdaptation
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($trait, $method, $newModifier, $newName, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->trait = $trait;
|
||||
$this->method = \is_string($method) ? new Node\Identifier($method) : $method;
|
||||
$this->newModifier = $newModifier;
|
||||
|
@@ -18,7 +18,7 @@ class Precedence extends Node\Stmt\TraitUseAdaptation
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Name $trait, $method, array $insteadof, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->trait = $trait;
|
||||
$this->method = \is_string($method) ? new Node\Identifier($method) : $method;
|
||||
$this->insteadof = $insteadof;
|
||||
|
@@ -11,19 +11,21 @@ class Trait_ extends ClassLike
|
||||
*
|
||||
* @param string|Node\Identifier $name Name
|
||||
* @param array $subNodes Array of the following optional subnodes:
|
||||
* 'stmts' => array(): Statements
|
||||
* 'stmts' => array(): Statements
|
||||
* 'attrGroups' => array(): PHP attribute groups
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, array $subNodes = [], array $attributes = []) {
|
||||
parent::__construct($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 ['name', 'stmts'];
|
||||
return ['attrGroups', 'name', 'stmts'];
|
||||
}
|
||||
|
||||
|
||||
public function getType() : string {
|
||||
return 'Stmt_Trait';
|
||||
}
|
||||
|
@@ -18,11 +18,11 @@ class TryCatch extends Node\Stmt
|
||||
*
|
||||
* @param Node\Stmt[] $stmts Statements
|
||||
* @param Catch_[] $catches Catches
|
||||
* @param null|Finally_ $finally Optionaly finally node
|
||||
* @param null|Finally_ $finally Optional finally node
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $stmts, array $catches, Finally_ $finally = null, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->stmts = $stmts;
|
||||
$this->catches = $catches;
|
||||
$this->finally = $finally;
|
||||
@@ -31,7 +31,7 @@ class TryCatch extends Node\Stmt
|
||||
public function getSubNodeNames() : array {
|
||||
return ['stmts', 'catches', 'finally'];
|
||||
}
|
||||
|
||||
|
||||
public function getType() : string {
|
||||
return 'Stmt_TryCatch';
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ class Unset_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $vars, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->vars = $vars;
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,7 @@ class UseUse extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Name $name, $alias = null, int $type = Use_::TYPE_UNKNOWN, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->type = $type;
|
||||
$this->name = $name;
|
||||
$this->alias = \is_string($alias) ? new Identifier($alias) : $alias;
|
||||
|
@@ -32,7 +32,7 @@ class Use_ extends Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $uses, int $type = self::TYPE_NORMAL, array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->type = $type;
|
||||
$this->uses = $uses;
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ class While_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $cond, array $stmts = [], array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->attributes = $attributes;
|
||||
$this->cond = $cond;
|
||||
$this->stmts = $stmts;
|
||||
}
|
||||
|
Reference in New Issue
Block a user