first commit

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

View File

@ -0,0 +1,44 @@
<?php declare(strict_types=1);
namespace PhpParser\Node;
use PhpParser\NodeAbstract;
class Arg extends NodeAbstract {
/** @var Identifier|null Parameter name (for named parameters) */
public ?Identifier $name;
/** @var Expr Value to pass */
public Expr $value;
/** @var bool Whether to pass by ref */
public bool $byRef;
/** @var bool Whether to unpack the argument */
public bool $unpack;
/**
* Constructs a function call argument node.
*
* @param Expr $value Value to pass
* @param bool $byRef Whether to pass by ref
* @param bool $unpack Whether to unpack the argument
* @param array<string, mixed> $attributes Additional attributes
* @param Identifier|null $name Parameter name (for named parameters)
*/
public function __construct(
Expr $value, bool $byRef = false, bool $unpack = false, array $attributes = [],
?Identifier $name = null
) {
$this->attributes = $attributes;
$this->name = $name;
$this->value = $value;
$this->byRef = $byRef;
$this->unpack = $unpack;
}
public function getSubNodeNames(): array {
return ['name', 'value', 'byRef', 'unpack'];
}
public function getType(): string {
return 'Arg';
}
}

View File

@ -0,0 +1,43 @@
<?php declare(strict_types=1);
namespace PhpParser\Node;
use PhpParser\NodeAbstract;
class ArrayItem extends NodeAbstract {
/** @var null|Expr Key */
public ?Expr $key;
/** @var Expr Value */
public Expr $value;
/** @var bool Whether to assign by reference */
public bool $byRef;
/** @var bool Whether to unpack the argument */
public bool $unpack;
/**
* Constructs an array item node.
*
* @param Expr $value Value
* @param null|Expr $key Key
* @param bool $byRef Whether to assign by reference
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $value, ?Expr $key = null, bool $byRef = false, array $attributes = [], bool $unpack = false) {
$this->attributes = $attributes;
$this->key = $key;
$this->value = $value;
$this->byRef = $byRef;
$this->unpack = $unpack;
}
public function getSubNodeNames(): array {
return ['key', 'value', 'byRef', 'unpack'];
}
public function getType(): string {
return 'ArrayItem';
}
}
// @deprecated compatibility alias
class_alias(ArrayItem::class, Expr\ArrayItem::class);

View File

@ -0,0 +1,33 @@
<?php declare(strict_types=1);
namespace PhpParser\Node;
use PhpParser\Node;
use PhpParser\NodeAbstract;
class Attribute extends NodeAbstract {
/** @var Name Attribute name */
public Name $name;
/** @var list<Arg> Attribute arguments */
public array $args;
/**
* @param Node\Name $name Attribute name
* @param list<Arg> $args Attribute arguments
* @param array<string, mixed> $attributes Additional node attributes
*/
public function __construct(Name $name, array $args = [], array $attributes = []) {
$this->attributes = $attributes;
$this->name = $name;
$this->args = $args;
}
public function getSubNodeNames(): array {
return ['name', 'args'];
}
public function getType(): string {
return 'Attribute';
}
}

View File

@ -0,0 +1,27 @@
<?php declare(strict_types=1);
namespace PhpParser\Node;
use PhpParser\NodeAbstract;
class AttributeGroup extends NodeAbstract {
/** @var Attribute[] Attributes */
public array $attrs;
/**
* @param Attribute[] $attrs PHP attributes
* @param array<string, mixed> $attributes Additional node attributes
*/
public function __construct(array $attrs, array $attributes = []) {
$this->attributes = $attributes;
$this->attrs = $attrs;
}
public function getSubNodeNames(): array {
return ['attrs'];
}
public function getType(): string {
return 'AttributeGroup';
}
}

View File

