Laravel version update

Laravel version update
This commit is contained in:
Manish Verma
2018-08-06 18:48:58 +05:30
parent d143048413
commit 126fbb0255
13678 changed files with 1031482 additions and 778530 deletions

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node;
@@ -21,14 +21,18 @@ class Arg extends NodeAbstract
* @param bool $unpack Whether to unpack the argument
* @param array $attributes Additional attributes
*/
public function __construct(Expr $value, $byRef = false, $unpack = false, array $attributes = array()) {
public function __construct(Expr $value, bool $byRef = false, bool $unpack = false, array $attributes = []) {
parent::__construct($attributes);
$this->value = $value;
$this->byRef = $byRef;
$this->unpack = $unpack;
}
public function getSubNodeNames() {
return array('value', 'byRef', 'unpack');
public function getSubNodeNames() : array {
return ['value', 'byRef', 'unpack'];
}
public function getType() : string {
return 'Arg';
}
}

View File

@@ -1,12 +1,15 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node;
use PhpParser\NodeAbstract;
/**
* @property Name $namespacedName Namespaced name (for class constants, if using NameResolver)
*/
class Const_ extends NodeAbstract
{
/** @var string Name */
/** @var Identifier Name */
public $name;
/** @var Expr Value */
public $value;
@@ -14,17 +17,21 @@ class Const_ extends NodeAbstract
/**
* Constructs a const node for use in class const and const statements.
*
* @param string $name Name
* @param Expr $value Value
* @param array $attributes Additional attributes
* @param string|Identifier $name Name
* @param Expr $value Value
* @param array $attributes Additional attributes
*/
public function __construct($name, Expr $value, array $attributes = array()) {
public function __construct($name, Expr $value, array $attributes = []) {
parent::__construct($attributes);
$this->name = $name;
$this->name = \is_string($name) ? new Identifier($name) : $name;
$this->value = $value;
}
public function getSubNodeNames() {
return array('name', 'value');
public function getSubNodeNames() : array {
return ['name', 'value'];
}
public function getType() : string {
return 'Const';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node;
@@ -6,4 +6,4 @@ use PhpParser\NodeAbstract;
abstract class Expr extends NodeAbstract
{
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -18,13 +18,17 @@ class ArrayDimFetch extends Expr
* @param null|Expr $dim Array index / dim
* @param array $attributes Additional attributes
*/
public function __construct(Expr $var, Expr $dim = null, array $attributes = array()) {
public function __construct(Expr $var, Expr $dim = null, array $attributes = []) {
parent::__construct($attributes);
$this->var = $var;
$this->dim = $dim;
}
public function getSubnodeNames() {
return array('var', 'dim');
public function getSubNodeNames() : array {
return ['var', 'dim'];
}
public function getType() : string {
return 'Expr_ArrayDimFetch';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -21,14 +21,18 @@ class ArrayItem extends Expr
* @param bool $byRef Whether to assign by reference
* @param array $attributes Additional attributes
*/
public function __construct(Expr $value, Expr $key = null, $byRef = false, array $attributes = array()) {
public function __construct(Expr $value, Expr $key = null, bool $byRef = false, array $attributes = []) {
parent::__construct($attributes);
$this->key = $key;
$this->value = $value;
$this->byRef = $byRef;
}
public function getSubNodeNames() {
return array('key', 'value', 'byRef');
public function getSubNodeNames() : array {
return ['key', 'value', 'byRef'];
}
public function getType() : string {
return 'Expr_ArrayItem';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -19,12 +19,16 @@ class Array_ extends Expr
* @param ArrayItem[] $items Items of the array
* @param array $attributes Additional attributes
*/
public function __construct(array $items = array(), array $attributes = array()) {
public function __construct(array $items = [], array $attributes = []) {
parent::__construct($attributes);
$this->items = $items;
}
public function getSubNodeNames() {
return array('items');
public function getSubNodeNames() : array {
return ['items'];
}
public function getType() : string {
return 'Expr_Array';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -18,13 +18,17 @@ class Assign extends Expr
* @param Expr $expr Expression
* @param array $attributes Additional attributes
*/
public function __construct(Expr $var, Expr $expr, array $attributes = array()) {
public function __construct(Expr $var, Expr $expr, array $attributes = []) {
parent::__construct($attributes);
$this->var = $var;
$this->expr = $expr;
}
public function getSubNodeNames() {
return array('var', 'expr');
public function getSubNodeNames() : array {
return ['var', 'expr'];
}
public function getType() : string {
return 'Expr_Assign';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -18,13 +18,13 @@ abstract class AssignOp extends Expr
* @param Expr $expr Expression
* @param array $attributes Additional attributes
*/
public function __construct(Expr $var, Expr $expr, array $attributes = array()) {
public function __construct(Expr $var, Expr $expr, array $attributes = []) {
parent::__construct($attributes);
$this->var = $var;
$this->expr = $expr;
}
public function getSubNodeNames() {
return array('var', 'expr');
public function getSubNodeNames() : array {
return ['var', 'expr'];
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\AssignOp;
@@ -6,4 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
class BitwiseAnd extends AssignOp
{
}
public function getType() : string {
return 'Expr_AssignOp_BitwiseAnd';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\AssignOp;
@@ -6,4 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
class BitwiseOr extends AssignOp
{
}
public function getType() : string {
return 'Expr_AssignOp_BitwiseOr';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\AssignOp;
@@ -6,4 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
class BitwiseXor extends AssignOp
{
}
public function getType() : string {
return 'Expr_AssignOp_BitwiseXor';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\AssignOp;
@@ -6,4 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
class Concat extends AssignOp
{
}
public function getType() : string {
return 'Expr_AssignOp_Concat';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\AssignOp;
@@ -6,4 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
class Div extends AssignOp
{
}
public function getType() : string {
return 'Expr_AssignOp_Div';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\AssignOp;
@@ -6,4 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
class Minus extends AssignOp
{
}
public function getType() : string {
return 'Expr_AssignOp_Minus';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\AssignOp;
@@ -6,4 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
class Mod extends AssignOp
{
}
public function getType() : string {
return 'Expr_AssignOp_Mod';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\AssignOp;
@@ -6,4 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
class Mul extends AssignOp
{
}
public function getType() : string {
return 'Expr_AssignOp_Mul';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\AssignOp;
@@ -6,4 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
class Plus extends AssignOp
{
}
public function getType() : string {
return 'Expr_AssignOp_Plus';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\AssignOp;
@@ -6,4 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
class Pow extends AssignOp
{
}
public function getType() : string {
return 'Expr_AssignOp_Pow';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\AssignOp;
@@ -6,4 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
class ShiftLeft extends AssignOp
{
}
public function getType() : string {
return 'Expr_AssignOp_ShiftLeft';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\AssignOp;
@@ -6,4 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
class ShiftRight extends AssignOp
{
}
public function getType() : string {
return 'Expr_AssignOp_ShiftRight';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -18,13 +18,17 @@ class AssignRef extends Expr
* @param Expr $expr Expression
* @param array $attributes Additional attributes
*/
public function __construct(Expr $var, Expr $expr, array $attributes = array()) {
public function __construct(Expr $var, Expr $expr, array $attributes = []) {
parent::__construct($attributes);
$this->var = $var;
$this->expr = $expr;
}
public function getSubNodeNames() {
return array('var', 'expr');
public function getSubNodeNames() : array {
return ['var', 'expr'];
}
public function getType() : string {
return 'Expr_AssignRef';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -12,19 +12,29 @@ abstract class BinaryOp extends Expr
public $right;
/**
* Constructs a bitwise and node.
* Constructs a binary operator node.
*
* @param Expr $left The left hand side expression
* @param Expr $right The right hand side expression
* @param array $attributes Additional attributes
*/
public function __construct(Expr $left, Expr $right, array $attributes = array()) {
public function __construct(Expr $left, Expr $right, array $attributes = []) {
parent::__construct($attributes);
$this->left = $left;
$this->right = $right;
}
public function getSubNodeNames() {
return array('left', 'right');
public function getSubNodeNames() : array {
return ['left', 'right'];
}
/**
* Get the operator sigil for this binary operation.
*
* In the case there are multiple possible sigils for an operator, this method does not
* necessarily return the one used in the parsed code.
*
* @return string
*/
abstract public function getOperatorSigil() : string;
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class BitwiseAnd extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '&';
}
public function getType() : string {
return 'Expr_BinaryOp_BitwiseAnd';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class BitwiseOr extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '|';
}
public function getType() : string {
return 'Expr_BinaryOp_BitwiseOr';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class BitwiseXor extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '^';
}
public function getType() : string {
return 'Expr_BinaryOp_BitwiseXor';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class BooleanAnd extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '&&';
}
public function getType() : string {
return 'Expr_BinaryOp_BooleanAnd';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class BooleanOr extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '||';
}
public function getType() : string {
return 'Expr_BinaryOp_BooleanOr';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class Coalesce extends BinaryOp
{
public function getOperatorSigil() : string {
return '??';
}
public function getType() : string {
return 'Expr_BinaryOp_Coalesce';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class Concat extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '.';
}
public function getType() : string {
return 'Expr_BinaryOp_Concat';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class Div extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '/';
}
public function getType() : string {
return 'Expr_BinaryOp_Div';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class Equal extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '==';
}
public function getType() : string {
return 'Expr_BinaryOp_Equal';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class Greater extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '>';
}
public function getType() : string {
return 'Expr_BinaryOp_Greater';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class GreaterOrEqual extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '>=';
}
public function getType() : string {
return 'Expr_BinaryOp_GreaterOrEqual';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class Identical extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '===';
}
public function getType() : string {
return 'Expr_BinaryOp_Identical';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class LogicalAnd extends BinaryOp
{
}
public function getOperatorSigil() : string {
return 'and';
}
public function getType() : string {
return 'Expr_BinaryOp_LogicalAnd';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class LogicalOr extends BinaryOp
{
}
public function getOperatorSigil() : string {
return 'or';
}
public function getType() : string {
return 'Expr_BinaryOp_LogicalOr';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class LogicalXor extends BinaryOp
{
}
public function getOperatorSigil() : string {
return 'xor';
}
public function getType() : string {
return 'Expr_BinaryOp_LogicalXor';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class Minus extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '-';
}
public function getType() : string {
return 'Expr_BinaryOp_Minus';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class Mod extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '%';
}
public function getType() : string {
return 'Expr_BinaryOp_Mod';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class Mul extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '*';
}
public function getType() : string {
return 'Expr_BinaryOp_Mul';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class NotEqual extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '!=';
}
public function getType() : string {
return 'Expr_BinaryOp_NotEqual';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class NotIdentical extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '!==';
}
public function getType() : string {
return 'Expr_BinaryOp_NotIdentical';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class Plus extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '+';
}
public function getType() : string {
return 'Expr_BinaryOp_Plus';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class Pow extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '**';
}
public function getType() : string {
return 'Expr_BinaryOp_Pow';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class ShiftLeft extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '<<';
}
public function getType() : string {
return 'Expr_BinaryOp_ShiftLeft';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class ShiftRight extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '>>';
}
public function getType() : string {
return 'Expr_BinaryOp_ShiftRight';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class Smaller extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '<';
}
public function getType() : string {
return 'Expr_BinaryOp_Smaller';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class SmallerOrEqual extends BinaryOp
{
}
public function getOperatorSigil() : string {
return '<=';
}
public function getType() : string {
return 'Expr_BinaryOp_SmallerOrEqual';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
@@ -6,4 +6,11 @@ use PhpParser\Node\Expr\BinaryOp;
class Spaceship extends BinaryOp
{
public function getOperatorSigil() : string {
return '<=>';
}
public function getType() : string {
return 'Expr_BinaryOp_Spaceship';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -15,12 +15,16 @@ class BitwiseNot extends Expr
* @param Expr $expr Expression
* @param array $attributes Additional attributes
*/
public function __construct(Expr $expr, array $attributes = array()) {
public function __construct(Expr $expr, array $attributes = []) {
parent::__construct($attributes);
$this->expr = $expr;
}
public function getSubNodeNames() {
return array('expr');
public function getSubNodeNames() : array {
return ['expr'];
}
public function getType() : string {
return 'Expr_BitwiseNot';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -15,12 +15,16 @@ class BooleanNot extends Expr
* @param Expr $expr Expression
* @param array $attributes Additional attributes
*/
public function __construct(Expr $expr, array $attributes = array()) {
public function __construct(Expr $expr, array $attributes = []) {
parent::__construct($attributes);
$this->expr = $expr;
}
public function getSubNodeNames() {
return array('expr');
public function getSubNodeNames() : array {
return ['expr'];
}
public function getType() : string {
return 'Expr_BooleanNot';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -15,12 +15,12 @@ abstract class Cast extends Expr
* @param Expr $expr Expression
* @param array $attributes Additional attributes
*/
public function __construct(Expr $expr, array $attributes = array()) {
public function __construct(Expr $expr, array $attributes = []) {
parent::__construct($attributes);
$this->expr = $expr;
}
public function getSubNodeNames() {
return array('expr');
public function getSubNodeNames() : array {
return ['expr'];
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\Cast;
@@ -6,4 +6,7 @@ use PhpParser\Node\Expr\Cast;
class Array_ extends Cast
{
}
public function getType() : string {
return 'Expr_Cast_Array';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\Cast;
@@ -6,4 +6,7 @@ use PhpParser\Node\Expr\Cast;
class Bool_ extends Cast
{
public function getType() : string {
return 'Expr_Cast_Bool';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\Cast;
@@ -6,4 +6,7 @@ use PhpParser\Node\Expr\Cast;
class Double extends Cast
{
public function getType() : string {
return 'Expr_Cast_Double';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\Cast;
@@ -6,4 +6,7 @@ use PhpParser\Node\Expr\Cast;
class Int_ extends Cast
{
public function getType() : string {
return 'Expr_Cast_Int';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\Cast;
@@ -6,4 +6,7 @@ use PhpParser\Node\Expr\Cast;
class Object_ extends Cast
{
public function getType() : string {
return 'Expr_Cast_Object';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\Cast;
@@ -6,4 +6,7 @@ use PhpParser\Node\Expr\Cast;
class String_ extends Cast
{
public function getType() : string {
return 'Expr_Cast_String';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\Cast;
@@ -6,4 +6,7 @@ use PhpParser\Node\Expr\Cast;
class Unset_ extends Cast
{
}
public function getType() : string {
return 'Expr_Cast_Unset';
}
}

View File

@@ -1,31 +1,36 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Name;
use PhpParser\Node\Expr;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
class ClassConstFetch extends Expr
{
/** @var Name|Expr Class name */
public $class;
/** @var string Constant name */
/** @var Identifier|Error Constant name */
public $name;
/**
* Constructs a class const fetch node.
*
* @param Name|Expr $class Class name
* @param string $name Constant name
* @param array $attributes Additional attributes
* @param Name|Expr $class Class name
* @param string|Identifier|Error $name Constant name
* @param array $attributes Additional attributes
*/
public function __construct($class, $name, array $attributes = array()) {
public function __construct($class, $name, array $attributes = []) {
parent::__construct($attributes);
$this->class = $class;
$this->name = $name;
$this->name = \is_string($name) ? new Identifier($name) : $name;
}
public function getSubNodeNames() {
return array('class', 'name');
public function getSubNodeNames() : array {
return ['class', 'name'];
}
public function getType() : string {
return 'Expr_ClassConstFetch';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -15,12 +15,16 @@ class Clone_ extends Expr
* @param Expr $expr Expression
* @param array $attributes Additional attributes
*/
public function __construct(Expr $expr, array $attributes = array()) {
public function __construct(Expr $expr, array $attributes = []) {
parent::__construct($attributes);
$this->expr = $expr;
}
public function getSubNodeNames() {
return array('expr');
public function getSubNodeNames() : array {
return ['expr'];
}
public function getType() : string {
return 'Expr_Clone';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -16,9 +16,9 @@ class Closure extends Expr implements FunctionLike
public $params;
/** @var ClosureUse[] use()s */
public $uses;
/** @var null|string|Node\Name Return type */
/** @var null|Node\Identifier|Node\Name|Node\NullableType Return type */
public $returnType;
/** @var Node[] Statements */
/** @var Node\Stmt[] Statements */
public $stmts;
/**
@@ -33,25 +33,26 @@ class Closure extends Expr implements FunctionLike
* 'stmts' => array(): Statements
* @param array $attributes Additional attributes
*/
public function __construct(array $subNodes = array(), array $attributes = array()) {
public function __construct(array $subNodes = [], array $attributes = []) {
parent::__construct($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->returnType = isset($subNodes['returnType']) ? $subNodes['returnType'] : null;
$this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
$this->static = $subNodes['static'] ?? false;
$this->byRef = $subNodes['byRef'] ?? false;
$this->params = $subNodes['params'] ?? [];
$this->uses = $subNodes['uses'] ?? [];
$returnType = $subNodes['returnType'] ?? null;
$this->returnType = \is_string($returnType) ? new Node\Identifier($returnType) : $returnType;
$this->stmts = $subNodes['stmts'] ?? [];
}
public function getSubNodeNames() {
return array('static', 'byRef', 'params', 'uses', 'returnType', 'stmts');
public function getSubNodeNames() : array {
return ['static', 'byRef', 'params', 'uses', 'returnType', 'stmts'];
}
public function returnsByRef() {
public function returnsByRef() : bool {
return $this->byRef;
}
public function getParams() {
public function getParams() : array {
return $this->params;
}
@@ -59,7 +60,12 @@ class Closure extends Expr implements FunctionLike
return $this->returnType;
}
public function getStmts() {
/** @return Node\Stmt[] */
public function getStmts() : array {
return $this->stmts;
}
public function getType() : string {
return 'Expr_Closure';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -6,7 +6,7 @@ use PhpParser\Node\Expr;
class ClosureUse extends Expr
{
/** @var string Name of variable */
/** @var Expr\Variable Variable to use */
public $var;
/** @var bool Whether to use by reference */
public $byRef;
@@ -14,17 +14,21 @@ class ClosureUse extends Expr
/**
* Constructs a closure use node.
*
* @param string $var Name of variable
* @param bool $byRef Whether to use by reference
* @param array $attributes Additional attributes
* @param Expr\Variable $var Variable to use
* @param bool $byRef Whether to use by reference
* @param array $attributes Additional attributes
*/
public function __construct($var, $byRef = false, array $attributes = array()) {
public function __construct(Expr\Variable $var, bool $byRef = false, array $attributes = []) {
parent::__construct($attributes);
$this->var = $var;
$this->byRef = $byRef;
}
public function getSubNodeNames() {
return array('var', 'byRef');
public function getSubNodeNames() : array {
return ['var', 'byRef'];
}
public function getType() : string {
return 'Expr_ClosureUse';
}
}

View File

@@ -1,9 +1,9 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Name;
use PhpParser\Node\Expr;
use PhpParser\Node\Name;
class ConstFetch extends Expr
{
@@ -16,12 +16,16 @@ class ConstFetch extends Expr
* @param Name $name Constant name
* @param array $attributes Additional attributes
*/
public function __construct(Name $name, array $attributes = array()) {
public function __construct(Name $name, array $attributes = []) {
parent::__construct($attributes);
$this->name = $name;
}
public function getSubNodeNames() {
return array('name');
public function getSubNodeNames() : array {
return ['name'];
}
public function getType() : string {
return 'Expr_ConstFetch';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -15,12 +15,16 @@ class Empty_ extends Expr
* @param Expr $expr Expression
* @param array $attributes Additional attributes
*/
public function __construct(Expr $expr, array $attributes = array()) {
public function __construct(Expr $expr, array $attributes = []) {
parent::__construct($attributes);
$this->expr = $expr;
}
public function getSubNodeNames() {
return array('expr');
public function getSubNodeNames() : array {
return ['expr'];
}
public function getType() : string {
return 'Expr_Empty';
}
}

View File

@@ -0,0 +1,31 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
/**
* Error node used during parsing with error recovery.
*
* An error node may be placed at a position where an expression is required, but an error occurred.
* Error nodes will not be present if the parser is run in throwOnError mode (the default).
*/
class Error extends Expr
{
/**
* Constructs an error node.
*
* @param array $attributes Additional attributes
*/
public function __construct(array $attributes = []) {
parent::__construct($attributes);
}
public function getSubNodeNames() : array {
return [];
}
public function getType() : string {
return 'Expr_Error';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -15,12 +15,16 @@ class ErrorSuppress extends Expr
* @param Expr $expr Expression
* @param array $attributes Additional attributes
*/
public function __construct(Expr $expr, array $attributes = array()) {
public function __construct(Expr $expr, array $attributes = []) {
parent::__construct($attributes);
$this->expr = $expr;
}
public function getSubNodeNames() {
return array('expr');
public function getSubNodeNames() : array {
return ['expr'];
}
public function getType() : string {
return 'Expr_ErrorSuppress';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -15,12 +15,16 @@ class Eval_ extends Expr
* @param Expr $expr Expression
* @param array $attributes Additional attributes
*/
public function __construct(Expr $expr, array $attributes = array()) {
public function __construct(Expr $expr, array $attributes = []) {
parent::__construct($attributes);
$this->expr = $expr;
}
public function getSubNodeNames() {
return array('expr');
public function getSubNodeNames() : array {
return ['expr'];
}
public function getType() : string {
return 'Expr_Eval';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -19,12 +19,16 @@ class Exit_ extends Expr
* @param null|Expr $expr Expression
* @param array $attributes Additional attributes
*/
public function __construct(Expr $expr = null, array $attributes = array()) {
public function __construct(Expr $expr = null, array $attributes = []) {
parent::__construct($attributes);
$this->expr = $expr;
}
public function getSubNodeNames() {
return array('expr');
public function getSubNodeNames() : array {
return ['expr'];
}
public function getType() : string {
return 'Expr_Exit';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -16,16 +16,20 @@ class FuncCall extends Expr
* Constructs a function call node.
*
* @param Node\Name|Expr $name Function name
* @param Node\Arg[] $args Arguments
* @param array $attributes Additional attributes
* @param Node\Arg[] $args Arguments
* @param array $attributes Additional attributes
*/
public function __construct($name, array $args = array(), array $attributes = array()) {
public function __construct($name, array $args = [], array $attributes = []) {
parent::__construct($attributes);
$this->name = $name;
$this->args = $args;
}
public function getSubNodeNames() {
return array('name', 'args');
public function getSubNodeNames() : array {
return ['name', 'args'];
}
public function getType() : string {
return 'Expr_FuncCall';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -23,13 +23,17 @@ class Include_ extends Expr
* @param int $type Type of include
* @param array $attributes Additional attributes
*/
public function __construct(Expr $expr, $type, array $attributes = array()) {
public function __construct(Expr $expr, int $type, array $attributes = []) {
parent::__construct($attributes);
$this->expr = $expr;
$this->type = $type;
}
public function getSubNodeNames() {
return array('expr', 'type');
public function getSubNodeNames() : array {
return ['expr', 'type'];
}
public function getType() : string {
return 'Expr_Include';
}
}

View File

@@ -1,9 +1,9 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Name;
use PhpParser\Node\Expr;
use PhpParser\Node\Name;
class Instanceof_ extends Expr
{
@@ -19,13 +19,17 @@ class Instanceof_ extends Expr
* @param Name|Expr $class Class name
* @param array $attributes Additional attributes
*/
public function __construct(Expr $expr, $class, array $attributes = array()) {
public function __construct(Expr $expr, $class, array $attributes = []) {
parent::__construct($attributes);
$this->expr = $expr;
$this->class = $class;
}
public function getSubNodeNames() {
return array('expr', 'class');
public function getSubNodeNames() : array {
return ['expr', 'class'];
}
public function getType() : string {
return 'Expr_Instanceof';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -15,12 +15,16 @@ class Isset_ extends Expr
* @param Expr[] $vars Variables
* @param array $attributes Additional attributes
*/
public function __construct(array $vars, array $attributes = array()) {
public function __construct(array $vars, array $attributes = []) {
parent::__construct($attributes);
$this->vars = $vars;
}
public function getSubNodeNames() {
return array('vars');
public function getSubNodeNames() : array {
return ['vars'];
}
public function getType() : string {
return 'Expr_Isset';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -6,21 +6,25 @@ use PhpParser\Node\Expr;
class List_ extends Expr
{
/** @var Expr[] List of variables to assign to */
public $vars;
/** @var (ArrayItem|null)[] List of items to assign to */
public $items;
/**
* Constructs a list() destructuring node.
*
* @param Expr[] $vars List of variables to assign to
* @param array $attributes Additional attributes
* @param (ArrayItem|null)[] $items List of items to assign to
* @param array $attributes Additional attributes
*/
public function __construct(array $vars, array $attributes = array()) {
public function __construct(array $items, array $attributes = []) {
parent::__construct($attributes);
$this->vars = $vars;
$this->items = $items;
}
public function getSubNodeNames() {
return array('vars');
public function getSubNodeNames() : array {
return ['items'];
}
public function getType() : string {
return 'Expr_List';
}
}

View File

@@ -1,15 +1,16 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr;
use PhpParser\Node\Identifier;
class MethodCall extends Expr
{
/** @var Expr Variable holding object */
public $var;
/** @var string|Expr Method name */
/** @var Identifier|Expr Method name */
public $name;
/** @var Arg[] Arguments */
public $args;
@@ -17,19 +18,23 @@ class MethodCall extends Expr
/**
* Constructs a function call node.
*
* @param Expr $var Variable holding object
* @param string|Expr $name Method name
* @param Arg[] $args Arguments
* @param array $attributes Additional attributes
* @param Expr $var Variable holding object
* @param string|Identifier|Expr $name Method name
* @param Arg[] $args Arguments
* @param array $attributes Additional attributes
*/
public function __construct(Expr $var, $name, array $args = array(), array $attributes = array()) {
public function __construct(Expr $var, $name, array $args = [], array $attributes = []) {
parent::__construct($attributes);
$this->var = $var;
$this->name = $name;
$this->name = \is_string($name) ? new Identifier($name) : $name;
$this->args = $args;
}
public function getSubNodeNames() {
return array('var', 'name', 'args');
public function getSubNodeNames() : array {
return ['var', 'name', 'args'];
}
public function getType() : string {
return 'Expr_MethodCall';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -19,13 +19,17 @@ class New_ extends Expr
* @param Node\Arg[] $args Arguments
* @param array $attributes Additional attributes
*/
public function __construct($class, array $args = array(), array $attributes = array()) {
public function __construct($class, array $args = [], array $attributes = []) {
parent::__construct($attributes);
$this->class = $class;
$this->args = $args;
}
public function getSubNodeNames() {
return array('class', 'args');
public function getSubNodeNames() : array {
return ['class', 'args'];
}
public function getType() : string {
return 'Expr_New';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -15,12 +15,16 @@ class PostDec extends Expr
* @param Expr $var Variable
* @param array $attributes Additional attributes
*/
public function __construct(Expr $var, array $attributes = array()) {
public function __construct(Expr $var, array $attributes = []) {
parent::__construct($attributes);
$this->var = $var;
}
public function getSubNodeNames() {
return array('var');
public function getSubNodeNames() : array {
return ['var'];
}
public function getType() : string {
return 'Expr_PostDec';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -15,12 +15,16 @@ class PostInc extends Expr
* @param Expr $var Variable
* @param array $attributes Additional attributes
*/
public function __construct(Expr $var, array $attributes = array()) {
public function __construct(Expr $var, array $attributes = []) {
parent::__construct($attributes);
$this->var = $var;
}
public function getSubNodeNames() {
return array('var');
public function getSubNodeNames() : array {
return ['var'];
}
public function getType() : string {
return 'Expr_PostInc';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -15,12 +15,16 @@ class PreDec extends Expr
* @param Expr $var Variable
* @param array $attributes Additional attributes
*/
public function __construct(Expr $var, array $attributes = array()) {
public function __construct(Expr $var, array $attributes = []) {
parent::__construct($attributes);
$this->var = $var;
}
public function getSubNodeNames() {
return array('var');
public function getSubNodeNames() : array {
return ['var'];
}
public function getType() : string {
return 'Expr_PreDec';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -15,12 +15,16 @@ class PreInc extends Expr
* @param Expr $var Variable
* @param array $attributes Additional attributes
*/
public function __construct(Expr $var, array $attributes = array()) {
public function __construct(Expr $var, array $attributes = []) {
parent::__construct($attributes);
$this->var = $var;
}
public function getSubNodeNames() {
return array('var');
public function getSubNodeNames() : array {
return ['var'];
}
public function getType() : string {
return 'Expr_PreInc';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -15,12 +15,16 @@ class Print_ extends Expr
* @param Expr $expr Expression
* @param array $attributes Additional attributes
*/
public function __construct(Expr $expr, array $attributes = array()) {
public function __construct(Expr $expr, array $attributes = []) {
parent::__construct($attributes);
$this->expr = $expr;
}
public function getSubNodeNames() {
return array('expr');
public function getSubNodeNames() : array {
return ['expr'];
}
public function getType() : string {
return 'Expr_Print';
}
}

View File

@@ -1,30 +1,35 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
use PhpParser\Node\Identifier;
class PropertyFetch extends Expr
{
/** @var Expr Variable holding object */
public $var;
/** @var string|Expr Property name */
/** @var Identifier|Expr Property name */
public $name;
/**
* Constructs a function call node.
*
* @param Expr $var Variable holding object
* @param string|Expr $name Property name
* @param array $attributes Additional attributes
* @param Expr $var Variable holding object
* @param string|Identifier|Expr $name Property name
* @param array $attributes Additional attributes
*/
public function __construct(Expr $var, $name, array $attributes = array()) {
public function __construct(Expr $var, $name, array $attributes = []) {
parent::__construct($attributes);
$this->var = $var;
$this->name = $name;
$this->name = \is_string($name) ? new Identifier($name) : $name;
}
public function getSubNodeNames() {
return array('var', 'name');
public function getSubNodeNames() : array {
return ['var', 'name'];
}
public function getType() : string {
return 'Expr_PropertyFetch';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -15,12 +15,16 @@ class ShellExec extends Expr
* @param array $parts Encapsed string array
* @param array $attributes Additional attributes
*/
public function __construct(array $parts, array $attributes = array()) {
public function __construct(array $parts, array $attributes = []) {
parent::__construct($attributes);
$this->parts = $parts;
}
public function getSubNodeNames() {
return array('parts');
public function getSubNodeNames() : array {
return ['parts'];
}
public function getType() : string {
return 'Expr_ShellExec';
}
}

View File

@@ -1,15 +1,16 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Identifier;
class StaticCall extends Expr
{
/** @var Node\Name|Expr Class name */
public $class;
/** @var string|Expr Method name */
/** @var string|Identifier|Expr Method name */
public $name;
/** @var Node\Arg[] Arguments */
public $args;
@@ -17,19 +18,23 @@ class StaticCall extends Expr
/**
* Constructs a static method call node.
*
* @param Node\Name|Expr $class Class name
* @param string|Expr $name Method name
* @param Node\Arg[] $args Arguments
* @param array $attributes Additional attributes
* @param Node\Name|Expr $class Class name
* @param string|Identifier|Expr $name Method name
* @param Node\Arg[] $args Arguments
* @param array $attributes Additional attributes
*/
public function __construct($class, $name, array $args = array(), array $attributes = array()) {
public function __construct($class, $name, array $args = [], array $attributes = []) {
parent::__construct($attributes);
$this->class = $class;
$this->name = $name;
$this->name = \is_string($name) ? new Identifier($name) : $name;
$this->args = $args;
}
public function getSubNodeNames() {
return array('class', 'name', 'args');
public function getSubNodeNames() : array {
return ['class', 'name', 'args'];
}
public function getType() : string {
return 'Expr_StaticCall';
}
}

View File

@@ -1,31 +1,36 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Name;
use PhpParser\Node\Expr;
use PhpParser\Node\Name;
use PhpParser\Node\VarLikeIdentifier;
class StaticPropertyFetch extends Expr
{
/** @var Name|Expr Class name */
public $class;
/** @var string|Expr Property name */
/** @var VarLikeIdentifier|Expr Property name */
public $name;
/**
* Constructs a static property fetch node.
*
* @param Name|Expr $class Class name
* @param string|Expr $name Property name
* @param array $attributes Additional attributes
* @param Name|Expr $class Class name
* @param string|VarLikeIdentifier|Expr $name Property name
* @param array $attributes Additional attributes
*/
public function __construct($class, $name, array $attributes = array()) {
public function __construct($class, $name, array $attributes = []) {
parent::__construct($attributes);
$this->class = $class;
$this->name = $name;
$this->name = \is_string($name) ? new VarLikeIdentifier($name) : $name;
}
public function getSubNodeNames() {
return array('class', 'name');
public function getSubNodeNames() : array {
return ['class', 'name'];
}
public function getType() : string {
return 'Expr_StaticPropertyFetch';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -21,14 +21,18 @@ class Ternary extends Expr
* @param Expr $else Expression for false
* @param array $attributes Additional attributes
*/
public function __construct(Expr $cond, $if, Expr $else, array $attributes = array()) {
public function __construct(Expr $cond, $if, Expr $else, array $attributes = []) {
parent::__construct($attributes);
$this->cond = $cond;
$this->if = $if;
$this->else = $else;
}
public function getSubNodeNames() {
return array('cond', 'if', 'else');
public function getSubNodeNames() : array {
return ['cond', 'if', 'else'];
}
public function getType() : string {
return 'Expr_Ternary';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -15,12 +15,16 @@ class UnaryMinus extends Expr
* @param Expr $expr Expression
* @param array $attributes Additional attributes
*/
public function __construct(Expr $expr, array $attributes = array()) {
public function __construct(Expr $expr, array $attributes = []) {
parent::__construct($attributes);
$this->expr = $expr;
}
public function getSubNodeNames() {
return array('expr');
public function getSubNodeNames() : array {
return ['expr'];
}
public function getType() : string {
return 'Expr_UnaryMinus';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -15,12 +15,16 @@ class UnaryPlus extends Expr
* @param Expr $expr Expression
* @param array $attributes Additional attributes
*/
public function __construct(Expr $expr, array $attributes = array()) {
public function __construct(Expr $expr, array $attributes = []) {
parent::__construct($attributes);
$this->expr = $expr;
}
public function getSubNodeNames() {
return array('expr');
public function getSubNodeNames() : array {
return ['expr'];
}
public function getType() : string {
return 'Expr_UnaryPlus';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -15,12 +15,16 @@ class Variable extends Expr
* @param string|Expr $name Name
* @param array $attributes Additional attributes
*/
public function __construct($name, array $attributes = array()) {
public function __construct($name, array $attributes = []) {
parent::__construct($attributes);
$this->name = $name;
}
public function getSubNodeNames() {
return array('name');
public function getSubNodeNames() : array {
return ['name'];
}
public function getType() : string {
return 'Expr_Variable';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -15,12 +15,16 @@ class YieldFrom extends Expr
* @param Expr $expr Expression
* @param array $attributes Additional attributes
*/
public function __construct(Expr $expr, array $attributes = array()) {
public function __construct(Expr $expr, array $attributes = []) {
parent::__construct($attributes);
$this->expr = $expr;
}
public function getSubNodeNames() {
return array('expr');
public function getSubNodeNames() : array {
return ['expr'];
}
public function getType() : string {
return 'Expr_YieldFrom';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
@@ -18,13 +18,17 @@ class Yield_ extends Expr
* @param null|Expr $key Key expression
* @param array $attributes Additional attributes
*/
public function __construct(Expr $value = null, Expr $key = null, array $attributes = array()) {
public function __construct(Expr $value = null, Expr $key = null, array $attributes = []) {
parent::__construct($attributes);
$this->key = $key;
$this->value = $value;
}
public function getSubNodeNames() {
return array('key', 'value');
public function getSubNodeNames() : array {
return ['key', 'value'];
}
public function getType() : string {
return 'Expr_Yield';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node;
@@ -11,26 +11,26 @@ interface FunctionLike extends Node
*
* @return bool
*/
public function returnsByRef();
public function returnsByRef() : bool;
/**
* List of parameters
*
* @return Node\Param[]
*/
public function getParams();
public function getParams() : array;
/**
* Get the declared return type or null
*
* @return null|string|Node\Name
*
* @return null|Identifier|Node\Name|Node\NullableType
*/
public function getReturnType();
/**
* The function body
*
* @return Node\Stmt[]
* @return Node\Stmt[]|null
*/
public function getStmts();
}

View File

@@ -0,0 +1,75 @@
<?php declare(strict_types=1);
namespace PhpParser\Node;
use PhpParser\NodeAbstract;
/**
* Represents a non-namespaced name. Namespaced names are represented using Name nodes.
*/
class Identifier extends NodeAbstract
{
/** @var string Identifier as string */
public $name;
private static $specialClassNames = [
'self' => true,
'parent' => true,
'static' => true,
];
/**
* Constructs an identifier node.
*
* @param string $name Identifier as string
* @param array $attributes Additional attributes
*/
public function __construct(string $name, array $attributes = []) {
parent::__construct($attributes);
$this->name = $name;
}
public function getSubNodeNames() : array {
return ['name'];
}
/**
* Get identifier as string.
*
* @return string Identifier as string.
*/
public function toString() : string {
return $this->name;
}
/**
* Get lowercased identifier as string.
*
* @return string Lowercased identifier as string
*/
public function toLowerString() : string {
return strtolower($this->name);
}
/**
* Checks whether the identifier is a special class name (self, parent or static).
*
* @return bool Whether identifier is a special class name
*/
public function isSpecialClassName() : bool {
return isset(self::$specialClassNames[strtolower($this->name)]);
}
/**
* Get identifier as string.
*
* @return string Identifier as string
*/
public function __toString() : string {
return $this->name;
}
public function getType() : string {
return 'Identifier';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node;
@@ -6,26 +6,30 @@ use PhpParser\NodeAbstract;
class Name extends NodeAbstract
{
/** @var string[] Parts of the name */
/**
* @var string[] Parts of the name
*/
public $parts;
private static $specialClassNames = [
'self' => true,
'parent' => true,
'static' => true,
];
/**
* Constructs a name node.
*
* @param string|array $parts Parts of the name (or name as string)
* @param array $attributes Additional attributes
* @param string|string[]|self $name Name as string, part array or Name instance (copy ctor)
* @param array $attributes Additional attributes
*/
public function __construct($parts, array $attributes = array()) {
if (!is_array($parts)) {
$parts = explode('\\', $parts);
}
public function __construct($name, array $attributes = []) {
parent::__construct($attributes);
$this->parts = $parts;
$this->parts = self::prepareName($name);
}
public function getSubNodeNames() {
return array('parts');
public function getSubNodeNames() : array {
return ['parts'];
}
/**
@@ -33,7 +37,7 @@ class Name extends NodeAbstract
*
* @return string First part of the name
*/
public function getFirst() {
public function getFirst() : string {
return $this->parts[0];
}
@@ -42,7 +46,7 @@ class Name extends NodeAbstract
*
* @return string Last part of the name
*/
public function getLast() {
public function getLast() : string {
return $this->parts[count($this->parts) - 1];
}
@@ -51,8 +55,8 @@ class Name extends NodeAbstract
*
* @return bool Whether the name is unqualified
*/
public function isUnqualified() {
return 1 == count($this->parts);
public function isUnqualified() : bool {
return 1 === count($this->parts);
}
/**
@@ -60,7 +64,7 @@ class Name extends NodeAbstract
*
* @return bool Whether the name is qualified
*/
public function isQualified() {
public function isQualified() : bool {
return 1 < count($this->parts);
}
@@ -69,7 +73,7 @@ class Name extends NodeAbstract
*
* @return bool Whether the name is fully qualified
*/
public function isFullyQualified() {
public function isFullyQualified() : bool {
return false;
}
@@ -78,19 +82,48 @@ class Name extends NodeAbstract
*
* @return bool Whether the name is relative
*/
public function isRelative() {
public function isRelative() : bool {
return false;
}
/**
* Returns a string representation of the name by imploding the namespace parts with a separator.
*
* @param string $separator The separator to use (defaults to the namespace separator \)
* Returns a string representation of the name itself, without taking taking the name type into
* account (e.g., not including a leading backslash for fully qualified names).
*
* @return string String representation
*/
public function toString($separator = '\\') {
return implode($separator, $this->parts);
public function toString() : string {
return implode('\\', $this->parts);
}
/**
* Returns a string representation of the name as it would occur in code (e.g., including
* leading backslash for fully qualified names.
*
* @return string String representation
*/
public function toCodeString() : string {
return $this->toString();
}
/**
* Returns lowercased string representation of the name, without taking the name type into
* account (e.g., no leading backslash for fully qualified names).
*
* @return string Lowercased string representation
*/
public function toLowerString() : string {
return strtolower(implode('\\', $this->parts));
}
/**
* Checks whether the identifier is a special class name (self, parent or static).
*
* @return bool Whether identifier is a special class name
*/
public function isSpecialClassName() : bool {
return count($this->parts) === 1
&& isset(self::$specialClassNames[strtolower($this->parts[0])]);
}
/**
@@ -99,83 +132,49 @@ class Name extends NodeAbstract
*
* @return string String representation
*/
public function __toString() {
public function __toString() : string {
return implode('\\', $this->parts);
}
/**
* Sets the whole name.
*
* @deprecated Create a new Name instead, or manually modify the $parts property
*
* @param string|array|self $name The name to set the whole name to
*/
public function set($name) {
$this->parts = self::prepareName($name);
}
/**
* Prepends a name to this name.
*
* @deprecated Use Name::concat($name1, $name2) instead
*
* @param string|array|self $name Name to prepend
*/
public function prepend($name) {
$this->parts = array_merge(self::prepareName($name), $this->parts);
}
/**
* Appends a name to this name.
*
* @deprecated Use Name::concat($name1, $name2) instead
*
* @param string|array|self $name Name to append
*/
public function append($name) {
$this->parts = array_merge($this->parts, self::prepareName($name));
}
/**
* Sets the first part of the name.
*
* @deprecated Use concat($first, $name->slice(1)) instead
*
* @param string|array|self $name The name to set the first part to
*/
public function setFirst($name) {
array_splice($this->parts, 0, 1, self::prepareName($name));
}
/**
* Sets the last part of the name.
*
* @param string|array|self $name The name to set the last part to
*/
public function setLast($name) {
array_splice($this->parts, -1, 1, self::prepareName($name));
}
/**
* Gets a slice of a name (similar to array_slice).
*
* This method returns a new instance of the same type as the original and with the same
* attributes.
*
* If the slice is empty, a Name with an empty parts array is returned. While this is
* meaningless in itself, it works correctly in conjunction with concat().
* If the slice is empty, null is returned. The null value will be correctly handled in
* concatenations using concat().
*
* @param int $offset Offset to start the slice at
* Offset and length have the same meaning as in array_slice().
*
* @return static Sliced name
* @param int $offset Offset to start the slice at (may be negative)
* @param int|null $length Length of the slice (may be negative)
*
* @return static|null Sliced name
*/
public function slice($offset) {
// TODO negative offset and length
if ($offset < 0 || $offset > count($this->parts)) {
public function slice(int $offset, int $length = null) {
$numParts = count($this->parts);
$realOffset = $offset < 0 ? $offset + $numParts : $offset;
if ($realOffset < 0 || $realOffset > $numParts) {
throw new \OutOfBoundsException(sprintf('Offset %d is out of bounds', $offset));
}
return new static(array_slice($this->parts, $offset), $this->attributes);
if (null === $length) {
$realLength = $numParts - $realOffset;
} else {
$realLength = $length < 0 ? $length + $numParts - $realOffset : $length;
if ($realLength < 0 || $realLength > $numParts) {
throw new \OutOfBoundsException(sprintf('Length %d is out of bounds', $length));
}
}
if ($realLength === 0) {
// Empty slice is represented as null
return null;
}
return new static(array_slice($this->parts, $realOffset, $realLength), $this->attributes);
}
/**
@@ -184,37 +183,62 @@ class Name extends NodeAbstract
* The type of the generated instance depends on which class this method is called on, for
* example Name\FullyQualified::concat() will yield a Name\FullyQualified instance.
*
* @param string|array|self $name1 The first name
* @param string|array|self $name2 The second name
* @param array $attributes Attributes to assign to concatenated name
* If one of the arguments is null, a new instance of the other name will be returned. If both
* arguments are null, null will be returned. As such, writing
* Name::concat($namespace, $shortName)
* where $namespace is a Name node or null will work as expected.
*
* @return static Concatenated name
* @param string|string[]|self|null $name1 The first name
* @param string|string[]|self|null $name2 The second name
* @param array $attributes Attributes to assign to concatenated name
*
* @return static|null Concatenated name
*/
public static function concat($name1, $name2, array $attributes = []) {
return new static(
array_merge(self::prepareName($name1), self::prepareName($name2)), $attributes
);
if (null === $name1 && null === $name2) {
return null;
} elseif (null === $name1) {
return new static(self::prepareName($name2), $attributes);
} elseif (null === $name2) {
return new static(self::prepareName($name1), $attributes);
} else {
return new static(
array_merge(self::prepareName($name1), self::prepareName($name2)), $attributes
);
}
}
/**
* Prepares a (string, array or Name node) name for use in name changing methods by converting
* it to an array.
*
* @param string|array|self $name Name to prepare
* @param string|string[]|self $name Name to prepare
*
* @return array Prepared name
* @return string[] Prepared name
*/
private static function prepareName($name) {
if (is_string($name)) {
private static function prepareName($name) : array {
if (\is_string($name)) {
if ('' === $name) {
throw new \InvalidArgumentException('Name cannot be empty');
}
return explode('\\', $name);
} elseif (is_array($name)) {
} elseif (\is_array($name)) {
if (empty($name)) {
throw new \InvalidArgumentException('Name cannot be empty');
}
return $name;
} elseif ($name instanceof self) {
return $name->parts;
}
throw new \InvalidArgumentException(
'When changing a name you need to pass either a string, an array or a Name node'
'Expected string, array of parts or Name instance'
);
}
public function getType() : string {
return 'Name';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Name;
@@ -9,7 +9,7 @@ class FullyQualified extends \PhpParser\Node\Name
*
* @return bool Whether the name is unqualified
*/
public function isUnqualified() {
public function isUnqualified() : bool {
return false;
}
@@ -18,7 +18,7 @@ class FullyQualified extends \PhpParser\Node\Name
*
* @return bool Whether the name is qualified
*/
public function isQualified() {
public function isQualified() : bool {
return false;
}
@@ -27,7 +27,7 @@ class FullyQualified extends \PhpParser\Node\Name
*
* @return bool Whether the name is fully qualified
*/
public function isFullyQualified() {
public function isFullyQualified() : bool {
return true;
}
@@ -36,7 +36,15 @@ class FullyQualified extends \PhpParser\Node\Name
*
* @return bool Whether the name is relative
*/
public function isRelative() {
public function isRelative() : bool {
return false;
}
}
public function toCodeString() : string {
return '\\' . $this->toString();
}
public function getType() : string {
return 'Name_FullyQualified';
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Name;
@@ -9,7 +9,7 @@ class Relative extends \PhpParser\Node\Name
*
* @return bool Whether the name is unqualified
*/
public function isUnqualified() {
public function isUnqualified() : bool {
return false;
}
@@ -18,7 +18,7 @@ class Relative extends \PhpParser\Node\Name
*
* @return bool Whether the name is qualified
*/
public function isQualified() {
public function isQualified() : bool {
return false;
}
@@ -27,7 +27,7 @@ class Relative extends \PhpParser\Node\Name
*
* @return bool Whether the name is fully qualified
*/
public function isFullyQualified() {
public function isFullyQualified() : bool {
return false;
}
@@ -36,7 +36,15 @@ class Relative extends \PhpParser\Node\Name
*
* @return bool Whether the name is relative
*/
public function isRelative() {
public function isRelative() : bool {
return true;
}
}
public function toCodeString() : string {
return 'namespace\\' . $this->toString();
}
public function getType() : string {
return 'Name_Relative';
}
}

View File

@@ -0,0 +1,30 @@
<?php declare(strict_types=1);
namespace PhpParser\Node;
use PhpParser\NodeAbstract;
class NullableType extends NodeAbstract
{
/** @var Identifier|Name Type */
public $type;
/**
* Constructs a nullable type (wrapping another type).
*
* @param string|Identifier|Name $type Type
* @param array $attributes Additional attributes
*/
public function __construct($type, array $attributes = []) {
parent::__construct($attributes);
$this->type = \is_string($type) ? new Identifier($type) : $type;
}
public function getSubNodeNames() : array {
return ['type'];
}
public function getType() : string {
return 'NullableType';
}
}

View File

@@ -1,47 +1,49 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node;
use PhpParser\Error;
use PhpParser\NodeAbstract;
class Param extends NodeAbstract
{
/** @var null|string|Name Typehint */
/** @var null|Identifier|Name|NullableType 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 Expr\Variable|Expr\Error Parameter variable */
public $var;
/** @var null|Expr Default value */
public $default;
/**
* Constructs a parameter node.
*
* @param string $name Name
* @param null|Expr $default Default value
* @param null|string|Name $type Typehint
* @param bool $byRef Whether is passed by reference
* @param bool $variadic Whether this is a variadic argument
* @param array $attributes Additional attributes
* @param Expr\Variable|Expr\Error $var Parameter variable
* @param null|Expr $default Default value
* @param null|string|Name|NullableType $type Typehint
* @param bool $byRef Whether is passed by reference
* @param bool $variadic Whether this is a variadic argument
* @param array $attributes Additional attributes
*/
public function __construct($name, Expr $default = null, $type = null, $byRef = false, $variadic = false, array $attributes = array()) {
public function __construct(
$var, Expr $default = null, $type = null,
bool $byRef = false, bool $variadic = false, array $attributes = []
) {
parent::__construct($attributes);
$this->type = $type;
$this->type = \is_string($type) ? new Identifier($type) : $type;
$this->byRef = $byRef;
$this->variadic = $variadic;
$this->name = $name;
$this->var = $var;
$this->default = $default;
if ($variadic && null !== $default) {
throw new Error('Variadic parameter cannot have a default value', $default->getAttributes());
}
}
public function getSubNodeNames() {
return array('type', 'byRef', 'variadic', 'name', 'default');
public function getSubNodeNames() : array {
return ['type', 'byRef', 'variadic', 'var', 'default'];
}
public function getType() : string {
return 'Param';
}
}

View File

@@ -1,7 +1,7 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node;
abstract class Scalar extends Expr
{
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser\Node\Scalar;
@@ -15,13 +15,13 @@ class DNumber extends Scalar
* @param float $value Value of the number
* @param array $attributes Additional attributes
*/
public function __construct($value, array $attributes = array()) {
public function __construct(float $value, array $attributes = []) {
parent::__construct($attributes);
$this->value = $value;
}
public function getSubNodeNames() {
return array('value');
public function getSubNodeNames() : array {
return ['value'];
}
/**
@@ -33,7 +33,7 @@ class DNumber extends Scalar
*
* @return float The parsed number
*/
public static function parse($str) {
public static function parse(string $str) : float {
// if string contains any of .eE just cast it to float
if (false !== strpbrk($str, '.eE')) {
return (float) $str;
@@ -61,4 +61,8 @@ class DNumber extends Scalar
// dec
return (float) $str;
}
public function getType() : string {
return 'Scalar_DNumber';
}
}

Some files were not shown because too many files have changed in this diff Show More