mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-01-17 15:18:17 +01:00
Use real properties for storing subnodes
Instead of storing subnodes in a subNodes dictionary, they are now stored as simple properties. This requires declarating the properties, assigning them in the constructor, overriding the getSubNodeNames() method and passing NULL to the first argument of the NodeAbstract constructor. [Deprecated: It's still possible to use the old mode of operation for custom nodes by passing an array of subnodes to the constructor.] The only behavior difference this should cause is that getSubNodeNames() will always return the original subnode names and skip any additional properties that were dynamically added. E.g. this means that the "namespacedName" node added by the NameResolver visitor is not treated as a subnode, but as a dynamic property instead. This change improves performance and memory usage.
This commit is contained in:
parent
73cace360d
commit
a2d7e8977a
@ -4,13 +4,15 @@ namespace PhpParser\Node;
|
||||
|
||||
use PhpParser\NodeAbstract;
|
||||
|
||||
/**
|
||||
* @property Expr $value Value to pass
|
||||
* @property bool $byRef Whether to pass by ref
|
||||
* @property bool $unpack Whether to unpack the argument
|
||||
*/
|
||||
class Arg extends NodeAbstract
|
||||
{
|
||||
/** @var Expr Value to pass */
|
||||
public $value;
|
||||
/** @var bool Whether to pass by ref */
|
||||
public $byRef;
|
||||
/** @var bool Whether to unpack the argument */
|
||||
public $unpack;
|
||||
|
||||
/**
|
||||
* Constructs a function call argument node.
|
||||
*
|
||||
@ -20,13 +22,13 @@ class Arg extends NodeAbstract
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $value, $byRef = false, $unpack = false, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'value' => $value,
|
||||
'byRef' => $byRef,
|
||||
'unpack' => $unpack,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->value = $value;
|
||||
$this->byRef = $byRef;
|
||||
$this->unpack = $unpack;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('value', 'byRef', 'unpack');
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,13 @@ namespace PhpParser\Node;
|
||||
|
||||
use PhpParser\NodeAbstract;
|
||||
|
||||
/**
|
||||
* @property string $name Name
|
||||
* @property Expr $value Value
|
||||
*/
|
||||
class Const_ extends NodeAbstract
|
||||
{
|
||||
/** @var string Name */
|
||||
public $name;
|
||||
/** @var Expr Value */
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* Constructs a const node for use in class const and const statements.
|
||||
*
|
||||
@ -18,12 +19,12 @@ class Const_ extends NodeAbstract
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, Expr $value, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'name' => $name,
|
||||
'value' => $value,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->name = $name;
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('name', 'value');
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,13 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $var Variable
|
||||
* @property null|Expr $dim Array index / dim
|
||||
*/
|
||||
class ArrayDimFetch extends Expr
|
||||
{
|
||||
/** @var Expr Variable */
|
||||
public $var;
|
||||
/** @var null|Expr Array index / dim */
|
||||
public $dim;
|
||||
|
||||
/**
|
||||
* Constructs an array index fetch node.
|
||||
*
|
||||
@ -18,12 +19,12 @@ class ArrayDimFetch extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $var, Expr $dim = null, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'var' => $var,
|
||||
'dim' => $dim
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->var = $var;
|
||||
$this->dim = $dim;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubnodeNames() {
|
||||
return array('var', 'dim');
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,15 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $value Value
|
||||
* @property null|Expr $key Key
|
||||
* @property bool $byRef Whether to assign by reference
|
||||
*/
|
||||
class ArrayItem extends Expr
|
||||
{
|
||||
/** @var null|Expr Key */
|
||||
public $key;
|
||||
/** @var Expr Value */
|
||||
public $value;
|
||||
/** @var bool Whether to assign by reference */
|
||||
public $byRef;
|
||||
|
||||
/**
|
||||
* Constructs an array item node.
|
||||
*
|
||||
@ -20,13 +22,13 @@ class ArrayItem extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $value, Expr $key = null, $byRef = false, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
'byRef' => $byRef
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->key = $key;
|
||||
$this->value = $value;
|
||||
$this->byRef = $byRef;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('key', 'value', 'byRef');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property ArrayItem[] $items Items
|
||||
*/
|
||||
class Array_ extends Expr
|
||||
{
|
||||
/** @var ArrayItem[] Items */
|
||||
public $items;
|
||||
|
||||
/**
|
||||
* Constructs an array node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Array_ extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $items = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'items' => $items
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->items = $items;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('items');
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,13 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $var Variable
|
||||
* @property Expr $expr Expression
|
||||
*/
|
||||
class Assign extends Expr
|
||||
{
|
||||
/** @var Expr Variable */
|
||||
public $var;
|
||||
/** @var Expr Expression */
|
||||
public $expr;
|
||||
|
||||
/**
|
||||
* Constructs an assignment node.
|
||||
*
|
||||
@ -18,12 +19,12 @@ class Assign extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $var, Expr $expr, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'var' => $var,
|
||||
'expr' => $expr
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->var = $var;
|
||||
$this->expr = $expr;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('var', 'expr');
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,11 @@ use PhpParser\Node\Expr;
|
||||
*/
|
||||
abstract class AssignOp extends Expr
|
||||
{
|
||||
/** @var Expr Variable */
|
||||
public $var;
|
||||
/** @var Expr Expression */
|
||||
public $expr;
|
||||
|
||||
/**
|
||||
* Constructs a compound assignment operation node.
|
||||
*
|
||||
@ -18,12 +23,12 @@ abstract class AssignOp extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $var, Expr $expr, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'var' => $var,
|
||||
'expr' => $expr
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->var = $var;
|
||||
$this->expr = $expr;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('var', 'expr');
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,11 @@ use PhpParser\Node\Expr;
|
||||
*/
|
||||
class AssignRef extends Expr
|
||||
{
|
||||
/** @var Expr Variable reference is assigned to */
|
||||
public $var;
|
||||
/** @var Expr Variable which is referenced */
|
||||
public $expr;
|
||||
|
||||
/**
|
||||
* Constructs an assignment node.
|
||||
*
|
||||
@ -18,12 +23,12 @@ class AssignRef extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $var, Expr $expr, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'var' => $var,
|
||||
'expr' => $expr
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->var = $var;
|
||||
$this->expr = $expr;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('var', 'expr');
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,13 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $left The left hand side expression
|
||||
* @property Expr $right The right hand side expression
|
||||
*/
|
||||
abstract class BinaryOp extends Expr
|
||||
{
|
||||
/** @var Expr The left hand side expression */
|
||||
public $left;
|
||||
/** @var Expr The right hand side expression */
|
||||
public $right;
|
||||
|
||||
/**
|
||||
* Constructs a bitwise and node.
|
||||
*
|
||||
@ -18,12 +19,12 @@ abstract class BinaryOp extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $left, Expr $right, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'left' => $left,
|
||||
'right' => $right
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->left = $left;
|
||||
$this->right = $right;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('left', 'right');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $expr Expression
|
||||
*/
|
||||
class BitwiseNot extends Expr
|
||||
{
|
||||
/** @var Expr Expression */
|
||||
public $expr;
|
||||
|
||||
/**
|
||||
* Constructs a bitwise not node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class BitwiseNot extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $expr, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'expr' => $expr
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->expr = $expr;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('expr');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $expr Expression
|
||||
*/
|
||||
class BooleanNot extends Expr
|
||||
{
|
||||
/** @var Expr Expression */
|
||||
public $expr;
|
||||
|
||||
/**
|
||||
* Constructs a boolean not node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class BooleanNot extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $expr, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'expr' => $expr
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->expr = $expr;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('expr');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $expr Expression
|
||||
*/
|
||||
abstract class Cast extends Expr
|
||||
{
|
||||
/** @var Expr Expression */
|
||||
public $expr;
|
||||
|
||||
/**
|
||||
* Constructs a cast node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ abstract class Cast extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $expr, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'expr' => $expr
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->expr = $expr;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('expr');
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,13 @@ namespace PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Name|Expr $class Class name
|
||||
* @property string $name Constant name
|
||||
*/
|
||||
class ClassConstFetch extends Expr
|
||||
{
|
||||
/** @var Name|Expr Class name */
|
||||
public $class;
|
||||
/** @var string Constant name */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* Constructs a class const fetch node.
|
||||
*
|
||||
@ -19,12 +20,12 @@ class ClassConstFetch extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($class, $name, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'class' => $class,
|
||||
'name' => $name
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->class = $class;
|
||||
$this->name = $name;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('class', 'name');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $expr Expression
|
||||
*/
|
||||
class Clone_ extends Expr
|
||||
{
|
||||
/** @var Expr Expression */
|
||||
public $expr;
|
||||
|
||||
/**
|
||||
* Constructs a clone node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Clone_ extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $expr, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'expr' => $expr
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->expr = $expr;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('expr');
|
||||
}
|
||||
}
|
||||
|
@ -5,15 +5,19 @@ namespace PhpParser\Node\Expr;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Node[] $stmts Statements
|
||||
* @property Node\Param[] $params Parameters
|
||||
* @property ClosureUse[] $uses use()s
|
||||
* @property bool $byRef Whether to return by reference
|
||||
* @property bool $static Whether the closure is static
|
||||
*/
|
||||
class Closure extends Expr
|
||||
{
|
||||
/** @var bool Whether the closure is static */
|
||||
public $static;
|
||||
/** @var bool Whether to return by reference */
|
||||
public $byRef;
|
||||
/** @var Node\Param[] Parameters */
|
||||
public $params;
|
||||
/** @var ClosureUse[] use()s */
|
||||
public $uses;
|
||||
/** @var Node[] Statements */
|
||||
public $stmts;
|
||||
|
||||
/**
|
||||
* Constructs a lambda function node.
|
||||
*
|
||||
@ -26,15 +30,15 @@ class Closure extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $subNodes = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'static' => isset($subNodes['static']) ? $subNodes['static'] : false,
|
||||
'byRef' => isset($subNodes['byRef']) ? $subNodes['byRef'] : false,
|
||||
'params' => isset($subNodes['params']) ? $subNodes['params'] : array(),
|
||||
'uses' => isset($subNodes['uses']) ? $subNodes['uses'] : array(),
|
||||
'stmts' => isset($subNodes['stmts']) ? $subNodes['stmts'] : array(),
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->static = isset($subNodes['static']) ? $subNodes['static'] : false;
|
||||
$this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false;
|
||||
$this->params = isset($subNodes['params']) ? $subNodes['params'] : array();
|
||||
$this->uses = isset($subNodes['uses']) ? $subNodes['uses'] : array();
|
||||
$this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('static', 'byRef', 'params', 'uses', 'stmts');
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,13 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property string $var Name of variable
|
||||
* @property bool $byRef Whether to use by reference
|
||||
*/
|
||||
class ClosureUse extends Expr
|
||||
{
|
||||
/** @var string Name of variable */
|
||||
public $var;
|
||||
/** @var bool Whether to use by reference */
|
||||
public $byRef;
|
||||
|
||||
/**
|
||||
* Constructs a closure use node.
|
||||
*
|
||||
@ -18,12 +19,12 @@ class ClosureUse extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($var, $byRef = false, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'var' => $var,
|
||||
'byRef' => $byRef
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->var = $var;
|
||||
$this->byRef = $byRef;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('var', 'byRef');
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ namespace PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Name $name Constant name
|
||||
*/
|
||||
class ConstFetch extends Expr
|
||||
{
|
||||
/** @var Name Constant name */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* Constructs a const fetch node.
|
||||
*
|
||||
@ -17,11 +17,11 @@ class ConstFetch extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Name $name, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'name' => $name
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->name = $name;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('name');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $expr Expression
|
||||
*/
|
||||
class Empty_ extends Expr
|
||||
{
|
||||
/** @var Expr Expression */
|
||||
public $expr;
|
||||
|
||||
/**
|
||||
* Constructs an empty() node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Empty_ extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $expr, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'expr' => $expr
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->expr = $expr;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('expr');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $expr Expression
|
||||
*/
|
||||
class ErrorSuppress extends Expr
|
||||
{
|
||||
/** @var Expr Expression */
|
||||
public $expr;
|
||||
|
||||
/**
|
||||
* Constructs an error suppress node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class ErrorSuppress extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $expr, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'expr' => $expr
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->expr = $expr;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('expr');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $expr Expression
|
||||
*/
|
||||
class Eval_ extends Expr
|
||||
{
|
||||
/** @var Expr Expression */
|
||||
public $expr;
|
||||
|
||||
/**
|
||||
* Constructs an eval() node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Eval_ extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $expr, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'expr' => $expr
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->expr = $expr;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('expr');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property null|Expr $expr Expression
|
||||
*/
|
||||
class Exit_ extends Expr
|
||||
{
|
||||
/** @var null|Expr Expression */
|
||||
public $expr;
|
||||
|
||||
/**
|
||||
* Constructs an exit() node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Exit_ extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $expr = null, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'expr' => $expr
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->expr = $expr;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('expr');
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,13 @@ namespace PhpParser\Node\Expr;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Node\Name|Expr $name Function name
|
||||
* @property Node\Arg[] $args Arguments
|
||||
*/
|
||||
class FuncCall extends Expr
|
||||
{
|
||||
/** @var Node\Name|Expr Function name */
|
||||
public $name;
|
||||
/** @var Node\Arg[] Arguments */
|
||||
public $args;
|
||||
|
||||
/**
|
||||
* Constructs a function call node.
|
||||
*
|
||||
@ -19,12 +20,12 @@ class FuncCall extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, array $args = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'name' => $name,
|
||||
'args' => $args
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->name = $name;
|
||||
$this->args = $args;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('name', 'args');
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,6 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $expr Expression
|
||||
* @property int $type Type of include
|
||||
*/
|
||||
class Include_ extends Expr
|
||||
{
|
||||
const TYPE_INCLUDE = 1;
|
||||
@ -15,6 +11,11 @@ class Include_ extends Expr
|
||||
const TYPE_REQUIRE = 3;
|
||||
const TYPE_REQUIRE_ONCE = 4;
|
||||
|
||||
/** @var Expr Expression */
|
||||
public $expr;
|
||||
/** @var int Type of include */
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* Constructs an include node.
|
||||
*
|
||||
@ -23,12 +24,12 @@ class Include_ extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $expr, $type, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'expr' => $expr,
|
||||
'type' => $type
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->expr = $expr;
|
||||
$this->type = $type;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('expr', 'type');
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,13 @@ namespace PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $expr Expression
|
||||
* @property Name|Expr $class Class name
|
||||
*/
|
||||
class Instanceof_ extends Expr
|
||||
{
|
||||
/** @var Expr Expression */
|
||||
public $expr;
|
||||
/** @var Name|Expr Class name */
|
||||
public $class;
|
||||
|
||||
/**
|
||||
* Constructs an instanceof check node.
|
||||
*
|
||||
@ -19,12 +20,12 @@ class Instanceof_ extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $expr, $class, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'expr' => $expr,
|
||||
'class' => $class
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->expr = $expr;
|
||||
$this->class = $class;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('expr', 'class');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr[] $vars Variables
|
||||
*/
|
||||
class Isset_ extends Expr
|
||||
{
|
||||
/** @var Expr[] Variables */
|
||||
public $vars;
|
||||
|
||||
/**
|
||||
* Constructs an array node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Isset_ extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $vars, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'vars' => $vars
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->vars = $vars;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('vars');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr[] $vars List of variables to assign to
|
||||
*/
|
||||
class List_ extends Expr
|
||||
{
|
||||
/** @var Expr[] List of variables to assign to */
|
||||
public $vars;
|
||||
|
||||
/**
|
||||
* Constructs a list() destructuring node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class List_ extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $vars, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'vars' => $vars,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->vars = $vars;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('vars');
|
||||
}
|
||||
}
|
||||
|
@ -5,13 +5,15 @@ namespace PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $var Variable holding object
|
||||
* @property string|Expr $name Method name
|
||||
* @property Arg[] $args Arguments
|
||||
*/
|
||||
class MethodCall extends Expr
|
||||
{
|
||||
/** @var Expr Variable holding object */
|
||||
public $var;
|
||||
/** @var string|Expr Method name */
|
||||
public $name;
|
||||
/** @var Arg[] Arguments */
|
||||
public $args;
|
||||
|
||||
/**
|
||||
* Constructs a function call node.
|
||||
*
|
||||
@ -21,13 +23,13 @@ class MethodCall extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $var, $name, array $args = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'var' => $var,
|
||||
'name' => $name,
|
||||
'args' => $args
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->var = $var;
|
||||
$this->name = $name;
|
||||
$this->args = $args;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('var', 'name', 'args');
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,13 @@ namespace PhpParser\Node\Expr;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Node\Name|Expr $class Class name
|
||||
* @property Node\Arg[] $args Arguments
|
||||
*/
|
||||
class New_ extends Expr
|
||||
{
|
||||
/** @var Node\Name|Expr Class name */
|
||||
public $class;
|
||||
/** @var Node\Arg[] Arguments */
|
||||
public $args;
|
||||
|
||||
/**
|
||||
* Constructs a function call node.
|
||||
*
|
||||
@ -19,12 +20,12 @@ class New_ extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($class, array $args = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'class' => $class,
|
||||
'args' => $args
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->class = $class;
|
||||
$this->args = $args;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('class', 'args');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $var Variable
|
||||
*/
|
||||
class PostDec extends Expr
|
||||
{
|
||||
/** @var Expr Variable */
|
||||
public $var;
|
||||
|
||||
/**
|
||||
* Constructs a post decrement node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class PostDec extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $var, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'var' => $var
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->var = $var;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('var');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $var Variable
|
||||
*/
|
||||
class PostInc extends Expr
|
||||
{
|
||||
/** @var Expr Variable */
|
||||
public $var;
|
||||
|
||||
/**
|
||||
* Constructs a post increment node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class PostInc extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $var, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'var' => $var
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->var = $var;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('var');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $var Variable
|
||||
*/
|
||||
class PreDec extends Expr
|
||||
{
|
||||
/** @var Expr Variable */
|
||||
public $var;
|
||||
|
||||
/**
|
||||
* Constructs a pre decrement node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class PreDec extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $var, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'var' => $var
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->var = $var;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('var');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $var Variable
|
||||
*/
|
||||
class PreInc extends Expr
|
||||
{
|
||||
/** @var Expr Variable */
|
||||
public $var;
|
||||
|
||||
/**
|
||||
* Constructs a pre increment node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class PreInc extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $var, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'var' => $var
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->var = $var;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('var');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $expr Expression
|
||||
*/
|
||||
class Print_ extends Expr
|
||||
{
|
||||
/** @var Expr Expression */
|
||||
public $expr;
|
||||
|
||||
/**
|
||||
* Constructs an print() node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Print_ extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $expr, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'expr' => $expr
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->expr = $expr;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('expr');
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,13 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $var Variable holding object
|
||||
* @property string|Expr $name Property Name
|
||||
*/
|
||||
class PropertyFetch extends Expr
|
||||
{
|
||||
/** @var Expr Variable holding object */
|
||||
public $var;
|
||||
/** @var string|Expr Property name */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* Constructs a function call node.
|
||||
*
|
||||
@ -18,12 +19,12 @@ class PropertyFetch extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $var, $name, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'var' => $var,
|
||||
'name' => $name
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->var = $var;
|
||||
$this->name = $name;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('var', 'name');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property array $parts Encapsed string array
|
||||
*/
|
||||
class ShellExec extends Expr
|
||||
{
|
||||
/** @var array Encapsed string array */
|
||||
public $parts;
|
||||
|
||||
/**
|
||||
* Constructs a shell exec (backtick) node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class ShellExec extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($parts, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'parts' => $parts
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->parts = $parts;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('parts');
|
||||
}
|
||||
}
|
||||
|
@ -5,13 +5,15 @@ namespace PhpParser\Node\Expr;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Node\Name|Expr $class Class name
|
||||
* @property string|Expr $name Method name
|
||||
* @property Node\Arg[] $args Arguments
|
||||
*/
|
||||
class StaticCall extends Expr
|
||||
{
|
||||
/** @var Node\Name|Expr Class name */
|
||||
public $class;
|
||||
/** @var string|Expr Method name */
|
||||
public $name;
|
||||
/** @var Node\Arg[] Arguments */
|
||||
public $args;
|
||||
|
||||
/**
|
||||
* Constructs a static method call node.
|
||||
*
|
||||
@ -21,13 +23,13 @@ class StaticCall extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($class, $name, array $args = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'class' => $class,
|
||||
'name' => $name,
|
||||
'args' => $args
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->class = $class;
|
||||
$this->name = $name;
|
||||
$this->args = $args;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('class', 'name', 'args');
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,13 @@ namespace PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Name|Expr $class Class name
|
||||
* @property string|Expr $name Property name
|
||||
*/
|
||||
class StaticPropertyFetch extends Expr
|
||||
{
|
||||
/** @var Name|Expr Class name */
|
||||
public $class;
|
||||
/** @var string|Expr Property name */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* Constructs a static property fetch node.
|
||||
*
|
||||
@ -19,12 +20,12 @@ class StaticPropertyFetch extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($class, $name, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'class' => $class,
|
||||
'name' => $name
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->class = $class;
|
||||
$this->name = $name;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('class', 'name');
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,15 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $cond Condition
|
||||
* @property null|Expr $if Expression for true
|
||||
* @property Expr $else Expression for false
|
||||
*/
|
||||
class Ternary extends Expr
|
||||
{
|
||||
/** @var Expr Condition */
|
||||
public $cond;
|
||||
/** @var null|Expr Expression for true */
|
||||
public $if;
|
||||
/** @var Expr Expression for false */
|
||||
public $else;
|
||||
|
||||
/**
|
||||
* Constructs a ternary operator node.
|
||||
*
|
||||
@ -20,13 +22,13 @@ class Ternary extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $cond, $if, Expr $else, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'cond' => $cond,
|
||||
'if' => $if,
|
||||
'else' => $else
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->cond = $cond;
|
||||
$this->if = $if;
|
||||
$this->else = $else;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('cond', 'if', 'else');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $expr Expression
|
||||
*/
|
||||
class UnaryMinus extends Expr
|
||||
{
|
||||
/** @var Expr Expression */
|
||||
public $expr;
|
||||
|
||||
/**
|
||||
* Constructs a unary minus node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class UnaryMinus extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $expr, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'expr' => $expr
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->expr = $expr;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('expr');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property Expr $expr Expression
|
||||
*/
|
||||
class UnaryPlus extends Expr
|
||||
{
|
||||
/** @var Expr Expression */
|
||||
public $expr;
|
||||
|
||||
/**
|
||||
* Constructs a unary plus node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class UnaryPlus extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $expr, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'expr' => $expr
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->expr = $expr;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('expr');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property string|Expr $name Name
|
||||
*/
|
||||
class Variable extends Expr
|
||||
{
|
||||
/** @var string|Expr Name */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* Constructs a variable node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Variable extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'name' => $name
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->name = $name;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('name');
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,13 @@ namespace PhpParser\Node\Expr;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
/**
|
||||
* @property null|Expr $value Value expression
|
||||
* @property null|Expr $key Key expression
|
||||
*/
|
||||
class Yield_ extends Expr
|
||||
{
|
||||
/** @var null|Expr Key expression */
|
||||
public $key;
|
||||
/** @var null|Expr Value expression */
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* Constructs a yield expression node.
|
||||
*
|
||||
@ -18,12 +19,12 @@ class Yield_ extends Expr
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $value = null, Expr $key = null, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->key = $key;
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('key', 'value');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node;
|
||||
|
||||
use PhpParser\NodeAbstract;
|
||||
|
||||
/**
|
||||
* @property array $parts Parts of the name
|
||||
*/
|
||||
class Name extends NodeAbstract
|
||||
{
|
||||
/** @var string[] Parts of the name */
|
||||
public $parts;
|
||||
|
||||
/**
|
||||
* Constructs a name node.
|
||||
*
|
||||
@ -20,12 +20,12 @@ class Name extends NodeAbstract
|
||||
$parts = explode('\\', $parts);
|
||||
}
|
||||
|
||||
parent::__construct(
|
||||
array(
|
||||
'parts' => $parts,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->parts = $parts;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('parts');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -169,4 +169,4 @@ class Name extends NodeAbstract
|
||||
'When changing a name you need to pass either a string, an array or a Name node'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,15 +5,19 @@ namespace PhpParser\Node;
|
||||
use PhpParser\Error;
|
||||
use PhpParser\NodeAbstract;
|
||||
|
||||
/**
|
||||
* @property null|string|Name $type Typehint
|
||||
* @property bool $byRef Whether is passed by reference
|
||||
* @property bool $variadic Whether this is a variadic argument
|
||||
* @property string $name Name
|
||||
* @property null|Expr $default Default value
|
||||
*/
|
||||
class Param extends NodeAbstract
|
||||
{
|
||||
/** @var null|string|Name Typehint */
|
||||
public $type;
|
||||
/** @var bool Whether parameter is passed by reference */
|
||||
public $byRef;
|
||||
/** @var bool Whether this is a variadic argument */
|
||||
public $variadic;
|
||||
/** @var string Name */
|
||||
public $name;
|
||||
/** @var null|Expr Default value */
|
||||
public $default;
|
||||
|
||||
/**
|
||||
* Constructs a parameter node.
|
||||
*
|
||||
@ -25,19 +29,19 @@ class Param extends NodeAbstract
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, $default = null, $type = null, $byRef = false, $variadic = false, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'type' => $type,
|
||||
'byRef' => $byRef,
|
||||
'variadic' => $variadic,
|
||||
'name' => $name,
|
||||
'default' => $default,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->type = $type;
|
||||
$this->byRef = $byRef;
|
||||
$this->variadic = $variadic;
|
||||
$this->name = $name;
|
||||
$this->default = $default;
|
||||
|
||||
if ($variadic && null !== $default) {
|
||||
throw new Error('Variadic parameter cannot have a default value');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('type', 'byRef', 'variadic', 'name', 'default');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Scalar;
|
||||
|
||||
use PhpParser\Node\Scalar;
|
||||
|
||||
/**
|
||||
* @property float $value Number value
|
||||
*/
|
||||
class DNumber extends Scalar
|
||||
{
|
||||
/** @var float Number value */
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* Constructs a float number scalar node.
|
||||
*
|
||||
@ -16,12 +16,12 @@ class DNumber extends Scalar
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($value = 0.0, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'value' => $value
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('value');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,4 +61,4 @@ class DNumber extends Scalar
|
||||
// dec
|
||||
return (float) $str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Scalar;
|
||||
|
||||
use PhpParser\Node\Scalar;
|
||||
|
||||
/**
|
||||
* @property array $parts Encaps list
|
||||
*/
|
||||
class Encapsed extends Scalar
|
||||
{
|
||||
/** @var array Encaps list */
|
||||
public $parts;
|
||||
|
||||
/**
|
||||
* Constructs an encapsed string node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Encapsed extends Scalar
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $parts = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'parts' => $parts
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->parts = $parts;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('parts');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Scalar;
|
||||
|
||||
use PhpParser\Node\Scalar;
|
||||
|
||||
/**
|
||||
* @property int $value Number value
|
||||
*/
|
||||
class LNumber extends Scalar
|
||||
{
|
||||
/** @var int Number value */
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* Constructs an integer number scalar node.
|
||||
*
|
||||
@ -16,12 +16,12 @@ class LNumber extends Scalar
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($value = 0, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'value' => $value
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('value');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,4 +58,4 @@ class LNumber extends Scalar
|
||||
// dec
|
||||
return (int) $str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,11 @@ abstract class MagicConst extends Scalar
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $attributes = array()) {
|
||||
parent::__construct(array(), $attributes);
|
||||
parent::__construct(null, $attributes);
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -21,4 +25,4 @@ abstract class MagicConst extends Scalar
|
||||
* @return string Name of magic constant
|
||||
*/
|
||||
abstract public function getName();
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Scalar;
|
||||
|
||||
use PhpParser\Node\Scalar;
|
||||
|
||||
/**
|
||||
* @property string $value String value
|
||||
*/
|
||||
class String extends Scalar
|
||||
{
|
||||
/** @var string String value */
|
||||
public $value;
|
||||
|
||||
protected static $replacements = array(
|
||||
'\\' => '\\',
|
||||
'$' => '$',
|
||||
@ -27,12 +27,12 @@ class String extends Scalar
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($value = '', array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'value' => $value
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('value');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,4 +116,4 @@ class String extends Scalar
|
||||
|
||||
return self::parseEscapeSequences($str, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property null|Node\Expr $num Number of loops to break
|
||||
*/
|
||||
class Break_ extends Node\Stmt
|
||||
{
|
||||
/** @var null|Node\Expr Number of loops to break */
|
||||
public $num;
|
||||
|
||||
/**
|
||||
* Constructs a break node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Break_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $num = null, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'num' => $num,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->num = $num;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('num');
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,13 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property null|Node\Expr $cond Condition (null for default)
|
||||
* @property Node[] $stmts Statements
|
||||
*/
|
||||
class Case_ extends Node\Stmt
|
||||
{
|
||||
/** @var null|Node\Expr $cond Condition (null for default) */
|
||||
public $cond;
|
||||
/** @var Node[] Statements */
|
||||
public $stmts;
|
||||
|
||||
/**
|
||||
* Constructs a case node.
|
||||
*
|
||||
@ -18,12 +19,12 @@ class Case_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($cond, array $stmts = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'cond' => $cond,
|
||||
'stmts' => $stmts,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->cond = $cond;
|
||||
$this->stmts = $stmts;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('cond', 'stmts');
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,15 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property Node\Name $type Class of exception
|
||||
* @property string $var Variable for exception
|
||||
* @property Node[] $stmts Statements
|
||||
*/
|
||||
class Catch_ extends Node\Stmt
|
||||
{
|
||||
/** @var Node\Name Class of exception */
|
||||
public $type;
|
||||
/** @var string Variable for exception */
|
||||
public $var;
|
||||
/** @var Node[] Statements */
|
||||
public $stmts;
|
||||
|
||||
/**
|
||||
* Constructs a catch node.
|
||||
*
|
||||
@ -20,13 +22,13 @@ class Catch_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Name $type, $var, array $stmts = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'type' => $type,
|
||||
'var' => $var,
|
||||
'stmts' => $stmts,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->type = $type;
|
||||
$this->var = $var;
|
||||
$this->stmts = $stmts;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('type', 'var', 'stmts');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property Node\Const_[] $consts Constant declarations
|
||||
*/
|
||||
class ClassConst extends Node\Stmt
|
||||
{
|
||||
/** @var Node\Const_[] Constant declarations */
|
||||
public $consts;
|
||||
|
||||
/**
|
||||
* Constructs a class const list node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class ClassConst extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $consts, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'consts' => $consts,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->consts = $consts;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('consts');
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* Class, interface or trait.
|
||||
*
|
||||
* @property string $name Name
|
||||
* @property Node[] $stmts Statements
|
||||
*/
|
||||
abstract class ClassLike extends Node\Stmt {
|
||||
/** @var string Name */
|
||||
public $name;
|
||||
/** @var Node[] Statements */
|
||||
public $stmts;
|
||||
|
||||
public function getMethods() {
|
||||
$methods = array();
|
||||
foreach ($this->stmts as $stmt) {
|
||||
|
@ -5,15 +5,18 @@ namespace PhpParser\Node\Stmt;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Error;
|
||||
|
||||
/**
|
||||
* @property int $type Type
|
||||
* @property bool $byRef Whether to return by reference
|
||||
* @property string $name Name
|
||||
* @property Node\Param[] $params Parameters
|
||||
* @property Node[] $stmts Statements
|
||||
*/
|
||||
class ClassMethod extends Node\Stmt
|
||||
{
|
||||
/** @var int Type */
|
||||
public $type;
|
||||
/** @var bool Whether to return by reference */
|
||||
public $byRef;
|
||||
/** @var string Name */
|
||||
public $name;
|
||||
/** @var Node\Param[] Parameters */
|
||||
public $params;
|
||||
/** @var Node[] Statements */
|
||||
public $stmts;
|
||||
|
||||
/**
|
||||
* Constructs a class method node.
|
||||
@ -27,18 +30,12 @@ class ClassMethod extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, array $subNodes = array(), array $attributes = array()) {
|
||||
$type = isset($subNodes['type']) ? $subNodes['type'] : 0;
|
||||
|
||||
parent::__construct(
|
||||
array(
|
||||
'type' => $type,
|
||||
'byRef' => isset($subNodes['byRef']) ? $subNodes['byRef'] : false,
|
||||
'name' => $name,
|
||||
'params' => isset($subNodes['params']) ? $subNodes['params'] : array(),
|
||||
'stmts' => array_key_exists('stmts', $subNodes) ? $subNodes['stmts'] : array(),
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->type = isset($subNodes['type']) ? $subNodes['type'] : 0;
|
||||
$this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false;
|
||||
$this->name = $name;
|
||||
$this->params = isset($subNodes['params']) ? $subNodes['params'] : array();
|
||||
$this->stmts = array_key_exists('stmts', $subNodes) ? $subNodes['stmts'] : array();
|
||||
|
||||
if ($this->type & Class_::MODIFIER_STATIC) {
|
||||
switch (strtolower($this->name)) {
|
||||
@ -52,6 +49,10 @@ class ClassMethod extends Node\Stmt
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('type', 'byRef', 'name', 'params', 'stmts');
|
||||
}
|
||||
|
||||
public function isPublic() {
|
||||
return ($this->type & Class_::MODIFIER_PUBLIC) !== 0 || $this->type === 0;
|
||||
}
|
||||
|
@ -5,13 +5,6 @@ namespace PhpParser\Node\Stmt;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Error;
|
||||
|
||||
/**
|
||||
* @property int $type Type
|
||||
* @property string $name Name
|
||||
* @property null|Node\Name $extends Name of extended class
|
||||
* @property Node\Name[] $implements Names of implemented interfaces
|
||||
* @property Node[] $stmts Statements
|
||||
*/
|
||||
class Class_ extends ClassLike
|
||||
{
|
||||
const MODIFIER_PUBLIC = 1;
|
||||
@ -23,6 +16,13 @@ class Class_ extends ClassLike
|
||||
|
||||
const VISIBILITY_MODIFER_MASK = 7; // 1 | 2 | 4
|
||||
|
||||
/** @var int Type */
|
||||
public $type;
|
||||
/** @var null|Node\Name Name of extended class */
|
||||
public $extends;
|
||||
/** @var Node\Name[] Names of implemented interfaces */
|
||||
public $implements;
|
||||
|
||||
protected static $specialNames = array(
|
||||
'self' => true,
|
||||
'parent' => true,
|
||||
@ -41,16 +41,12 @@ class Class_ extends ClassLike
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, array $subNodes = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'type' => isset($subNodes['type']) ? $subNodes['type'] : 0,
|
||||
'name' => $name,
|
||||
'extends' => isset($subNodes['extends']) ? $subNodes['extends'] : null,
|
||||
'implements' => isset($subNodes['implements']) ? $subNodes['implements'] : array(),
|
||||
'stmts' => isset($subNodes['stmts']) ? $subNodes['stmts'] : array(),
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->type = isset($subNodes['type']) ? $subNodes['type'] : 0;
|
||||
$this->name = $name;
|
||||
$this->extends = isset($subNodes['extends']) ? $subNodes['extends'] : null;
|
||||
$this->implements = isset($subNodes['implements']) ? $subNodes['implements'] : array();
|
||||
$this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
|
||||
|
||||
if (isset(self::$specialNames[(string) $this->name])) {
|
||||
throw new Error(sprintf('Cannot use \'%s\' as class name as it is reserved', $this->name));
|
||||
@ -67,6 +63,10 @@ class Class_ extends ClassLike
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('type', 'name', 'extends', 'implements', 'stmts');
|
||||
}
|
||||
|
||||
public function isAbstract() {
|
||||
return (bool) ($this->type & self::MODIFIER_ABSTRACT);
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property Node\Const_[] $consts Constant declarations
|
||||
*/
|
||||
class Const_ extends Node\Stmt
|
||||
{
|
||||
/** @var Node\Const_[] Constant declarations */
|
||||
public $consts;
|
||||
|
||||
/**
|
||||
* Constructs a const list node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Const_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $consts, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'consts' => $consts,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->consts = $consts;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('consts');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property null|Node\Expr $num Number of loops to continue
|
||||
*/
|
||||
class Continue_ extends Node\Stmt
|
||||
{
|
||||
/** @var null|Node\Expr Number of loops to continue */
|
||||
public $num;
|
||||
|
||||
/**
|
||||
* Constructs a continue node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Continue_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $num = null, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'num' => $num,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->num = $num;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('num');
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,13 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property string $key Key
|
||||
* @property Node\Expr $value Value
|
||||
*/
|
||||
class DeclareDeclare extends Node\Stmt
|
||||
{
|
||||
/** @var string Key */
|
||||
public $key;
|
||||
/** @var Node\Expr Value */
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* Constructs a declare key=>value pair node.
|
||||
*
|
||||
@ -18,12 +19,12 @@ class DeclareDeclare extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($key, Node\Expr $value, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->key = $key;
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('key', 'value');
|
||||
}
|
||||
}
|
||||
|
@ -3,13 +3,13 @@
|
||||
namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property DeclareDeclare[] $declares List of declares
|
||||
* @property Node[] $stmts Statements
|
||||
*/
|
||||
class Declare_ extends Node\Stmt
|
||||
{
|
||||
/** @var DeclareDeclare[] List of declares */
|
||||
public $declares;
|
||||
/** @var Node[] Statements */
|
||||
public $stmts;
|
||||
|
||||
/**
|
||||
* Constructs a declare node.
|
||||
*
|
||||
@ -18,12 +18,12 @@ class Declare_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $declares, array $stmts, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'declares' => $declares,
|
||||
'stmts' => $stmts,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->declares = $declares;
|
||||
$this->stmts = $stmts;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('declares', 'stmts');
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,13 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property Node\Expr $cond Condition
|
||||
* @property Node[] $stmts Statements
|
||||
*/
|
||||
class Do_ extends Node\Stmt
|
||||
{
|
||||
/** @var Node\Expr Condition */
|
||||
public $cond;
|
||||
/** @var Node[] Statements */
|
||||
public $stmts;
|
||||
|
||||
/**
|
||||
* Constructs a do while node.
|
||||
*
|
||||
@ -18,12 +19,12 @@ class Do_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $cond, array $stmts = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'cond' => $cond,
|
||||
'stmts' => $stmts,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->cond = $cond;
|
||||
$this->stmts = $stmts;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('cond', 'stmts');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property Node\Expr[] $exprs Expressions
|
||||
*/
|
||||
class Echo_ extends Node\Stmt
|
||||
{
|
||||
/** @var Node\Expr[] Expressions */
|
||||
public $exprs;
|
||||
|
||||
/**
|
||||
* Constructs an echo node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Echo_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $exprs, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'exprs' => $exprs,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->exprs = $exprs;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('exprs');
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,13 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property Node\Expr $cond Condition
|
||||
* @property Node[] $stmts Statements
|
||||
*/
|
||||
class ElseIf_ extends Node\Stmt
|
||||
{
|
||||
/** @var Node\Expr Condition */
|
||||
public $cond;
|
||||
/** @var Node[] Statements */
|
||||
public $stmts;
|
||||
|
||||
/**
|
||||
* Constructs an elseif node.
|
||||
*
|
||||
@ -18,12 +19,12 @@ class ElseIf_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $cond, array $stmts = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'cond' => $cond,
|
||||
'stmts' => $stmts,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->cond = $cond;
|
||||
$this->stmts = $stmts;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('cond', 'stmts');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property Node[] $stmts Statements
|
||||
*/
|
||||
class Else_ extends Node\Stmt
|
||||
{
|
||||
/** @var Node[] Statements */
|
||||
public $stmts;
|
||||
|
||||
/**
|
||||
* Constructs an else node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Else_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $stmts = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'stmts' => $stmts,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->stmts = $stmts;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('stmts');
|
||||
}
|
||||
}
|
||||
|
@ -4,14 +4,17 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property Node\Expr[] $init Init expressions
|
||||
* @property Node\Expr[] $cond Loop conditions
|
||||
* @property Node\Expr[] $loop Loop expressions
|
||||
* @property Node[] $stmts Statements
|
||||
*/
|
||||
class For_ extends Node\Stmt
|
||||
{
|
||||
/** @var Node\Expr[] Init expressions */
|
||||
public $init;
|
||||
/** @var Node\Expr[] Loop conditions */
|
||||
public $cond;
|
||||
/** @var Node\Expr[] Loop expressions */
|
||||
public $loop;
|
||||
/** @var Node[] Statements */
|
||||
public $stmts;
|
||||
|
||||
/**
|
||||
* Constructs a for loop node.
|
||||
*
|
||||
@ -23,14 +26,14 @@ class For_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $subNodes = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'init' => isset($subNodes['init']) ? $subNodes['init'] : array(),
|
||||
'cond' => isset($subNodes['cond']) ? $subNodes['cond'] : array(),
|
||||
'loop' => isset($subNodes['loop']) ? $subNodes['loop'] : array(),
|
||||
'stmts' => isset($subNodes['stmts']) ? $subNodes['stmts'] : array(),
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->init = isset($subNodes['init']) ? $subNodes['init'] : array();
|
||||
$this->cond = isset($subNodes['cond']) ? $subNodes['cond'] : array();
|
||||
$this->loop = isset($subNodes['loop']) ? $subNodes['loop'] : array();
|
||||
$this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('init', 'cond', 'loop', 'stmts');
|
||||
}
|
||||
}
|
||||
|
@ -4,15 +4,19 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property Node\Expr $expr Expression to iterate
|
||||
* @property null|Node\Expr $keyVar Variable to assign key to
|
||||
* @property bool $byRef Whether to assign value by reference
|
||||
* @property Node\Expr $valueVar Variable to assign value to
|
||||
* @property Node[] $stmts Statements
|
||||
*/
|
||||
class Foreach_ extends Node\Stmt
|
||||
{
|
||||
/** @var Node\Expr Expression to iterate */
|
||||
public $expr;
|
||||
/** @var null|Node\Expr Variable to assign key to */
|
||||
public $keyVar;
|
||||
/** @var bool Whether to assign value by reference */
|
||||
public $byRef;
|
||||
/** @var Node\Expr Variable to assign value to */
|
||||
public $valueVar;
|
||||
/** @var Node[] Statements */
|
||||
public $stmts;
|
||||
|
||||
/**
|
||||
* Constructs a foreach node.
|
||||
*
|
||||
@ -25,15 +29,15 @@ class Foreach_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $expr, Node\Expr $valueVar, array $subNodes = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'expr' => $expr,
|
||||
'keyVar' => isset($subNodes['keyVar']) ? $subNodes['keyVar'] : null,
|
||||
'byRef' => isset($subNodes['byRef']) ? $subNodes['byRef'] : false,
|
||||
'valueVar' => $valueVar,
|
||||
'stmts' => isset($subNodes['stmts']) ? $subNodes['stmts'] : array(),
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->expr = $expr;
|
||||
$this->keyVar = isset($subNodes['keyVar']) ? $subNodes['keyVar'] : null;
|
||||
$this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false;
|
||||
$this->valueVar = $valueVar;
|
||||
$this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('expr', 'keyVar', 'byRef', 'valueVar', 'stmts');
|
||||
}
|
||||
}
|
||||
|
@ -4,14 +4,17 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property bool $byRef Whether returns by reference
|
||||
* @property string $name Name
|
||||
* @property Node\Param[] $params Parameters
|
||||
* @property Node[] $stmts Statements
|
||||
*/
|
||||
class Function_ extends Node\Stmt
|
||||
{
|
||||
/** @var bool Whether function returns by reference */
|
||||
public $byRef;
|
||||
/** @var string Name */
|
||||
public $name;
|
||||
/** @var Node\Param[] Parameters */
|
||||
public $params;
|
||||
/** @var Node[] Statements */
|
||||
public $stmts;
|
||||
|
||||
/**
|
||||
* Constructs a function node.
|
||||
*
|
||||
@ -23,15 +26,14 @@ class Function_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, array $subNodes = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'byRef' => isset($subNodes['byRef']) ? $subNodes['byRef'] : false,
|
||||
'name' => $name,
|
||||
'params' => isset($subNodes['params']) ? $subNodes['params'] : array(),
|
||||
'stmts' => isset($subNodes['stmts']) ? $subNodes['stmts'] : array(),
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false;
|
||||
$this->name = $name;
|
||||
$this->params = isset($subNodes['params']) ? $subNodes['params'] : array();
|
||||
$this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('byRef', 'name', 'params', 'stmts');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property Node\Expr[] $vars Variables
|
||||
*/
|
||||
class Global_ extends Node\Stmt
|
||||
{
|
||||
/** @var Node\Expr[] Variables */
|
||||
public $vars;
|
||||
|
||||
/**
|
||||
* Constructs a global variables list node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Global_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $vars, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'vars' => $vars,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->vars = $vars;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('vars');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
/**
|
||||
* @property string $name Name of label to jump to
|
||||
*/
|
||||
class Goto_ extends Stmt
|
||||
{
|
||||
/** @var string Name of label to jump to */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* Constructs a goto node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Goto_ extends Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'name' => $name,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->name = $name;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('name');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
/**
|
||||
* @property string $remaining Remaining text after halt compiler statement.
|
||||
*/
|
||||
class HaltCompiler extends Stmt
|
||||
{
|
||||
/** @var string Remaining text after halt compiler statement. */
|
||||
public $remaining;
|
||||
|
||||
/**
|
||||
* Constructs a __halt_compiler node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class HaltCompiler extends Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($remaining, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'remaining' => $remaining,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->remaining = $remaining;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('remaining');
|
||||
}
|
||||
}
|
||||
|
@ -4,14 +4,16 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property Node\Expr $cond Condition expression
|
||||
* @property Node[] $stmts Statements
|
||||
* @property Node\Stmt\ElseIf_[] $elseifs Elseif clauses
|
||||
* @property null|Node\Stmt\Else_ $else Else clause
|
||||
*/
|
||||
class If_ extends Node\Stmt
|
||||
{
|
||||
/** @var Node\Expr Condition expression */
|
||||
public $cond;
|
||||
/** @var Node[] Statements */
|
||||
public $stmts;
|
||||
/** @var ElseIf_[] Elseif clauses */
|
||||
public $elseifs;
|
||||
/** @var null|Else_ Else clause */
|
||||
public $else;
|
||||
|
||||
/**
|
||||
* Constructs an if node.
|
||||
@ -24,15 +26,14 @@ class If_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $cond, array $subNodes = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'cond' => $cond,
|
||||
'stmts' => isset($subNodes['stmts']) ? $subNodes['stmts'] : array(),
|
||||
'elseifs' => isset($subNodes['elseifs']) ? $subNodes['elseifs'] : array(),
|
||||
'else' => isset($subNodes['else']) ? $subNodes['else'] : null,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->cond = $cond;
|
||||
$this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
|
||||
$this->elseifs = isset($subNodes['elseifs']) ? $subNodes['elseifs'] : array();
|
||||
$this->else = isset($subNodes['else']) ? $subNodes['else'] : null;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('cond', 'stmts', 'elseifs', 'else');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
/**
|
||||
* @property string $value String
|
||||
*/
|
||||
class InlineHTML extends Stmt
|
||||
{
|
||||
/** @var string String */
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* Constructs an inline HTML node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class InlineHTML extends Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($value, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'value' => $value,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('value');
|
||||
}
|
||||
}
|
||||
|
@ -5,13 +5,11 @@ namespace PhpParser\Node\Stmt;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Error;
|
||||
|
||||
/**
|
||||
* @property string $name Name
|
||||
* @property Node\Name[] $extends Extended interfaces
|
||||
* @property Node[] $stmts Statements
|
||||
*/
|
||||
class Interface_ extends ClassLike
|
||||
{
|
||||
/** @var Node\Name[] Extended interfaces */
|
||||
public $extends;
|
||||
|
||||
protected static $specialNames = array(
|
||||
'self' => true,
|
||||
'parent' => true,
|
||||
@ -28,14 +26,10 @@ class Interface_ extends ClassLike
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, array $subNodes = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'name' => $name,
|
||||
'extends' => isset($subNodes['extends']) ? $subNodes['extends'] : array(),
|
||||
'stmts' => isset($subNodes['stmts']) ? $subNodes['stmts'] : array(),
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->name = $name;
|
||||
$this->extends = isset($subNodes['extends']) ? $subNodes['extends'] : array();
|
||||
$this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
|
||||
|
||||
if (isset(self::$specialNames[(string) $this->name])) {
|
||||
throw new Error(sprintf('Cannot use \'%s\' as class name as it is reserved', $this->name));
|
||||
@ -47,4 +41,8 @@ class Interface_ extends ClassLike
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('name', 'extends', 'stmts');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
/**
|
||||
* @property string $name Name
|
||||
*/
|
||||
class Label extends Stmt
|
||||
{
|
||||
/** @var string Name */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* Constructs a label node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Label extends Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'name' => $name,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->name = $name;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('name');
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,13 @@ namespace PhpParser\Node\Stmt;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Error;
|
||||
|
||||
/**
|
||||
* @property null|Node\Name $name Name
|
||||
* @property Node[] $stmts Statements
|
||||
*/
|
||||
class Namespace_ extends Node\Stmt
|
||||
{
|
||||
/** @var null|Node\Name Name */
|
||||
public $name;
|
||||
/** @var Node[] Statements */
|
||||
public $stmts;
|
||||
|
||||
protected static $specialNames = array(
|
||||
'self' => true,
|
||||
'parent' => true,
|
||||
@ -25,13 +26,9 @@ class Namespace_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Name $name = null, $stmts = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'name' => $name,
|
||||
'stmts' => $stmts,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->name = $name;
|
||||
$this->stmts = $stmts;
|
||||
|
||||
if (isset(self::$specialNames[(string) $this->name])) {
|
||||
throw new Error(sprintf('Cannot use \'%s\' as namespace name', $this->name));
|
||||
@ -45,4 +42,8 @@ class Namespace_ extends Node\Stmt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('name', 'stmts');
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,13 @@ namespace PhpParser\Node\Stmt;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Error;
|
||||
|
||||
/**
|
||||
* @property int $type Modifiers
|
||||
* @property PropertyProperty[] $props Properties
|
||||
*/
|
||||
class Property extends Node\Stmt
|
||||
{
|
||||
/** @var int Modifiers */
|
||||
public $type;
|
||||
/** @var PropertyProperty[] Properties */
|
||||
public $props;
|
||||
|
||||
/**
|
||||
* Constructs a class property list node.
|
||||
*
|
||||
@ -27,13 +28,13 @@ class Property extends Node\Stmt
|
||||
throw new Error('Properties cannot be declared final');
|
||||
}
|
||||
|
||||
parent::__construct(
|
||||
array(
|
||||
'type' => $type,
|
||||
'props' => $props,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->type = $type;
|
||||
$this->props = $props;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('type', 'props');
|
||||
}
|
||||
|
||||
public function isPublic() {
|
||||
|
@ -4,12 +4,13 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property string $name Name
|
||||
* @property null|Node\Expr $default Default
|
||||
*/
|
||||
class PropertyProperty extends Node\Stmt
|
||||
{
|
||||
/** @var string Name */
|
||||
public $name;
|
||||
/** @var null|Node\Expr Default */
|
||||
public $default;
|
||||
|
||||
/**
|
||||
* Constructs a class property node.
|
||||
*
|
||||
@ -18,12 +19,12 @@ class PropertyProperty extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, Node\Expr $default = null, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'name' => $name,
|
||||
'default' => $default,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->name = $name;
|
||||
$this->default = $default;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('name', 'default');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property null|Node\Expr $expr Expression
|
||||
*/
|
||||
class Return_ extends Node\Stmt
|
||||
{
|
||||
/** @var null|Node\Expr Expression */
|
||||
public $expr;
|
||||
|
||||
/**
|
||||
* Constructs a return node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Return_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $expr = null, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'expr' => $expr,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->expr = $expr;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('expr');
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,13 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property string $name Name
|
||||
* @property null|Node\Expr $default Default value
|
||||
*/
|
||||
class StaticVar extends Node\Stmt
|
||||
{
|
||||
/** @var string Name */
|
||||
public $name;
|
||||
/** @var null|Node\Expr Default value */
|
||||
public $default;
|
||||
|
||||
/**
|
||||
* Constructs a static variable node.
|
||||
*
|
||||
@ -18,12 +19,12 @@ class StaticVar extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, Node\Expr $default = null, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'name' => $name,
|
||||
'default' => $default,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->name = $name;
|
||||
$this->default = $default;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('name', 'default');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
/**
|
||||
* @property StaticVar[] $vars Variable definitions
|
||||
*/
|
||||
class Static_ extends Stmt
|
||||
{
|
||||
/** @var StaticVar[] Variable definitions */
|
||||
public $vars;
|
||||
|
||||
/**
|
||||
* Constructs a static variables list node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Static_ extends Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $vars, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'vars' => $vars,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->vars = $vars;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('vars');
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,13 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property Node\Expr $cond Condition
|
||||
* @property Case_[] $cases Case list
|
||||
*/
|
||||
class Switch_ extends Node\Stmt
|
||||
{
|
||||
/** @var Node\Expr Condition */
|
||||
public $cond;
|
||||
/** @var Case_[] Case list */
|
||||
public $cases;
|
||||
|
||||
/**
|
||||
* Constructs a case node.
|
||||
*
|
||||
@ -18,12 +19,12 @@ class Switch_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $cond, array $cases, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'cond' => $cond,
|
||||
'cases' => $cases,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->cond = $cond;
|
||||
$this->cases = $cases;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('cond', 'cases');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property Node\Expr $expr Expression
|
||||
*/
|
||||
class Throw_ extends Node\Stmt
|
||||
{
|
||||
/** @var Node\Expr Expression */
|
||||
public $expr;
|
||||
|
||||
/**
|
||||
* Constructs a throw node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Throw_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $expr, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'expr' => $expr,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->expr = $expr;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('expr');
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,14 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property Node\Name[] $traits Traits
|
||||
* @property TraitUseAdaptation[] $adaptations Adaptations
|
||||
*/
|
||||
|
||||
class TraitUse extends Node\Stmt
|
||||
{
|
||||
/** @var Node\Name[] Traits */
|
||||
public $traits;
|
||||
/** @var TraitUseAdaptation[] Adaptations */
|
||||
public $adaptations;
|
||||
|
||||
/**
|
||||
* Constructs a trait use node.
|
||||
*
|
||||
@ -18,12 +20,12 @@ class TraitUse extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $traits, array $adaptations = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'traits' => $traits,
|
||||
'adaptations' => $adaptations,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->traits = $traits;
|
||||
$this->adaptations = $adaptations;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('traits', 'adaptations');
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,10 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property Node\Name $trait Trait name
|
||||
* @property string $method Method name
|
||||
*/
|
||||
abstract class TraitUseAdaptation extends Node\Stmt
|
||||
{
|
||||
}
|
||||
/** @var Node\Name Trait name */
|
||||
public $trait;
|
||||
/** @var string Method name */
|
||||
public $method;
|
||||
}
|
||||
|
@ -4,14 +4,13 @@ namespace PhpParser\Node\Stmt\TraitUseAdaptation;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property null|Node\Name $trait Trait name
|
||||
* @property string $method Method name
|
||||
* @property null|int $newModifier New modifier
|
||||
* @property null|string $newName New name
|
||||
*/
|
||||
class Alias extends Node\Stmt\TraitUseAdaptation
|
||||
{
|
||||
/** @var null|int New modifier */
|
||||
public $newModifier;
|
||||
/** @var null|string New name */
|
||||
public $newName;
|
||||
|
||||
/**
|
||||
* Constructs a trait use precedence adaptation node.
|
||||
*
|
||||
@ -22,14 +21,14 @@ class Alias extends Node\Stmt\TraitUseAdaptation
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($trait, $method, $newModifier, $newName, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'trait' => $trait,
|
||||
'method' => $method,
|
||||
'newModifier' => $newModifier,
|
||||
'newName' => $newName,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->trait = $trait;
|
||||
$this->method = $method;
|
||||
$this->newModifier = $newModifier;
|
||||
$this->newName = $newName;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('trait', 'method', 'newModifier', 'newName');
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,11 @@ namespace PhpParser\Node\Stmt\TraitUseAdaptation;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property Node\Name $trait Trait name
|
||||
* @property string $method Method name
|
||||
* @property Node\Name[] $insteadof Overwritten traits
|
||||
*/
|
||||
class Precedence extends Node\Stmt\TraitUseAdaptation
|
||||
{
|
||||
/** @var Node\Name[] Overwritten traits */
|
||||
public $insteadof;
|
||||
|
||||
/**
|
||||
* Constructs a trait use precedence adaptation node.
|
||||
*
|
||||
@ -20,13 +18,13 @@ class Precedence extends Node\Stmt\TraitUseAdaptation
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Name $trait, $method, array $insteadof, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'trait' => $trait,
|
||||
'method' => $method,
|
||||
'insteadof' => $insteadof,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->trait = $trait;
|
||||
$this->method = $method;
|
||||
$this->insteadof = $insteadof;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('trait', 'method', 'insteadof');
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,6 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property string $name Name
|
||||
* @property Node[] $stmts Statements
|
||||
*/
|
||||
class Trait_ extends ClassLike
|
||||
{
|
||||
/**
|
||||
@ -18,12 +14,12 @@ class Trait_ extends ClassLike
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, array $stmts = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'name' => $name,
|
||||
'stmts' => $stmts,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->name = $name;
|
||||
$this->stmts = $stmts;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('name', 'stmts');
|
||||
}
|
||||
}
|
||||
|
@ -5,33 +5,35 @@ namespace PhpParser\Node\Stmt;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Error;
|
||||
|
||||
/**
|
||||
* @property Node[] $stmts Statements
|
||||
* @property Catch_[] $catches Catches
|
||||
* @property Node[] $finallyStmts Finally statements
|
||||
*/
|
||||
class TryCatch extends Node\Stmt
|
||||
{
|
||||
/** @var Node[] Statements */
|
||||
public $stmts;
|
||||
/** @var Catch_[] Catches */
|
||||
public $catches;
|
||||
/** @var null|Node[] Finally statements */
|
||||
public $finallyStmts;
|
||||
|
||||
/**
|
||||
* Constructs a try catch node.
|
||||
*
|
||||
* @param Node[] $stmts Statements
|
||||
* @param Catch_[] $catches Catches
|
||||
* @param Node[] $finallyStmts Finally statements (null means no finally clause)
|
||||
* @param array|null $attributes Additional attributes
|
||||
* @param Node[] $stmts Statements
|
||||
* @param Catch_[] $catches Catches
|
||||
* @param null|Node[] $finallyStmts Finally statements (null means no finally clause)
|
||||
* @param array|null $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $stmts, array $catches, array $finallyStmts = null, array $attributes = array()) {
|
||||
if (empty($catches) && null === $finallyStmts) {
|
||||
throw new Error('Cannot use try without catch or finally');
|
||||
}
|
||||
|
||||
parent::__construct(
|
||||
array(
|
||||
'stmts' => $stmts,
|
||||
'catches' => $catches,
|
||||
'finallyStmts' => $finallyStmts,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->stmts = $stmts;
|
||||
$this->catches = $catches;
|
||||
$this->finallyStmts = $finallyStmts;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('stmts', 'catches', 'finallyStmts');
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property Node\Expr[] $vars Variables to unset
|
||||
*/
|
||||
class Unset_ extends Node\Stmt
|
||||
{
|
||||
/** @var Node\Expr[] Variables to unset */
|
||||
public $vars;
|
||||
|
||||
/**
|
||||
* Constructs an unset node.
|
||||
*
|
||||
@ -16,11 +16,11 @@ class Unset_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $vars, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'vars' => $vars,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->vars = $vars;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('vars');
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,13 @@ namespace PhpParser\Node\Stmt;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Error;
|
||||
|
||||
/**
|
||||
* @property Node\Name $name Namespace/Class to alias
|
||||
* @property string $alias Alias
|
||||
*/
|
||||
class UseUse extends Node\Stmt
|
||||
{
|
||||
/** @var Node\Name Namespace, class, function or constant to alias */
|
||||
public $name;
|
||||
/** @var string Alias */
|
||||
public $alias;
|
||||
|
||||
/**
|
||||
* Constructs an alias (use) node.
|
||||
*
|
||||
@ -30,12 +31,12 @@ class UseUse extends Node\Stmt
|
||||
));
|
||||
}
|
||||
|
||||
parent::__construct(
|
||||
array(
|
||||
'name' => $name,
|
||||
'alias' => $alias,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->name = $name;
|
||||
$this->alias = $alias;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('name', 'alias');
|
||||
}
|
||||
}
|
||||
|
@ -4,16 +4,17 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
/**
|
||||
* @property int $type Type of alias
|
||||
* @property UseUse[] $uses Aliases
|
||||
*/
|
||||
class Use_ extends Stmt
|
||||
{
|
||||
const TYPE_NORMAL = 1;
|
||||
const TYPE_NORMAL = 1;
|
||||
const TYPE_FUNCTION = 2;
|
||||
const TYPE_CONSTANT = 3;
|
||||
|
||||
/** @var int Type of alias */
|
||||
public $type;
|
||||
/** @var UseUse[] Aliases */
|
||||
public $uses;
|
||||
|
||||
/**
|
||||
* Constructs an alias (use) list node.
|
||||
*
|
||||
@ -22,12 +23,12 @@ class Use_ extends Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $uses, $type = self::TYPE_NORMAL, array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'type' => $type,
|
||||
'uses' => $uses,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->type = $type;
|
||||
$this->uses = $uses;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('type', 'uses');
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,13 @@ namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
/**
|
||||
* @property Node\Expr $cond Condition
|
||||
* @property Node[] $stmts Statements
|
||||
*/
|
||||
class While_ extends Node\Stmt
|
||||
{
|
||||
/** @var Node\Expr Condition */
|
||||
public $cond;
|
||||
/** @var Node[] Statements */
|
||||
public $stmts;
|
||||
|
||||
/**
|
||||
* Constructs a while node.
|
||||
*
|
||||
@ -18,12 +19,12 @@ class While_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $cond, array $stmts = array(), array $attributes = array()) {
|
||||
parent::__construct(
|
||||
array(
|
||||
'cond' => $cond,
|
||||
'stmts' => $stmts,
|
||||
),
|
||||
$attributes
|
||||
);
|
||||
parent::__construct(null, $attributes);
|
||||
$this->cond = $cond;
|
||||
$this->stmts = $stmts;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('cond', 'stmts');
|
||||
}
|
||||
}
|
||||
|
@ -2,20 +2,32 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
abstract class NodeAbstract implements Node, \IteratorAggregate
|
||||
abstract class NodeAbstract implements Node
|
||||
{
|
||||
protected $subNodes;
|
||||
private $subNodeNames;
|
||||
protected $attributes;
|
||||
|
||||
/**
|
||||
* Creates a Node.
|
||||
*
|
||||
* @param array $subNodes Array of sub nodes
|
||||
* @param array $attributes Array of attributes
|
||||
* If null is passed for the $subNodes parameter the node constructor must assign
|
||||
* all subnodes by itself and also override the getSubNodeNames() method.
|
||||
* DEPRECATED: If an array is passed as $subNodes instead, the properties corresponding
|
||||
* to the array keys will be set and getSubNodeNames() will return the keys of that
|
||||
* array.
|
||||
*
|
||||
* @param null|array $subNodes Null or an array of sub nodes (deprecated)
|
||||
* @param array $attributes Array of attributes
|
||||
*/
|
||||
public function __construct(array $subNodes = array(), array $attributes = array()) {
|
||||
$this->subNodes = $subNodes;
|
||||
public function __construct($subNodes = array(), array $attributes = array()) {
|
||||
$this->attributes = $attributes;
|
||||
|
||||
if (null !== $subNodes) {
|
||||
foreach ($subNodes as $name => $value) {
|
||||
$this->$name = $value;
|
||||
}
|
||||
$this->subNodeNames = array_keys($subNodes);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -33,7 +45,7 @@ abstract class NodeAbstract implements Node, \IteratorAggregate
|
||||
* @return array Names of sub nodes
|
||||
*/
|
||||
public function getSubNodeNames() {
|
||||
return array_keys($this->subNodes);
|
||||
return $this->subNodeNames;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,22 +118,4 @@ abstract class NodeAbstract implements Node, \IteratorAggregate
|
||||
public function getAttributes() {
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
/* Magic interfaces */
|
||||
|
||||
public function &__get($name) {
|
||||
return $this->subNodes[$name];
|
||||
}
|
||||
public function __set($name, $value) {
|
||||
$this->subNodes[$name] = $value;
|
||||
}
|
||||
public function __isset($name) {
|
||||
return isset($this->subNodes[$name]);
|
||||
}
|
||||
public function __unset($name) {
|
||||
unset($this->subNodes[$name]);
|
||||
}
|
||||
public function getIterator() {
|
||||
return new \ArrayIterator($this->subNodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,28 +14,45 @@ class NodeDumper
|
||||
public function dump($node) {
|
||||
if ($node instanceof Node) {
|
||||
$r = $node->getType() . '(';
|
||||
|
||||
foreach ($node->getSubNodeNames() as $key) {
|
||||
$r .= "\n " . $key . ': ';
|
||||
|
||||
$value = $node->$key;
|
||||
if (null === $value) {
|
||||
$r .= 'null';
|
||||
} elseif (false === $value) {
|
||||
$r .= 'false';
|
||||
} elseif (true === $value) {
|
||||
$r .= 'true';
|
||||
} elseif (is_scalar($value)) {
|
||||
$r .= $value;
|
||||
} else {
|
||||
$r .= str_replace("\n", "\n ", $this->dump($value));
|
||||
}
|
||||
}
|
||||
} elseif (is_array($node)) {
|
||||
$r = 'array(';
|
||||
|
||||
foreach ($node as $key => $value) {
|
||||
$r .= "\n " . $key . ': ';
|
||||
|
||||
if (null === $value) {
|
||||
$r .= 'null';
|
||||
} elseif (false === $value) {
|
||||
$r .= 'false';
|
||||
} elseif (true === $value) {
|
||||
$r .= 'true';
|
||||
} elseif (is_scalar($value)) {
|
||||
$r .= $value;
|
||||
} else {
|
||||
$r .= str_replace("\n", "\n ", $this->dump($value));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Can only dump nodes and arrays.');
|
||||
}
|
||||
|
||||
foreach ($node as $key => $value) {
|
||||
$r .= "\n " . $key . ': ';
|
||||
|
||||
if (null === $value) {
|
||||
$r .= 'null';
|
||||
} elseif (false === $value) {
|
||||
$r .= 'false';
|
||||
} elseif (true === $value) {
|
||||
$r .= 'true';
|
||||
} elseif (is_scalar($value)) {
|
||||
$r .= $value;
|
||||
} else {
|
||||
$r .= str_replace("\n", "\n ", $this->dump($value));
|
||||
}
|
||||
}
|
||||
|
||||
return $r . "\n)";
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class XML implements Unserializer
|
||||
// create the node without calling it's constructor
|
||||
$node = unserialize(
|
||||
sprintf(
|
||||
"O:%d:\"%s\":2:{s:11:\"\0*\0subNodes\";a:0:{}s:13:\"\0*\0attributes\";a:0:{}}",
|
||||
"O:%d:\"%s\":1:{s:13:\"\0*\0attributes\";a:0:{}}",
|
||||
strlen($className), $className
|
||||
)
|
||||
);
|
||||
|
@ -2,9 +2,29 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
class DummyNode extends NodeAbstract {
|
||||
public $subNode1;
|
||||
public $subNode2;
|
||||
|
||||
public function __construct($subNode1, $subNode2, $attributes) {
|
||||
parent::__construct(null, $attributes);
|
||||
$this->subNode1 = $subNode1;
|
||||
$this->subNode2 = $subNode2;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() {
|
||||
return array('subNode1', 'subNode2');
|
||||
}
|
||||
|
||||
// This method is only overwritten because the node is located in an unusual namespace
|
||||
public function getType() {
|
||||
return 'Dummy';
|
||||
}
|
||||
}
|
||||
|
||||
class NodeAbstractTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testConstruct() {
|
||||
public function provideNodes() {
|
||||
$attributes = array(
|
||||
'startLine' => 10,
|
||||
'comments' => array(
|
||||
@ -13,33 +33,50 @@ class NodeAbstractTest extends \PHPUnit_Framework_TestCase
|
||||
),
|
||||
);
|
||||
|
||||
/** @var $node NodeAbstract */
|
||||
$node = $this->getMockForAbstractClass(
|
||||
$node1 = $this->getMockForAbstractClass(
|
||||
'PhpParser\NodeAbstract',
|
||||
array(
|
||||
array(
|
||||
'subNode' => 'value'
|
||||
'subNode1' => 'value1',
|
||||
'subNode2' => 'value2',
|
||||
),
|
||||
$attributes
|
||||
),
|
||||
'PhpParser_Node_Dummy'
|
||||
);
|
||||
$node1->notSubNode = 'value3';
|
||||
|
||||
$node2 = new DummyNode('value1', 'value2', $attributes);
|
||||
$node2->notSubNode = 'value3';
|
||||
|
||||
return array(
|
||||
array($attributes, $node1),
|
||||
array($attributes, $node2),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideNodes
|
||||
*/
|
||||
public function testConstruct(array $attributes, Node $node) {
|
||||
$this->assertSame('Dummy', $node->getType());
|
||||
$this->assertSame(array('subNode'), $node->getSubNodeNames());
|
||||
$this->assertSame(array('subNode1', 'subNode2'), $node->getSubNodeNames());
|
||||
$this->assertSame(10, $node->getLine());
|
||||
$this->assertSame('/** doc comment */', $node->getDocComment()->getText());
|
||||
$this->assertSame('value', $node->subNode);
|
||||
$this->assertTrue(isset($node->subNode));
|
||||
$this->assertSame('value1', $node->subNode1);
|
||||
$this->assertSame('value2', $node->subNode2);
|
||||
$this->assertTrue(isset($node->subNode1));
|
||||
$this->assertTrue(isset($node->subNode2));
|
||||
$this->assertFalse(isset($node->subNode3));
|
||||
$this->assertSame($attributes, $node->getAttributes());
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testConstruct
|
||||
* @dataProvider provideNodes
|
||||
*/
|
||||
public function testGetDocComment(Node $node) {
|
||||
public function testGetDocComment(array $attributes, Node $node) {
|
||||
$this->assertSame('/** doc comment */', $node->getDocComment()->getText());
|
||||
array_pop($node->getAttribute('comments')); // remove doc comment
|
||||
$this->assertNull($node->getDocComment());
|
||||
@ -48,9 +85,9 @@ class NodeAbstractTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testConstruct
|
||||
* @dataProvider provideNodes
|
||||
*/
|
||||
public function testChange(Node $node) {
|
||||
public function testChange(array $attributes, Node $node) {
|
||||
// change of line
|
||||
$node->setLine(15);
|
||||
$this->assertSame(15, $node->getLine());
|
||||
@ -69,6 +106,31 @@ class NodeAbstractTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertFalse(isset($node->subNode));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideNodes
|
||||
*/
|
||||
public function testIteration(array $attributes, Node $node) {
|
||||
// Iteration is simple object iteration over properties,
|
||||
// not over subnodes
|
||||
$i = 0;
|
||||
foreach ($node as $key => $value) {
|
||||
if ($i === 0) {
|
||||
$this->assertSame('subNode1', $key);
|
||||
$this->assertSame('value1', $value);
|
||||
} else if ($i === 1) {
|
||||
$this->assertSame('subNode2', $key);
|
||||
$this->assertSame('value2', $value);
|
||||
} else if ($i === 2) {
|
||||
$this->assertSame('notSubNode', $key);
|
||||
$this->assertSame('value3', $value);
|
||||
} else {
|
||||
throw new \Exception;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$this->assertSame(3, $i);
|
||||
}
|
||||
|
||||
public function testAttributes() {
|
||||
/** @var $node Node */
|
||||
$node = $this->getMockForAbstractClass('PhpParser\NodeAbstract');
|
||||
@ -96,4 +158,4 @@ class NodeAbstractTest extends \PHPUnit_Framework_TestCase
|
||||
$node->getAttributes()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user