@ -0,0 +1,36 @@
<?php declare(strict_types=1);
namespace PhpParser\Node;
use PhpParser\NodeAbstract;
class ClosureUse extends NodeAbstract {
/** @var Expr\Variable Variable to use */
public Expr\Variable $var;
/** @var bool Whether to use by reference */
public bool $byRef;
/**
* Constructs a closure use node.
*
* @param Expr\Variable $var Variable to use
* @param bool $byRef Whether to use by reference
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr\Variable $var, bool $byRef = false, array $attributes = []) {
$this->attributes = $attributes;
$this->var = $var;
$this->byRef = $byRef;
}
public function getSubNodeNames(): array {
return ['var', 'byRef'];
}
public function getType(): string {
return 'ClosureUse';
}
}
// @deprecated compatibility alias
class_alias(ClosureUse::class, Expr\ClosureUse::class);

View File

@ -0,0 +1,13 @@
<?php declare(strict_types=1);
namespace PhpParser\Node;
use PhpParser\NodeAbstract;
/**
* This is a base class for complex types, including nullable types and union types.
*
* It does not provide any shared behavior and exists only for type-checking purposes.
*/
abstract class ComplexType extends NodeAbstract {
}

View File

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

View File

@ -0,0 +1,37 @@
<?php declare(strict_types=1);
namespace PhpParser\Node;
use PhpParser\Node;
use PhpParser\NodeAbstract;
class DeclareItem extends NodeAbstract {
/** @var Node\Identifier Key */
public Identifier $key;
/** @var Node\Expr Value */
public Expr $value;
/**
* Constructs a declare key=>value pair node.
*
* @param string|Node\Identifier $key Key
* @param Node\Expr $value Value
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct($key, Node\Expr $value, array $attributes = []) {
$this->attributes = $attributes;
$this->key = \is_string($key) ? new Node\Identifier($key) : $key;
$this->value = $value;
}
public function getSubNodeNames(): array {
return ['key', 'value'];
}
public function getType(): string {
return 'DeclareItem';
}
}
// @deprecated compatibility alias
class_alias(DeclareItem::class, Stmt\DeclareDeclare::class);

View File

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

View File

@ -0,0 +1,33 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
class ArrayDimFetch extends Expr {
/** @var Expr Variable */
public Expr $var;
/** @var null|Expr Array index / dim */
public ?Expr $dim;
/**
* Constructs an array index fetch node.
*
* @param Expr $var Variable
* @param null|Expr $dim Array index / dim
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $var, ?Expr $dim = null, array $attributes = []) {
$this->attributes = $attributes;
$this->var = $var;
$this->dim = $dim;
}
public function getSubNodeNames(): array {
return ['var', 'dim'];
}
public function getType(): string {
return 'Expr_ArrayDimFetch';
}
}

View File

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

View File

@ -0,0 +1,34 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\ArrayItem;
use PhpParser\Node\Expr;
class Array_ extends Expr {
// For use in "kind" attribute
public const KIND_LONG = 1; // array() syntax
public const KIND_SHORT = 2; // [] syntax
/** @var ArrayItem[] Items */
public array $items;
/**
* Constructs an array node.
*
* @param ArrayItem[] $items Items of the array
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(array $items = [], array $attributes = []) {
$this->attributes = $attributes;
$this->items = $items;
}
public function getSubNodeNames(): array {
return ['items'];
}
public function getType(): string {
return 'Expr_Array';
}
}

View File

@ -0,0 +1,84 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\FunctionLike;
class ArrowFunction extends Expr implements FunctionLike {
/** @var bool Whether the closure is static */
public bool $static;
/** @var bool Whether to return by reference */
public bool $byRef;
/** @var Node\Param[] */
public array $params = [];
/** @var null|Node\Identifier|Node\Name|Node\ComplexType */
public ?Node $returnType;
/** @var Expr Expression body */
public Expr $expr;
/** @var Node\AttributeGroup[] */
public array $attrGroups;
/**
* @param array{
* expr: Expr,
* static?: bool,
* byRef?: bool,
* params?: Node\Param[],
* returnType?: null|Node\Identifier|Node\Name|Node\ComplexType,
* attrGroups?: Node\AttributeGroup[]
* } $subNodes Array of the following subnodes:
* 'expr' : Expression body
* 'static' => false : Whether the closure is static
* 'byRef' => false : Whether to return by reference
* 'params' => array() : Parameters
* 'returnType' => null : Return type
* 'attrGroups' => array() : PHP attribute groups
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(array $subNodes, array $attributes = []) {
$this->attributes = $attributes;
$this->static = $subNodes['static'] ?? false;
$this->byRef = $subNodes['byRef'] ?? false;
$this->params = $subNodes['params'] ?? [];
$this->returnType = $subNodes['returnType'] ?? null;
$this->expr = $subNodes['expr'];
$this->attrGroups = $subNodes['attrGroups'] ?? [];
}
public function getSubNodeNames(): array {
return ['attrGroups', 'static', 'byRef', 'params', 'returnType', 'expr'];
}
public function returnsByRef(): bool {
return $this->byRef;
}
public function getParams(): array {
return $this->params;
}
public function getReturnType() {
return $this->returnType;
}
public function getAttrGroups(): array {
return $this->attrGroups;
}
/**
* @return Node\Stmt\Return_[]
*/
public function getStmts(): array {
return [new Node\Stmt\Return_($this->expr)];
}
public function getType(): string {
return 'Expr_ArrowFunction';
}
}

View File

@ -0,0 +1,33 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
class Assign extends Expr {
/** @var Expr Variable */
public Expr $var;
/** @var Expr Expression */
public Expr $expr;
/**
* Constructs an assignment node.
*
* @param Expr $var Variable
* @param Expr $expr Expression
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $var, Expr $expr, array $attributes = []) {
$this->attributes = $attributes;
$this->var = $var;
$this->expr = $expr;
}
public function getSubNodeNames(): array {
return ['var', 'expr'];
}
public function getType(): string {
return 'Expr_Assign';
}
}

View File

@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
abstract class AssignOp extends Expr {
/** @var Expr Variable */
public Expr $var;
/** @var Expr Expression */
public Expr $expr;
/**
* Constructs a compound assignment operation node.
*
* @param Expr $var Variable
* @param Expr $expr Expression
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $var, Expr $expr, array $attributes = []) {
$this->attributes = $attributes;
$this->var = $var;
$this->expr = $expr;
}
public function getSubNodeNames(): array {
return ['var', 'expr'];
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,33 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
class AssignRef extends Expr {
/** @var Expr Variable reference is assigned to */
public Expr $var;
/** @var Expr Variable which is referenced */
public Expr $expr;
/**
* Constructs an assignment node.
*
* @param Expr $var Variable
* @param Expr $expr Expression
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $var, Expr $expr, array $attributes = []) {
$this->attributes = $attributes;
$this->var = $var;
$this->expr = $expr;
}
public function getSubNodeNames(): array {
return ['var', 'expr'];
}
public function getType(): string {
return 'Expr_AssignRef';
}
}

View File

@ -0,0 +1,37 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
abstract class BinaryOp extends Expr {
/** @var Expr The left hand side expression */
public Expr $left;
/** @var Expr The right hand side expression */
public Expr $right;
/**
* Constructs a binary operator node.
*
* @param Expr $left The left hand side expression
* @param Expr $right The right hand side expression
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $left, Expr $right, array $attributes = []) {
$this->attributes = $attributes;
$this->left = $left;
$this->right = $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.
*/
abstract public function getOperatorSigil(): string;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,15 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
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

@ -0,0 +1,15 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
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

@ -0,0 +1,15 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\BinaryOp;
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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
class BitwiseNot extends Expr {
/** @var Expr Expression */
public Expr $expr;
/**
* Constructs a bitwise not node.
*
* @param Expr $expr Expression
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $expr, array $attributes = []) {
$this->attributes = $attributes;
$this->expr = $expr;
}
public function getSubNodeNames(): array {
return ['expr'];
}
public function getType(): string {
return 'Expr_BitwiseNot';
}
}

View File

@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
class BooleanNot extends Expr {
/** @var Expr Expression */
public Expr $expr;
/**
* Constructs a boolean not node.
*
* @param Expr $expr Expression
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $expr, array $attributes = []) {
$this->attributes = $attributes;
$this->expr = $expr;
}
public function getSubNodeNames(): array {
return ['expr'];
}
public function getType(): string {
return 'Expr_BooleanNot';
}
}

View File

@ -0,0 +1,35 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr;
use PhpParser\Node\VariadicPlaceholder;
abstract class CallLike extends Expr {
/**
* Return raw arguments, which may be actual Args, or VariadicPlaceholders for first-class
* callables.
*
* @return array<Arg|VariadicPlaceholder>
*/
abstract public function getRawArgs(): array;
/**
* Returns whether this call expression is actually a first class callable.
*/
public function isFirstClassCallable(): bool {
$rawArgs = $this->getRawArgs();
return count($rawArgs) === 1 && current($rawArgs) instanceof VariadicPlaceholder;
}
/**
* Assert that this is not a first-class callable and return only ordinary Args.
*
* @return Arg[]
*/
public function getArgs(): array {
assert(!$this->isFirstClassCallable());
return $this->getRawArgs();
}
}

View File

@ -0,0 +1,25 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
abstract class Cast extends Expr {
/** @var Expr Expression */
public Expr $expr;
/**
* Constructs a cast node.
*
* @param Expr $expr Expression
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $expr, array $attributes = []) {
$this->attributes = $attributes;
$this->expr = $expr;
}
public function getSubNodeNames(): array {
return ['expr'];
}
}

View File

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

View File

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

View File

@ -0,0 +1,16 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr\Cast;
use PhpParser\Node\Expr\Cast;
class Double extends Cast {
// For use in "kind" attribute
public const KIND_DOUBLE = 1; // "double" syntax
public const KIND_FLOAT = 2; // "float" syntax
public const KIND_REAL = 3; // "real" syntax
public function getType(): string {
return 'Expr_Cast_Double';
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
class Clone_ extends Expr {
/** @var Expr Expression */
public Expr $expr;
/**
* Constructs a clone node.
*
* @param Expr $expr Expression
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $expr, array $attributes = []) {
$this->attributes = $attributes;
$this->expr = $expr;
}
public function getSubNodeNames(): array {
return ['expr'];
}
public function getType(): string {
return 'Expr_Clone';
}
}

View File

@ -0,0 +1,86 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node;
use PhpParser\Node\ClosureUse;
use PhpParser\Node\Expr;
use PhpParser\Node\FunctionLike;
class Closure extends Expr implements FunctionLike {
/** @var bool Whether the closure is static */
public bool $static;
/** @var bool Whether to return by reference */
public bool $byRef;
/** @var Node\Param[] Parameters */
public array $params;
/** @var ClosureUse[] use()s */
public array $uses;
/** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */
public ?Node $returnType;
/** @var Node\Stmt[] Statements */
public array $stmts;
/** @var Node\AttributeGroup[] PHP attribute groups */
public array $attrGroups;
/**
* Constructs a lambda function node.
*
* @param array{
* static?: bool,
* byRef?: bool,
* params?: Node\Param[],
* uses?: ClosureUse[],
* returnType?: null|Node\Identifier|Node\Name|Node\ComplexType,
* stmts?: Node\Stmt[],
* attrGroups?: Node\AttributeGroup[],
* } $subNodes Array of the following optional subnodes:
* 'static' => false : Whether the closure is static
* 'byRef' => false : Whether to return by reference
* 'params' => array(): Parameters
* 'uses' => array(): use()s
* 'returnType' => null : Return type
* 'stmts' => array(): Statements
* 'attrGroups' => array(): PHP attributes groups
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(array $subNodes = [], array $attributes = []) {
$this->attributes = $attributes;
$this->static = $subNodes['static'] ?? false;
$this->byRef = $subNodes['byRef'] ?? false;
$this->params = $subNodes['params'] ?? [];
$this->uses = $subNodes['uses'] ?? [];
$this->returnType = $subNodes['returnType'] ?? null;
$this->stmts = $subNodes['stmts'] ?? [];
$this->attrGroups = $subNodes['attrGroups'] ?? [];
}
public function getSubNodeNames(): array {
return ['attrGroups', 'static', 'byRef', 'params', 'uses', 'returnType', 'stmts'];
}
public function returnsByRef(): bool {
return $this->byRef;
}
public function getParams(): array {
return $this->params;
}
public function getReturnType() {
return $this->returnType;
}
/** @return Node\Stmt[] */
public function getStmts(): array {
return $this->stmts;
}
public function getAttrGroups(): array {
return $this->attrGroups;
}
public function getType(): string {
return 'Expr_Closure';
}
}

View File

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

View File

@ -0,0 +1,30 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
use PhpParser\Node\Name;
class ConstFetch extends Expr {
/** @var Name Constant name */
public Name $name;
/**
* Constructs a const fetch node.
*
* @param Name $name Constant name
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Name $name, array $attributes = []) {
$this->attributes = $attributes;
$this->name = $name;
}
public function getSubNodeNames(): array {
return ['name'];
}
public function getType(): string {
return 'Expr_ConstFetch';
}
}

View File

@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
class Empty_ extends Expr {
/** @var Expr Expression */
public Expr $expr;
/**
* Constructs an empty() node.
*
* @param Expr $expr Expression
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $expr, array $attributes = []) {
$this->attributes = $attributes;
$this->expr = $expr;
}
public function getSubNodeNames(): array {
return ['expr'];
}
public function getType(): string {
return 'Expr_Empty';
}
}

View File

@ -0,0 +1,30 @@
<?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<string, mixed> $attributes Additional attributes
*/
public function __construct(array $attributes = []) {
$this->attributes = $attributes;
}
public function getSubNodeNames(): array {
return [];
}
public function getType(): string {
return 'Expr_Error';
}
}

View File

@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
class ErrorSuppress extends Expr {
/** @var Expr Expression */
public Expr $expr;
/**
* Constructs an error suppress node.
*
* @param Expr $expr Expression
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $expr, array $attributes = []) {
$this->attributes = $attributes;
$this->expr = $expr;
}
public function getSubNodeNames(): array {
return ['expr'];
}
public function getType(): string {
return 'Expr_ErrorSuppress';
}
}

View File

@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
class Eval_ extends Expr {
/** @var Expr Expression */
public Expr $expr;
/**
* Constructs an eval() node.
*
* @param Expr $expr Expression
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $expr, array $attributes = []) {
$this->attributes = $attributes;
$this->expr = $expr;
}
public function getSubNodeNames(): array {
return ['expr'];
}
public function getType(): string {
return 'Expr_Eval';
}
}

View File

@ -0,0 +1,33 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
class Exit_ extends Expr {
/* For use in "kind" attribute */
public const KIND_EXIT = 1;
public const KIND_DIE = 2;
/** @var null|Expr Expression */
public ?Expr $expr;
/**
* Constructs an exit() node.
*
* @param null|Expr $expr Expression
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(?Expr $expr = null, array $attributes = []) {
$this->attributes = $attributes;
$this->expr = $expr;
}
public function getSubNodeNames(): array {
return ['expr'];
}
public function getType(): string {
return 'Expr_Exit';
}
}

View File

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

View File

@ -0,0 +1,38 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
class Include_ extends Expr {
public const TYPE_INCLUDE = 1;
public const TYPE_INCLUDE_ONCE = 2;
public const TYPE_REQUIRE = 3;
public const TYPE_REQUIRE_ONCE = 4;
/** @var Expr Expression */
public Expr $expr;
/** @var int Type of include */
public int $type;
/**
* Constructs an include node.
*
* @param Expr $expr Expression
* @param int $type Type of include
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $expr, int $type, array $attributes = []) {
$this->attributes = $attributes;
$this->expr = $expr;
$this->type = $type;
}
public function getSubNodeNames(): array {
return ['expr', 'type'];
}
public function getType(): string {
return 'Expr_Include';
}
}

View File

@ -0,0 +1,35 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Name;
class Instanceof_ extends Expr {
/** @var Expr Expression */
public Expr $expr;
/** @var Name|Expr Class name */
public Node $class;
/**
* Constructs an instanceof check node.
*
* @param Expr $expr Expression
* @param Name|Expr $class Class name
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $expr, Node $class, array $attributes = []) {
$this->attributes = $attributes;
$this->expr = $expr;
$this->class = $class;
}
public function getSubNodeNames(): array {
return ['expr', 'class'];
}
public function getType(): string {
return 'Expr_Instanceof';
}
}

View File

@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
class Isset_ extends Expr {
/** @var Expr[] Variables */
public array $vars;
/**
* Constructs an array node.
*
* @param Expr[] $vars Variables
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(array $vars, array $attributes = []) {
$this->attributes = $attributes;
$this->vars = $vars;
}
public function getSubNodeNames(): array {
return ['vars'];
}
public function getType(): string {
return 'Expr_Isset';
}
}

View File

@ -0,0 +1,34 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\ArrayItem;
use PhpParser\Node\Expr;
class List_ extends Expr {
// For use in "kind" attribute
public const KIND_LIST = 1; // list() syntax
public const KIND_ARRAY = 2; // [] syntax
/** @var (ArrayItem|null)[] List of items to assign to */
public array $items;
/**
* Constructs a list() destructuring node.
*
* @param (ArrayItem|null)[] $items List of items to assign to
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(array $items, array $attributes = []) {
$this->attributes = $attributes;
$this->items = $items;
}
public function getSubNodeNames(): array {
return ['items'];
}
public function getType(): string {
return 'Expr_List';
}
}

View File

@ -0,0 +1,32 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node;
use PhpParser\Node\MatchArm;
class Match_ extends Node\Expr {
/** @var Node\Expr Condition */
public Node\Expr $cond;
/** @var MatchArm[] */
public array $arms;
/**
* @param Node\Expr $cond Condition
* @param MatchArm[] $arms
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Node\Expr $cond, array $arms = [], array $attributes = []) {
$this->attributes = $attributes;
$this->cond = $cond;
$this->arms = $arms;
}
public function getSubNodeNames(): array {
return ['cond', 'arms'];
}
public function getType(): string {
return 'Expr_Match';
}
}

View File

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

View File

@ -0,0 +1,40 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr;
use PhpParser\Node\VariadicPlaceholder;
class New_ extends CallLike {
/** @var Node\Name|Expr|Node\Stmt\Class_ Class name */
public Node $class;
/** @var array<Arg|VariadicPlaceholder> Arguments */
public array $args;
/**
* Constructs a function call node.
*
* @param Node\Name|Expr|Node\Stmt\Class_ $class Class name (or class node for anonymous classes)
* @param array<Arg|VariadicPlaceholder> $args Arguments
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Node $class, array $args = [], array $attributes = []) {
$this->attributes = $attributes;
$this->class = $class;
$this->args = $args;
}
public function getSubNodeNames(): array {
return ['class', 'args'];
}
public function getType(): string {
return 'Expr_New';
}
public function getRawArgs(): array {
return $this->args;
}
}

View File

@ -0,0 +1,45 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr;
use PhpParser\Node\Identifier;
use PhpParser\Node\VariadicPlaceholder;
class NullsafeMethodCall extends CallLike {
/** @var Expr Variable holding object */
public Expr $var;
/** @var Identifier|Expr Method name */
public Node $name;
/** @var array<Arg|VariadicPlaceholder> Arguments */
public array $args;
/**
* Constructs a nullsafe method call node.
*
* @param Expr $var Variable holding object
* @param string|Identifier|Expr $name Method name
* @param array<Arg|VariadicPlaceholder> $args Arguments
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $var, $name, array $args = [], array $attributes = []) {
$this->attributes = $attributes;
$this->var = $var;
$this->name = \is_string($name) ? new Identifier($name) : $name;
$this->args = $args;
}
public function getSubNodeNames(): array {
return ['var', 'name', 'args'];
}
public function getType(): string {
return 'Expr_NullsafeMethodCall';
}
public function getRawArgs(): array {
return $this->args;
}
}

View File

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

View File

@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
class PostDec extends Expr {
/** @var Expr Variable */
public Expr $var;
/**
* Constructs a post decrement node.
*
* @param Expr $var Variable
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $var, array $attributes = []) {
$this->attributes = $attributes;
$this->var = $var;
}
public function getSubNodeNames(): array {
return ['var'];
}
public function getType(): string {
return 'Expr_PostDec';
}
}

View File

@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
class PostInc extends Expr {
/** @var Expr Variable */
public Expr $var;
/**
* Constructs a post increment node.
*
* @param Expr $var Variable
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $var, array $attributes = []) {
$this->attributes = $attributes;
$this->var = $var;
}
public function getSubNodeNames(): array {
return ['var'];
}
public function getType(): string {
return 'Expr_PostInc';
}
}

View File

@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
class PreDec extends Expr {
/** @var Expr Variable */
public Expr $var;
/**
* Constructs a pre decrement node.
*
* @param Expr $var Variable
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $var, array $attributes = []) {
$this->attributes = $attributes;
$this->var = $var;
}
public function getSubNodeNames(): array {
return ['var'];
}
public function getType(): string {
return 'Expr_PreDec';
}
}

View File

@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
class PreInc extends Expr {
/** @var Expr Variable */
public Expr $var;
/**
* Constructs a pre increment node.
*
* @param Expr $var Variable
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $var, array $attributes = []) {
$this->attributes = $attributes;
$this->var = $var;
}
public function getSubNodeNames(): array {
return ['var'];
}
public function getType(): string {
return 'Expr_PreInc';
}
}

View File

@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
class Print_ extends Expr {
/** @var Expr Expression */
public Expr $expr;
/**
* Constructs an print() node.
*
* @param Expr $expr Expression
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $expr, array $attributes = []) {
$this->attributes = $attributes;
$this->expr = $expr;
}
public function getSubNodeNames(): array {
return ['expr'];
}
public function getType(): string {
return 'Expr_Print';
}
}

View File

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

View File

@ -0,0 +1,30 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
use PhpParser\Node\InterpolatedStringPart;
class ShellExec extends Expr {
/** @var (Expr|InterpolatedStringPart)[] Interpolated string array */
public array $parts;
/**
* Constructs a shell exec (backtick) node.
*
* @param (Expr|InterpolatedStringPart)[] $parts Interpolated string array
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(array $parts, array $attributes = []) {
$this->attributes = $attributes;
$this->parts = $parts;
}
public function getSubNodeNames(): array {
return ['parts'];
}
public function getType(): string {
return 'Expr_ShellExec';
}
}

View File

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

View File

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

View File

@ -0,0 +1,37 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
class Ternary extends Expr {
/** @var Expr Condition */
public Expr $cond;
/** @var null|Expr Expression for true */
public ?Expr $if;
/** @var Expr Expression for false */
public Expr $else;
/**
* Constructs a ternary operator node.
*
* @param Expr $cond Condition
* @param null|Expr $if Expression for true
* @param Expr $else Expression for false
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $cond, ?Expr $if, Expr $else, array $attributes = []) {
$this->attributes = $attributes;
$this->cond = $cond;
$this->if = $if;
$this->else = $else;
}
public function getSubNodeNames(): array {
return ['cond', 'if', 'else'];
}
public function getType(): string {
return 'Expr_Ternary';
}
}

View File

@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node;
class Throw_ extends Node\Expr {
/** @var Node\Expr Expression */
public Node\Expr $expr;
/**
* Constructs a throw expression node.
*
* @param Node\Expr $expr Expression
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Node\Expr $expr, array $attributes = []) {
$this->attributes = $attributes;
$this->expr = $expr;
}
public function getSubNodeNames(): array {
return ['expr'];
}
public function getType(): string {
return 'Expr_Throw';
}
}

View File

@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace PhpParser\Node\Expr;
use PhpParser\Node\Expr;
class UnaryMinus extends Expr {
/** @var Expr Expression */
public Expr $expr;
/**
* Constructs a unary minus node.
*
* @param Expr $expr Expression
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $expr, array $attributes = []) {
$this->attributes = $attributes;
$this->expr = $expr;
}
public function getSubNodeNames(): array {
return ['expr'];
}
public function getType(): string {
return 'Expr_UnaryMinus';
}
}

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