composer update
This commit is contained in:
@@ -19,12 +19,14 @@ class ClassConst implements PhpParser\Builder
|
||||
|
||||
/** @var Node\AttributeGroup[] */
|
||||
protected $attributeGroups = [];
|
||||
/** @var Identifier|Node\Name|Node\ComplexType */
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* Creates a class constant builder
|
||||
*
|
||||
* @param string|Identifier $name Name
|
||||
* @param Node\Expr|bool|null|int|float|string|array $value Value
|
||||
* @param Node\Expr|bool|null|int|float|string|array|\UnitEnum $value Value
|
||||
*/
|
||||
public function __construct($name, $value) {
|
||||
$this->constants = [new Const_($name, BuilderHelpers::normalizeValue($value))];
|
||||
@@ -34,7 +36,7 @@ class ClassConst implements PhpParser\Builder
|
||||
* Add another constant to const group
|
||||
*
|
||||
* @param string|Identifier $name Name
|
||||
* @param Node\Expr|bool|null|int|float|string|array $value Value
|
||||
* @param Node\Expr|bool|null|int|float|string|array|\UnitEnum $value Value
|
||||
*
|
||||
* @return $this The builder instance (for fluid interface)
|
||||
*/
|
||||
@@ -116,6 +118,19 @@ class ClassConst implements PhpParser\Builder
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the constant type.
|
||||
*
|
||||
* @param string|Node\Name|Identifier|Node\ComplexType $type
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setType($type) {
|
||||
$this->type = BuilderHelpers::normalizeType($type);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the built class node.
|
||||
*
|
||||
@@ -126,7 +141,8 @@ class ClassConst implements PhpParser\Builder
|
||||
$this->constants,
|
||||
$this->flags,
|
||||
$this->attributes,
|
||||
$this->attributeGroups
|
||||
$this->attributeGroups,
|
||||
$this->type
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+47
-1
@@ -19,6 +19,8 @@ class Param implements PhpParser\Builder
|
||||
|
||||
protected $variadic = false;
|
||||
|
||||
protected $flags = 0;
|
||||
|
||||
/** @var Node\AttributeGroup[] */
|
||||
protected $attributeGroups = [];
|
||||
|
||||
@@ -95,6 +97,50 @@ class Param implements PhpParser\Builder
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the (promoted) parameter public.
|
||||
*
|
||||
* @return $this The builder instance (for fluid interface)
|
||||
*/
|
||||
public function makePublic() {
|
||||
$this->flags = BuilderHelpers::addModifier($this->flags, Node\Stmt\Class_::MODIFIER_PUBLIC);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the (promoted) parameter protected.
|
||||
*
|
||||
* @return $this The builder instance (for fluid interface)
|
||||
*/
|
||||
public function makeProtected() {
|
||||
$this->flags = BuilderHelpers::addModifier($this->flags, Node\Stmt\Class_::MODIFIER_PROTECTED);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the (promoted) parameter private.
|
||||
*
|
||||
* @return $this The builder instance (for fluid interface)
|
||||
*/
|
||||
public function makePrivate() {
|
||||
$this->flags = BuilderHelpers::addModifier($this->flags, Node\Stmt\Class_::MODIFIER_PRIVATE);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the (promoted) parameter readonly.
|
||||
*
|
||||
* @return $this The builder instance (for fluid interface)
|
||||
*/
|
||||
public function makeReadonly() {
|
||||
$this->flags = BuilderHelpers::addModifier($this->flags, Node\Stmt\Class_::MODIFIER_READONLY);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an attribute group.
|
||||
*
|
||||
@@ -116,7 +162,7 @@ class Param implements PhpParser\Builder
|
||||
public function getNode() : Node {
|
||||
return new Node\Param(
|
||||
new Node\Expr\Variable($this->name),
|
||||
$this->default, $this->type, $this->byRef, $this->variadic, [], 0, $this->attributeGroups
|
||||
$this->default, $this->type, $this->byRef, $this->variadic, [], $this->flags, $this->attributeGroups
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ class BuilderFactory
|
||||
/**
|
||||
* Creates node a for a literal value.
|
||||
*
|
||||
* @param Expr|bool|null|int|float|string|array $value $value
|
||||
* @param Expr|bool|null|int|float|string|array|\UnitEnum $value $value
|
||||
*
|
||||
* @return Expr
|
||||
*/
|
||||
@@ -349,15 +349,15 @@ class BuilderFactory
|
||||
/**
|
||||
* Creates a class constant fetch node.
|
||||
*
|
||||
* @param string|Name|Expr $class Class name
|
||||
* @param string|Identifier $name Constant name
|
||||
* @param string|Name|Expr $class Class name
|
||||
* @param string|Identifier|Expr $name Constant name
|
||||
*
|
||||
* @return Expr\ClassConstFetch
|
||||
*/
|
||||
public function classConstFetch($class, $name): Expr\ClassConstFetch {
|
||||
return new Expr\ClassConstFetch(
|
||||
BuilderHelpers::normalizeNameOrExpr($class),
|
||||
BuilderHelpers::normalizeIdentifier($name)
|
||||
BuilderHelpers::normalizeIdentifierOrExpr($name)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ use PhpParser\Node\ComplexType;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\NullableType;
|
||||
use PhpParser\Node\Scalar;
|
||||
use PhpParser\Node\Stmt;
|
||||
@@ -215,7 +216,7 @@ final class BuilderHelpers
|
||||
* Normalizes a value: Converts nulls, booleans, integers,
|
||||
* floats, strings and arrays into their respective nodes
|
||||
*
|
||||
* @param Node\Expr|bool|null|int|float|string|array $value The value to normalize
|
||||
* @param Node\Expr|bool|null|int|float|string|array|\UnitEnum $value The value to normalize
|
||||
*
|
||||
* @return Expr The normalized value
|
||||
*/
|
||||
@@ -269,6 +270,10 @@ final class BuilderHelpers
|
||||
return new Expr\Array_($items);
|
||||
}
|
||||
|
||||
if ($value instanceof \UnitEnum) {
|
||||
return new Expr\ClassConstFetch(new FullyQualified(\get_class($value)), new Identifier($value->name));
|
||||
}
|
||||
|
||||
throw new \LogicException('Invalid value');
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class ConstExprEvaluator
|
||||
*
|
||||
* @param callable|null $fallbackEvaluator To call if subexpression cannot be evaluated
|
||||
*/
|
||||
public function __construct(callable $fallbackEvaluator = null) {
|
||||
public function __construct(?callable $fallbackEvaluator = null) {
|
||||
$this->fallbackEvaluator = $fallbackEvaluator ?? function(Expr $expr) {
|
||||
throw new ConstExprEvaluationException(
|
||||
"Expression of type {$expr->getType()} cannot be evaluated"
|
||||
|
||||
+6
-3
@@ -19,6 +19,8 @@ class PrintableNewAnonClassNode extends Expr
|
||||
{
|
||||
/** @var Node\AttributeGroup[] PHP attribute groups */
|
||||
public $attrGroups;
|
||||
/** @var int Modifiers */
|
||||
public $flags;
|
||||
/** @var Node\Arg[] Arguments */
|
||||
public $args;
|
||||
/** @var null|Node\Name Name of extended class */
|
||||
@@ -29,11 +31,12 @@ class PrintableNewAnonClassNode extends Expr
|
||||
public $stmts;
|
||||
|
||||
public function __construct(
|
||||
array $attrGroups, array $args, Node\Name $extends = null, array $implements,
|
||||
array $attrGroups, int $flags, array $args, ?Node\Name $extends, array $implements,
|
||||
array $stmts, array $attributes
|
||||
) {
|
||||
parent::__construct($attributes);
|
||||
$this->attrGroups = $attrGroups;
|
||||
$this->flags = $flags;
|
||||
$this->args = $args;
|
||||
$this->extends = $extends;
|
||||
$this->implements = $implements;
|
||||
@@ -46,7 +49,7 @@ class PrintableNewAnonClassNode extends Expr
|
||||
// We don't assert that $class->name is null here, to allow consumers to assign unique names
|
||||
// to anonymous classes for their own purposes. We simplify ignore the name here.
|
||||
return new self(
|
||||
$class->attrGroups, $newNode->args, $class->extends, $class->implements,
|
||||
$class->attrGroups, $class->flags, $newNode->args, $class->extends, $class->implements,
|
||||
$class->stmts, $newNode->getAttributes()
|
||||
);
|
||||
}
|
||||
@@ -56,6 +59,6 @@ class PrintableNewAnonClassNode extends Expr
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
return ['attrGroups', 'args', 'extends', 'implements', 'stmts'];
|
||||
return ['attrGroups', 'flags', 'args', 'extends', 'implements', 'stmts'];
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ class Lexer
|
||||
* @param ErrorHandler|null $errorHandler Error handler to use for lexing errors. Defaults to
|
||||
* ErrorHandler\Throwing
|
||||
*/
|
||||
public function startLexing(string $code, ErrorHandler $errorHandler = null) {
|
||||
public function startLexing(string $code, ?ErrorHandler $errorHandler = null) {
|
||||
if (null === $errorHandler) {
|
||||
$errorHandler = new ErrorHandler\Throwing();
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class Emulative extends Lexer
|
||||
}
|
||||
}
|
||||
|
||||
public function startLexing(string $code, ErrorHandler $errorHandler = null) {
|
||||
public function startLexing(string $code, ?ErrorHandler $errorHandler = null) {
|
||||
$emulators = array_filter($this->emulators, function($emulator) use($code) {
|
||||
return $emulator->isEmulationNeeded($code);
|
||||
});
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ class NameContext
|
||||
*
|
||||
* @param Name|null $namespace Null is the global namespace
|
||||
*/
|
||||
public function startNamespace(Name $namespace = null) {
|
||||
public function startNamespace(?Name $namespace = null) {
|
||||
$this->namespace = $namespace;
|
||||
$this->origAliases = $this->aliases = [
|
||||
Stmt\Use_::TYPE_NORMAL => [],
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ class Arg extends NodeAbstract
|
||||
*/
|
||||
public function __construct(
|
||||
Expr $value, bool $byRef = false, bool $unpack = false, array $attributes = [],
|
||||
Identifier $name = null
|
||||
?Identifier $name = null
|
||||
) {
|
||||
$this->attributes = $attributes;
|
||||
$this->name = $name;
|
||||
|
||||
@@ -18,7 +18,7 @@ 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 = []) {
|
||||
public function __construct(Expr $var, ?Expr $dim = null, array $attributes = []) {
|
||||
$this->attributes = $attributes;
|
||||
$this->var = $var;
|
||||
$this->dim = $dim;
|
||||
|
||||
@@ -23,7 +23,7 @@ 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, bool $byRef = false, array $attributes = [], bool $unpack = false) {
|
||||
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;
|
||||
|
||||
@@ -10,15 +10,15 @@ class ClassConstFetch extends Expr
|
||||
{
|
||||
/** @var Name|Expr Class name */
|
||||
public $class;
|
||||
/** @var Identifier|Error Constant name */
|
||||
/** @var Identifier|Expr|Error Constant name */
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* Constructs a class const fetch node.
|
||||
*
|
||||
* @param Name|Expr $class Class name
|
||||
* @param string|Identifier|Error $name Constant name
|
||||
* @param array $attributes Additional attributes
|
||||
* @param Name|Expr $class Class name
|
||||
* @param string|Identifier|Expr|Error $name Constant name
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($class, $name, array $attributes = []) {
|
||||
$this->attributes = $attributes;
|
||||
@@ -29,7 +29,7 @@ class ClassConstFetch extends Expr
|
||||
public function getSubNodeNames() : array {
|
||||
return ['class', 'name'];
|
||||
}
|
||||
|
||||
|
||||
public function getType() : string {
|
||||
return 'Expr_ClassConstFetch';
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class Exit_ extends Expr
|
||||
* @param null|Expr $expr Expression
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Expr $expr = null, array $attributes = []) {
|
||||
public function __construct(?Expr $expr = null, array $attributes = []) {
|
||||
$this->attributes = $attributes;
|
||||
$this->expr = $expr;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ 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 = []) {
|
||||
public function __construct(?Expr $value = null, ?Expr $key = null, array $attributes = []) {
|
||||
$this->attributes = $attributes;
|
||||
$this->key = $key;
|
||||
$this->value = $value;
|
||||
|
||||
+14
-2
@@ -6,7 +6,10 @@ use PhpParser\NodeAbstract;
|
||||
|
||||
class Name extends NodeAbstract
|
||||
{
|
||||
/** @var string[] Parts of the name */
|
||||
/**
|
||||
* @var string[] Parts of the name
|
||||
* @deprecated Use getParts() instead
|
||||
*/
|
||||
public $parts;
|
||||
|
||||
private static $specialClassNames = [
|
||||
@@ -30,6 +33,15 @@ class Name extends NodeAbstract
|
||||
return ['parts'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parts of name (split by the namespace separator).
|
||||
*
|
||||
* @return string[] Parts of name
|
||||
*/
|
||||
public function getParts(): array {
|
||||
return $this->parts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first part of the name, i.e. everything before the first namespace separator.
|
||||
*
|
||||
@@ -150,7 +162,7 @@ class Name extends NodeAbstract
|
||||
*
|
||||
* @return static|null Sliced name
|
||||
*/
|
||||
public function slice(int $offset, int $length = null) {
|
||||
public function slice(int $offset, ?int $length = null) {
|
||||
$numParts = count($this->parts);
|
||||
|
||||
$realOffset = $offset < 0 ? $offset + $numParts : $offset;
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ class Param extends NodeAbstract
|
||||
* @param AttributeGroup[] $attrGroups PHP attribute groups
|
||||
*/
|
||||
public function __construct(
|
||||
$var, Expr $default = null, $type = null,
|
||||
$var, ?Expr $default = null, $type = null,
|
||||
bool $byRef = false, bool $variadic = false,
|
||||
array $attributes = [],
|
||||
int $flags = 0,
|
||||
|
||||
@@ -120,7 +120,7 @@ class String_ extends Scalar
|
||||
} elseif ('u' === $str[0]) {
|
||||
return self::codePointToUtf8(hexdec($matches[2]));
|
||||
} else {
|
||||
return chr(octdec($str));
|
||||
return chr(octdec($str) & 255);
|
||||
}
|
||||
},
|
||||
$str
|
||||
|
||||
@@ -15,7 +15,7 @@ class Break_ extends Node\Stmt
|
||||
* @param null|Node\Expr $num Number of loops to break
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $num = null, array $attributes = []) {
|
||||
public function __construct(?Node\Expr $num = null, array $attributes = []) {
|
||||
$this->attributes = $attributes;
|
||||
$this->num = $num;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class Catch_ extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(
|
||||
array $types, Expr\Variable $var = null, array $stmts = [], array $attributes = []
|
||||
array $types, ?Expr\Variable $var = null, array $stmts = [], array $attributes = []
|
||||
) {
|
||||
$this->attributes = $attributes;
|
||||
$this->types = $types;
|
||||
|
||||
@@ -10,31 +10,36 @@ class ClassConst extends Node\Stmt
|
||||
public $flags;
|
||||
/** @var Node\Const_[] Constant declarations */
|
||||
public $consts;
|
||||
/** @var Node\AttributeGroup[] */
|
||||
/** @var Node\AttributeGroup[] PHP attribute groups */
|
||||
public $attrGroups;
|
||||
/** @var Node\Identifier|Node\Name|Node\ComplexType|null Type declaration */
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* Constructs a class const list node.
|
||||
*
|
||||
* @param Node\Const_[] $consts Constant declarations
|
||||
* @param int $flags Modifiers
|
||||
* @param array $attributes Additional attributes
|
||||
* @param Node\AttributeGroup[] $attrGroups PHP attribute groups
|
||||
* @param Node\Const_[] $consts Constant declarations
|
||||
* @param int $flags Modifiers
|
||||
* @param array $attributes Additional attributes
|
||||
* @param Node\AttributeGroup[] $attrGroups PHP attribute groups
|
||||
* @param null|string|Node\Identifier|Node\Name|Node\ComplexType $type Type declaration
|
||||
*/
|
||||
public function __construct(
|
||||
array $consts,
|
||||
int $flags = 0,
|
||||
array $attributes = [],
|
||||
array $attrGroups = []
|
||||
array $attrGroups = [],
|
||||
$type = null
|
||||
) {
|
||||
$this->attributes = $attributes;
|
||||
$this->flags = $flags;
|
||||
$this->consts = $consts;
|
||||
$this->attrGroups = $attrGroups;
|
||||
$this->type = \is_string($type) ? new Node\Identifier($type) : $type;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
return ['attrGroups', 'flags', 'consts'];
|
||||
return ['attrGroups', 'flags', 'type', 'consts'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,7 @@ class Continue_ extends Node\Stmt
|
||||
* @param null|Node\Expr $num Number of loops to continue
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $num = null, array $attributes = []) {
|
||||
public function __construct(?Node\Expr $num = null, array $attributes = []) {
|
||||
$this->attributes = $attributes;
|
||||
$this->num = $num;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class Declare_ extends Node\Stmt
|
||||
* @param Node\Stmt[]|null $stmts Statements
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $declares, array $stmts = null, array $attributes = []) {
|
||||
public function __construct(array $declares, ?array $stmts = null, array $attributes = []) {
|
||||
$this->attributes = $attributes;
|
||||
$this->declares = $declares;
|
||||
$this->stmts = $stmts;
|
||||
|
||||
@@ -20,7 +20,7 @@ class EnumCase extends Node\Stmt
|
||||
* @param AttributeGroup[] $attrGroups PHP attribute groups
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, Node\Expr $expr = null, array $attrGroups = [], array $attributes = []) {
|
||||
public function __construct($name, ?Node\Expr $expr = null, array $attrGroups = [], array $attributes = []) {
|
||||
parent::__construct($attributes);
|
||||
$this->name = \is_string($name) ? new Node\Identifier($name) : $name;
|
||||
$this->expr = $expr;
|
||||
|
||||
@@ -22,7 +22,7 @@ class Namespace_ extends Node\Stmt
|
||||
* @param null|Node\Stmt[] $stmts Statements
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Name $name = null, $stmts = [], array $attributes = []) {
|
||||
public function __construct(?Node\Name $name = null, $stmts = [], array $attributes = []) {
|
||||
$this->attributes = $attributes;
|
||||
$this->name = $name;
|
||||
$this->stmts = $stmts;
|
||||
|
||||
@@ -18,7 +18,7 @@ class PropertyProperty extends Node\Stmt
|
||||
* @param null|Node\Expr $default Default value
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, Node\Expr $default = null, array $attributes = []) {
|
||||
public function __construct($name, ?Node\Expr $default = null, array $attributes = []) {
|
||||
$this->attributes = $attributes;
|
||||
$this->name = \is_string($name) ? new Node\VarLikeIdentifier($name) : $name;
|
||||
$this->default = $default;
|
||||
|
||||
@@ -15,7 +15,7 @@ class Return_ extends Node\Stmt
|
||||
* @param null|Node\Expr $expr Expression
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(Node\Expr $expr = null, array $attributes = []) {
|
||||
public function __construct(?Node\Expr $expr = null, array $attributes = []) {
|
||||
$this->attributes = $attributes;
|
||||
$this->expr = $expr;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class StaticVar extends Node\Stmt
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(
|
||||
Expr\Variable $var, Node\Expr $default = null, array $attributes = []
|
||||
Expr\Variable $var, ?Node\Expr $default = null, array $attributes = []
|
||||
) {
|
||||
$this->attributes = $attributes;
|
||||
$this->var = $var;
|
||||
|
||||
@@ -21,7 +21,7 @@ class TryCatch extends Node\Stmt
|
||||
* @param null|Finally_ $finally Optional finally node
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $stmts, array $catches, Finally_ $finally = null, array $attributes = []) {
|
||||
public function __construct(array $stmts, array $catches, ?Finally_ $finally = null, array $attributes = []) {
|
||||
$this->attributes = $attributes;
|
||||
$this->stmts = $stmts;
|
||||
$this->catches = $catches;
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ class NodeDumper
|
||||
*
|
||||
* @return string Dumped value
|
||||
*/
|
||||
public function dump($node, string $code = null) : string {
|
||||
public function dump($node, ?string $code = null) : string {
|
||||
$this->code = $code;
|
||||
return $this->dumpRecursive($node);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class NameResolver extends NodeVisitorAbstract
|
||||
* @param ErrorHandler|null $errorHandler Error handler
|
||||
* @param array $options Options
|
||||
*/
|
||||
public function __construct(ErrorHandler $errorHandler = null, array $options = []) {
|
||||
public function __construct(?ErrorHandler $errorHandler = null, array $options = []) {
|
||||
$this->nameContext = new NameContext($errorHandler ?? new ErrorHandler\Throwing);
|
||||
$this->preserveOriginalNames = $options['preserveOriginalNames'] ?? false;
|
||||
$this->replaceNodes = $options['replaceNodes'] ?? true;
|
||||
@@ -118,6 +118,9 @@ class NameResolver extends NodeVisitorAbstract
|
||||
$this->addNamespacedName($const);
|
||||
}
|
||||
} else if ($node instanceof Stmt\ClassConst) {
|
||||
if (null !== $node->type) {
|
||||
$node->type = $this->resolveType($node->type);
|
||||
}
|
||||
$this->resolveAttrGroups($node);
|
||||
} else if ($node instanceof Stmt\EnumCase) {
|
||||
$this->resolveAttrGroups($node);
|
||||
@@ -161,7 +164,7 @@ class NameResolver extends NodeVisitorAbstract
|
||||
return null;
|
||||
}
|
||||
|
||||
private function addAlias(Stmt\UseUse $use, int $type, Name $prefix = null) {
|
||||
private function addAlias(Stmt\UseUse $use, int $type, ?Name $prefix = null) {
|
||||
// Add prefix for group uses
|
||||
$name = $prefix ? Name::concat($prefix, $use->name) : $use->name;
|
||||
// Type is determined either by individual element or whole use declaration
|
||||
|
||||
+1
-1
@@ -14,5 +14,5 @@ interface Parser
|
||||
* @return Node\Stmt[]|null Array of statements (or null non-throwing error handler is used and
|
||||
* the parser was unable to recover from an error).
|
||||
*/
|
||||
public function parse(string $code, ErrorHandler $errorHandler = null);
|
||||
public function parse(string $code, ?ErrorHandler $errorHandler = null);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class Multiple implements Parser
|
||||
$this->parsers = $parsers;
|
||||
}
|
||||
|
||||
public function parse(string $code, ErrorHandler $errorHandler = null) {
|
||||
public function parse(string $code, ?ErrorHandler $errorHandler = null) {
|
||||
if (null === $errorHandler) {
|
||||
$errorHandler = new ErrorHandler\Throwing;
|
||||
}
|
||||
|
||||
+283
-283
@@ -27,7 +27,7 @@ class Php5 extends \PhpParser\ParserAbstract
|
||||
protected $unexpectedTokenRule = 32767;
|
||||
|
||||
protected $YY2TBLSTATE = 415;
|
||||
protected $numNonLeafStates = 663;
|
||||
protected $numNonLeafStates = 664;
|
||||
|
||||
protected $symbolToName = array(
|
||||
"EOF",
|
||||
@@ -244,116 +244,116 @@ class Php5 extends \PhpParser\ParserAbstract
|
||||
);
|
||||
|
||||
protected $action = array(
|
||||
700, 670, 671, 672, 673, 674, 286, 675, 676, 677,
|
||||
713, 714, 223, 224, 225, 226, 227, 228, 229, 230,
|
||||
701, 671, 672, 673, 674, 675, 286, 676, 677, 678,
|
||||
714, 715, 223, 224, 225, 226, 227, 228, 229, 230,
|
||||
231, 232, 0, 233, 234, 235, 236, 237, 238, 239,
|
||||
240, 241, 242, 243, 244,-32766,-32766,-32766,-32766,-32766,
|
||||
-32766,-32766,-32766,-32766,-32767,-32767,-32767,-32767, 245, 246,
|
||||
242, 243, 244,-32766,-32766, 678,-32766,-32766,-32766,-32766,
|
||||
-32766,-32766,-32766,-32766,-32766, 1229, 245, 246, 1230, 679,
|
||||
680, 681, 682, 683, 684, 685, 899, 900, 747,-32766,
|
||||
-32766,-32766,-32766,-32766,-32766, 686, 687, 688, 689, 690,
|
||||
691, 692, 693, 694, 695, 696, 716, 739, 717, 718,
|
||||
719, 720, 708, 709, 710, 738, 711, 712, 697, 698,
|
||||
699, 701, 702, 703, 741, 742, 743, 744, 745, 746,
|
||||
875, 704, 705, 706, 707, 737, 728, 726, 727, 723,
|
||||
724, 1046, 715, 721, 722, 729, 730, 732, 731, 733,
|
||||
734, 55, 56, 425, 57, 58, 725, 736, 735, 755,
|
||||
242, 243, 244,-32766,-32766, 679,-32766,-32766,-32766,-32766,
|
||||
-32766,-32766,-32766,-32766,-32766, 1230, 245, 246, 1231, 680,
|
||||
681, 682, 683, 684, 685, 686, 900, 901, 748,-32766,
|
||||
-32766,-32766,-32766,-32766,-32766, 687, 688, 689, 690, 691,
|
||||
692, 693, 694, 695, 696, 697, 717, 740, 718, 719,
|
||||
720, 721, 709, 710, 711, 739, 712, 713, 698, 699,
|
||||
700, 702, 703, 704, 742, 743, 744, 745, 746, 747,
|
||||
876, 705, 706, 707, 708, 738, 729, 727, 728, 724,
|
||||
725, 1047, 716, 722, 723, 730, 731, 733, 732, 734,
|
||||
735, 55, 56, 425, 57, 58, 726, 737, 736, 756,
|
||||
59, 60, -226, 61,-32766,-32766,-32766,-32766,-32766,-32766,
|
||||
-32766,-32766,-32766,-32766, 337,-32767,-32767,-32767,-32767, 29,
|
||||
107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
|
||||
117, 118, 119, 620,-32766,-32766,-32766,-32766, 62, 63,
|
||||
1046,-32766,-32766,-32766, 64, 419, 65, 294, 295, 66,
|
||||
67, 68, 69, 70, 71, 72, 73, 823, 25, 302,
|
||||
74, 418, 984, 986, 669, 668, 1100, 1101, 1078, 755,
|
||||
755, 767, 1220, 768, 470,-32766,-32766,-32766, 341, 749,
|
||||
824, 54,-32767,-32767,-32767,-32767, 98, 99, 100, 101,
|
||||
102, 220, 221, 222, 362, 876,-32766, 27,-32766,-32766,
|
||||
-32766,-32766,-32766, 1046, 493, 126, 1080, 1079, 1081, 370,
|
||||
1068, 930, 207, 478, 479, 952, 953, 954, 951, 950,
|
||||
949, 128, 480, 481, 803, 1106, 1107, 1108, 1109, 1103,
|
||||
1104, 319, 32, 297, 10, 211, -515, 1110, 1105, 669,
|
||||
668, 1080, 1079, 1081, 220, 221, 222, 41, 364, 341,
|
||||
334, 421, 336, 426, -128, -128, -128, 313, 1046, 469,
|
||||
-4, 824, 54, 812, 770, 207, 40, 21, 427, -128,
|
||||
471, -128, 472, -128, 473, -128, 1046, 428, 220, 221,
|
||||
117, 118, 119, 621,-32766,-32766,-32766,-32766, 62, 63,
|
||||
1047,-32766,-32766,-32766, 64, 419, 65, 294, 295, 66,
|
||||
67, 68, 69, 70, 71, 72, 73, 824, 25, 302,
|
||||
74, 418, 985, 987, 670, 669, 1101, 1102, 1079, 756,
|
||||
756, 768, 1221, 769, 470,-32766,-32766,-32766, 341, 750,
|
||||
825, 54,-32767,-32767,-32767,-32767, 98, 99, 100, 101,
|
||||
102, 220, 221, 222, 362, 877,-32766, 27,-32766,-32766,
|
||||
-32766,-32766,-32766, 1047, 492, 126, 1081, 1080, 1082, 370,
|
||||
1069, 931, 207, 478, 479, 953, 954, 955, 952, 951,
|
||||
950, 128, 480, 481, 804, 1107, 1108, 1109, 1110, 1104,
|
||||
1105, 319, 32, 297, 10, 211, -515, 1111, 1106, 670,
|
||||
669, 1081, 1080, 1082, 220, 221, 222, 41, 364, 341,
|
||||
334, 421, 336, 426, -128, -128, -128, 313, 1047, 469,
|
||||
-4, 825, 54, 813, 597, 207, 40, 21, 427, -128,
|
||||
471, -128, 472, -128, 473, -128, 1047, 428, 220, 221,
|
||||
222,-32766, 33, 34, 429, 361, 327, 52, 35, 474,
|
||||
-32766,-32766,-32766, 342, 357, 358, 475, 476, 48, 207,
|
||||
249, 669, 668, 477, 443, 300, 795, 846, 430, 431,
|
||||
28,-32766, 814,-32766,-32766,-32766,-32766,-32766,-32766,-32766,
|
||||
-32767,-32767,-32767,-32767,-32767, 952, 953, 954, 951, 950,
|
||||
949, 422, 755, 424, 426, 826, 634, -128,-32766,-32766,
|
||||
469, 824, 54, 288, 812, 1151, 755, 40, 21, 427,
|
||||
317, 471, 345, 472, 129, 473, 9, 1186, 428, 769,
|
||||
360, 324, 905, 33, 34, 429, 361, 1046, 415, 35,
|
||||
474, 944, 1068, 315, 125, 357, 358, 475, 476,-32766,
|
||||
-32766,-32766, 926, 302, 477, 121, 1068, 759, 846, 430,
|
||||
431, 669, 668, 423, 755, 1152, 809, 1046, 480, 766,
|
||||
-32766, 805,-32766,-32766,-32766,-32766, -261, 127, 347, 436,
|
||||
841, 341, 1078, 1200, 426, 446, 826, 634, -4, 807,
|
||||
469, 824, 54, 436, 812, 341, 755, 40, 21, 427,
|
||||
444, 471, 130, 472, 1068, 473, 346, 767, 428, 768,
|
||||
-211, -211, -211, 33, 34, 429, 361, 308, 1076, 35,
|
||||
474,-32766,-32766,-32766, 1046, 357, 358, 475, 476,-32766,
|
||||
-32766,-32766, 906, 120, 477, 539, 1068, 795, 846, 430,
|
||||
431, 436,-32766, 341,-32766,-32766,-32766, 1046, 480, 810,
|
||||
-32766, 925,-32766,-32766, 754, 1080, 1079, 1081, 49,-32766,
|
||||
-32766,-32766, 749, 751, 426, 1201, 826, 634, -211, 30,
|
||||
469, 669, 668, 436, 812, 341, 75, 40, 21, 427,
|
||||
-32766, 471, 1064, 472, 124, 473, 669, 668, 428, 212,
|
||||
-210, -210, -210, 33, 34, 429, 361, 51, 1186, 35,
|
||||
474, 755,-32766,-32766,-32766, 357, 358, 475, 476, 213,
|
||||
824, 54, 221, 222, 477, 20, 581, 795, 846, 430,
|
||||
431, 220, 221, 222, 755, 222, 247, 78, 79, 80,
|
||||
81, 341, 207, 517, 103, 104, 105, 752, 307, 131,
|
||||
637, 1068, 207, 341, 207, 122, 826, 634, -210, 36,
|
||||
249, 670, 669, 477, 443, 300, 796, 847, 430, 431,
|
||||
28,-32766, 815,-32766,-32766,-32766,-32766,-32766,-32766,-32766,
|
||||
-32767,-32767,-32767,-32767,-32767, 953, 954, 955, 952, 951,
|
||||
950, 422, 756, 424, 426, 827, 635, -128,-32766,-32766,
|
||||
469, 825, 54, 288, 813, 1152, 756, 40, 21, 427,
|
||||
317, 471, 345, 472, 129, 473, 9, 1187, 428, 612,
|
||||
360, 324, 906, 33, 34, 429, 361, 1047, 415, 35,
|
||||
474, 945, 1069, 315, 125, 357, 358, 475, 476,-32766,
|
||||
-32766,-32766, 927, 302, 477, 121, 1069, 760, 847, 430,
|
||||
431, 670, 669, 423, 756, 1153, 810, 1047, 480, 767,
|
||||
-32766, 806,-32766,-32766,-32766,-32766, -261, 127, 347, 436,
|
||||
842, 341, 1079, 1201, 426, 446, 827, 635, -4, 808,
|
||||
469, 825, 54, 436, 813, 341, 756, 40, 21, 427,
|
||||
444, 471, 130, 472, 1069, 473, 346, 768, 428, 769,
|
||||
-211, -211, -211, 33, 34, 429, 361, 308, 1077, 35,
|
||||
474,-32766,-32766,-32766, 1047, 357, 358, 475, 476,-32766,
|
||||
-32766,-32766, 907, 120, 477, 538, 1069, 796, 847, 430,
|
||||
431, 436,-32766, 341,-32766,-32766,-32766, 1047, 480, 811,
|
||||
-32766, 926,-32766,-32766, 755, 1081, 1080, 1082, 49,-32766,
|
||||
-32766,-32766, 750, 752, 426, 1202, 827, 635, -211, 30,
|
||||
469, 670, 669, 436, 813, 341, 75, 40, 21, 427,
|
||||
-32766, 471, 1065, 472, 124, 473, 670, 669, 428, 212,
|
||||
-210, -210, -210, 33, 34, 429, 361, 51, 1187, 35,
|
||||
474, 756,-32766,-32766,-32766, 357, 358, 475, 476, 213,
|
||||
825, 54, 221, 222, 477, 20, 580, 796, 847, 430,
|
||||
431, 220, 221, 222, 756, 222, 247, 78, 79, 80,
|
||||
81, 341, 207, 516, 103, 104, 105, 753, 307, 131,
|
||||
638, 1069, 207, 341, 207, 122, 827, 635, -210, 36,
|
||||
106, 82, 83, 84, 85, 86, 87, 88, 89, 90,
|
||||
91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
|
||||
101, 102, 103, 104, 105, 1112, 307, 346, 436, 214,
|
||||
341, 824, 54, 426, 123, 250, 129, 134, 106, 469,
|
||||
-32766, 572, 1112, 812, 245, 246, 40, 21, 427, 251,
|
||||
471, 252, 472, 341, 473, 453, 22, 428, 207, 899,
|
||||
900, 638, 33, 34, 429, 824, 54, -86, 35, 474,
|
||||
101, 102, 103, 104, 105, 1113, 307, 346, 436, 214,
|
||||
341, 825, 54, 426, 123, 250, 129, 134, 106, 469,
|
||||
-32766, 571, 1113, 813, 245, 246, 40, 21, 427, 251,
|
||||
471, 252, 472, 341, 473, 453, 22, 428, 207, 900,
|
||||
901, 639, 33, 34, 429, 825, 54, -86, 35, 474,
|
||||
220, 221, 222, 314, 357, 358, 100, 101, 102, 239,
|
||||
240, 241, 645, 477, -230, 458, 589, 135, 374, 596,
|
||||
597, 207, 760, 640, 648, 642, 941, 654, 929, 662,
|
||||
822, 133, 307, 837, 426,-32766, 106, 749, 43, 44,
|
||||
469, 45, 442, 46, 812, 826, 634, 40, 21, 427,
|
||||
240, 241, 646, 477, -230, 458, 588, 135, 374, 595,
|
||||
596, 207, 761, 641, 649, 643, 942, 655, 930, 663,
|
||||
823, 133, 307, 838, 426,-32766, 106, 750, 43, 44,
|
||||
469, 45, 442, 46, 813, 827, 635, 40, 21, 427,
|
||||
47, 471, 50, 472, 53, 473, 132, 608, 428, 302,
|
||||
604, -280,-32766, 33, 34, 429, 824, 54, 426, 35,
|
||||
474, 755, 957, -84, 469, 357, 358, 521, 812, 628,
|
||||
363, 40, 21, 427, 477, 471, 575, 472, -515, 473,
|
||||
847, 616, 428, -423,-32766, 11, 646, 33, 34, 429,
|
||||
824, 54, 445, 35, 474, 462, 285, 578, 1111, 357,
|
||||
358, 593, 369, 848, 594, 290, 826, 634, 477, 0,
|
||||
0, 532, 0, 0, 325, 0, 0, 0, 0, 0,
|
||||
651, 0, 0, 0, 322, 326, 0, 0, 0, 426,
|
||||
0, 0, 0, 0, 323, 469, 316, 318, -516, 812,
|
||||
862, 634, 40, 21, 427, 0, 471, 0, 472, 0,
|
||||
473, 1158, 0, 428, 0, -414, 6, 7, 33, 34,
|
||||
429, 824, 54, 426, 35, 474, 12, 14, 373, 469,
|
||||
357, 358, -424, 812, 563, 754, 40, 21, 427, 477,
|
||||
471, 248, 472, 839, 473, 38, 39, 428, 657, 658,
|
||||
765, 813, 33, 34, 429, 821, 800, 815, 35, 474,
|
||||
215, 216, 878, 869, 357, 358, 217, 870, 218, 798,
|
||||
863, 826, 634, 477, 860, 858, 936, 937, 934, 820,
|
||||
209, 804, 806, 808, 811, 933, 763, 764, 1100, 1101,
|
||||
935, 659, 78, 335, 426, 359, 1102, 635, 639, 641,
|
||||
469, 643, 644, 647, 812, 826, 634, 40, 21, 427,
|
||||
649, 471, 650, 472, 652, 473, 653, 636, 428, 796,
|
||||
1226, 1228, 762, 33, 34, 429, 215, 216, 845, 35,
|
||||
474, 761, 217, 844, 218, 357, 358, 1227, 843, 1060,
|
||||
831, 1048, 842, 1049, 477, 559, 209, 1106, 1107, 1108,
|
||||
1109, 1103, 1104, 398, 1100, 1101, 829, 942, 867, 1110,
|
||||
1105, 868, 1102, 457, 1225, 1194, 1192, 1177, 1157, 219,
|
||||
1190, 1091, 917, 1198, 1188, 0, 826, 634, 24, -433,
|
||||
26, 31, 37, 42, 76, 77, 210, 287, 292, 293,
|
||||
604, -280,-32766, 33, 34, 429, 825, 54, 426, 35,
|
||||
474, 756, 958, -84, 469, 357, 358, 520, 813, 629,
|
||||
363, 40, 21, 427, 477, 471, 574, 472, -515, 473,
|
||||
848, 617, 428, -423,-32766, 11, 647, 33, 34, 429,
|
||||
825, 54, 445, 35, 474, 462, 285, 577, 1112, 357,
|
||||
358, 592, 369, 849, 593, 290, 827, 635, 477, 0,
|
||||
0, 531, 0, 0, 325, 0, 0, 0, 0, 0,
|
||||
652, 0, 0, 0, 322, 326, 0, 0, 0, 426,
|
||||
0, 0, 0, 0, 323, 469, 316, 318, -516, 813,
|
||||
863, 635, 40, 21, 427, 0, 471, 0, 472, 0,
|
||||
473, 1159, 0, 428, 0, -414, 6, 7, 33, 34,
|
||||
429, 825, 54, 426, 35, 474, 12, 14, 373, 469,
|
||||
357, 358, -424, 813, 562, 755, 40, 21, 427, 477,
|
||||
471, 248, 472, 840, 473, 38, 39, 428, 658, 659,
|
||||
814, 822, 33, 34, 429, 801, 816, 879, 35, 474,
|
||||
215, 216, 870, 871, 357, 358, 217, 771, 218, 799,
|
||||
864, 827, 635, 477, 770, 861, 859, 937, 938, 935,
|
||||
209, 821, 805, 807, 809, 812, 934, 764, 1101, 1102,
|
||||
765, 936, 24, 78, 426, 335, 1103, 359, 636, 640,
|
||||
469, 642, 644, 645, 813, 827, 635, 40, 21, 427,
|
||||
648, 471, 650, 472, 651, 473, 653, 654, 428, 637,
|
||||
26, 660, 797, 33, 34, 429, 215, 216, 1227, 35,
|
||||
474, 1229, 217, 763, 218, 357, 358, 846, 762, 845,
|
||||
1228, 844, 1061, 832, 477, 558, 209, 1107, 1108, 1109,
|
||||
1110, 1104, 1105, 398, 1101, 1102, 1049, 843, 1050, 1111,
|
||||
1106, 830, 1103, 943, 868, 869, 457, 1226, 1158, 219,
|
||||
1195, 1193, 1178, 1191, 1092, 918, 827, 635, 31, 1199,
|
||||
1189, 1056, 37, 42, 76, 77, 210, 287, 292, 293,
|
||||
308, 309, 310, 311, 339, 356, 416, 0, -227, -226,
|
||||
16, 17, 18, 393, 454, 461, 463, 467, 553, 625,
|
||||
1051, 559, 1054, 1106, 1107, 1108, 1109, 1103, 1104, 398,
|
||||
907, 1116, 1050, 1026, 564, 1110, 1105, 1025, 1093, 1055,
|
||||
0, 1044, 0, 1057, 1056, 219, 1059, 1058, 1075, 0,
|
||||
1191, 1176, 1172, 1189, 1090, 1223, 1117, 1171, 600
|
||||
16, 17, 18, 393, 454, 461, 463, 467, 552, 626,
|
||||
1052, 558, 1055, 1107, 1108, 1109, 1110, 1104, 1105, 398,
|
||||
908, 1117, 1051, 1027, 563, 1111, 1106, 1026, 1094, 1058,
|
||||
0, -433, 1045, 0, 1057, 219, 1060, 1059, 1076, 0,
|
||||
1192, 1177, 1173, 1190, 1091, 1224, 1118, 1172, 600
|
||||
);
|
||||
|
||||
protected $actionCheck = array(
|
||||
@@ -451,26 +451,26 @@ class Php5 extends \PhpParser\ParserAbstract
|
||||
50, 51, 156, 156, 115, 116, 56, 156, 58, 156,
|
||||
156, 156, 157, 124, 156, 156, 156, 156, 156, 156,
|
||||
70, 156, 156, 156, 156, 156, 156, 156, 78, 79,
|
||||
156, 158, 157, 157, 74, 157, 86, 157, 157, 157,
|
||||
156, 156, 159, 157, 74, 157, 86, 157, 157, 157,
|
||||
80, 157, 157, 157, 84, 156, 157, 87, 88, 89,
|
||||
157, 91, 157, 93, 157, 95, 157, 157, 98, 158,
|
||||
158, 158, 158, 103, 104, 105, 50, 51, 158, 109,
|
||||
157, 91, 157, 93, 157, 95, 157, 157, 98, 157,
|
||||
159, 158, 158, 103, 104, 105, 50, 51, 158, 109,
|
||||
110, 158, 56, 158, 58, 115, 116, 158, 158, 158,
|
||||
158, 158, 158, 158, 124, 135, 70, 137, 138, 139,
|
||||
140, 141, 142, 143, 78, 79, 158, 158, 158, 149,
|
||||
150, 158, 86, 158, 158, 158, 158, 158, 164, 159,
|
||||
158, 158, 158, 158, 158, -1, 156, 157, 159, 162,
|
||||
159, 159, 159, 159, 159, 159, 159, 159, 159, 159,
|
||||
158, 158, 158, 158, 158, 158, 156, 157, 159, 158,
|
||||
158, 163, 159, 159, 159, 159, 159, 159, 159, 159,
|
||||
159, 159, 159, 159, 159, 159, 159, -1, 160, 160,
|
||||
160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
|
||||
160, 135, 160, 137, 138, 139, 140, 141, 142, 143,
|
||||
160, 160, 160, 160, 160, 149, 150, 160, 160, 163,
|
||||
-1, 162, -1, 163, 163, 159, 163, 163, 163, -1,
|
||||
-1, 162, 162, -1, 163, 159, 163, 163, 163, -1,
|
||||
163, 163, 163, 163, 163, 163, 163, 163, 163
|
||||
);
|
||||
|
||||
protected $actionBase = array(
|
||||
0, 229, 310, 390, 470, 103, 325, 325, 784, -2,
|
||||
0, 229, 310, 390, 470, 103, 325, 325, 785, -2,
|
||||
-2, 149, -2, -2, -2, 660, 765, 799, 765, 589,
|
||||
694, 870, 870, 870, 252, 404, 404, 404, 514, 177,
|
||||
177, 918, 434, 118, 295, 313, 240, 491, 491, 491,
|
||||
@@ -483,9 +483,9 @@ class Php5 extends \PhpParser\ParserAbstract
|
||||
491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
|
||||
491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
|
||||
491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
|
||||
491, 491, 491, 491, 491, 491, 89, 206, 773, 550,
|
||||
535, 775, 776, 777, 912, 709, 913, 856, 857, 700,
|
||||
858, 859, 862, 863, 864, 855, 865, 935, 866, 599,
|
||||
491, 491, 491, 491, 491, 491, 89, 206, 775, 550,
|
||||
535, 776, 777, 778, 912, 709, 913, 859, 862, 700,
|
||||
863, 864, 865, 866, 867, 858, 871, 935, 872, 599,
|
||||
599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
|
||||
599, 322, 592, 285, 319, 232, 44, 691, 691, 691,
|
||||
691, 691, 691, 691, 182, 182, 182, 182, 182, 182,
|
||||
@@ -504,43 +504,44 @@ class Php5 extends \PhpParser\ParserAbstract
|
||||
554, 554, 679, -59, -59, 381, 462, 462, 462, 528,
|
||||
717, 854, 382, 382, 382, 382, 382, 382, 561, 561,
|
||||
561, -3, -3, -3, 692, 115, 137, 115, 137, 678,
|
||||
732, 450, 732, 338, 677, -15, 510, 810, 468, 707,
|
||||
850, 711, 853, 572, 735, 267, 529, 654, 674, 463,
|
||||
732, 450, 732, 338, 677, -15, 510, 812, 468, 707,
|
||||
856, 711, 857, 572, 735, 267, 529, 654, 674, 463,
|
||||
529, 529, 529, 529, 654, 610, 640, 608, 463, 529,
|
||||
463, 718, 323, 496, 89, 570, 507, 675, 778, 293,
|
||||
670, 780, 290, 373, 332, 566, 278, 435, 733, 781,
|
||||
463, 718, 323, 496, 89, 570, 507, 675, 779, 293,
|
||||
670, 781, 290, 373, 332, 566, 278, 435, 733, 784,
|
||||
914, 917, 385, 715, 675, 675, 675, 352, 511, 278,
|
||||
-8, 605, 605, 605, 605, 156, 605, 605, 605, 605,
|
||||
251, 276, 375, 402, 779, 657, 657, 690, 872, 869,
|
||||
869, 657, 689, 657, 690, 874, 874, 874, 874, 657,
|
||||
657, 657, 657, 869, 869, 869, 688, 869, 239, 703,
|
||||
704, 704, 874, 742, 743, 657, 657, 712, 869, 869,
|
||||
869, 712, 695, 874, 701, 741, 277, 869, 874, 672,
|
||||
251, 276, 375, 402, 780, 657, 657, 690, 869, 783,
|
||||
783, 657, 689, 657, 690, 874, 874, 874, 874, 657,
|
||||
657, 657, 657, 783, 783, 783, 688, 783, 239, 703,
|
||||
704, 704, 874, 742, 743, 657, 657, 712, 783, 783,
|
||||
783, 712, 695, 874, 701, 741, 277, 783, 874, 672,
|
||||
689, 672, 657, 701, 672, 689, 689, 672, 22, 666,
|
||||
668, 873, 875, 887, 790, 662, 685, 879, 880, 876,
|
||||
878, 871, 699, 744, 745, 497, 669, 671, 673, 680,
|
||||
719, 682, 713, 674, 667, 667, 667, 655, 720, 655,
|
||||
667, 667, 667, 667, 667, 667, 667, 667, 916, 646,
|
||||
731, 714, 653, 749, 553, 573, 791, 664, 811, 900,
|
||||
893, 867, 919, 881, 898, 655, 920, 739, 247, 643,
|
||||
882, 783, 786, 655, 883, 655, 792, 655, 902, 812,
|
||||
686, 813, 814, 667, 910, 921, 923, 924, 925, 927,
|
||||
928, 929, 930, 684, 931, 750, 696, 894, 299, 877,
|
||||
718, 729, 705, 788, 751, 820, 328, 932, 823, 655,
|
||||
655, 794, 785, 655, 795, 756, 740, 890, 757, 895,
|
||||
933, 664, 708, 896, 655, 706, 825, 934, 328, 681,
|
||||
683, 888, 661, 761, 886, 911, 885, 796, 649, 663,
|
||||
829, 830, 831, 693, 763, 891, 892, 889, 764, 803,
|
||||
665, 805, 697, 832, 807, 884, 768, 833, 834, 899,
|
||||
676, 730, 710, 698, 687, 809, 835, 897, 769, 770,
|
||||
771, 848, 772, 849, 0, 0, 0, 0, 0, 0,
|
||||
668, 873, 875, 887, 791, 662, 685, 879, 880, 876,
|
||||
878, 811, 699, 744, 497, 669, 671, 673, 680, 719,
|
||||
682, 713, 674, 667, 667, 667, 655, 720, 655, 667,
|
||||
667, 667, 667, 667, 667, 667, 667, 868, 646, 731,
|
||||
714, 653, 745, 553, 573, 792, 664, 814, 900, 893,
|
||||
919, 920, 881, 898, 655, 916, 739, 247, 643, 882,
|
||||
813, 788, 655, 883, 655, 794, 655, 902, 820, 686,
|
||||
823, 825, 667, 910, 921, 923, 924, 925, 927, 928,
|
||||
929, 930, 684, 931, 749, 696, 894, 299, 877, 718,
|
||||
729, 705, 790, 750, 829, 328, 932, 830, 655, 655,
|
||||
795, 786, 655, 796, 751, 740, 890, 756, 895, 933,
|
||||
664, 708, 896, 655, 706, 831, 934, 328, 681, 683,
|
||||
888, 661, 757, 886, 911, 885, 803, 761, 649, 663,
|
||||
832, 833, 834, 693, 763, 891, 892, 889, 764, 805,
|
||||
665, 807, 768, 697, 835, 809, 884, 769, 848, 849,
|
||||
899, 676, 730, 710, 698, 687, 810, 850, 897, 770,
|
||||
771, 772, 853, 773, 855, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 138, 138, 138, 138, -2, -2,
|
||||
-2, -2, 0, 0, -2, 0, 0, 0, 138, 138,
|
||||
0, 0, 0, 0, 0, 138, 138, 138, 138, -2,
|
||||
-2, -2, -2, 0, 0, -2, 0, 0, 0, 138,
|
||||
138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
|
||||
138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
|
||||
138, 138, 138, 138, 0, 0, 138, 138, 138, 138,
|
||||
138, 138, 138, 138, 138, 0, 0, 138, 138, 138,
|
||||
138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
|
||||
138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
|
||||
138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
|
||||
138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
|
||||
@@ -549,35 +550,34 @@ class Php5 extends \PhpParser\ParserAbstract
|
||||
138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
|
||||
138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
|
||||
138, 138, 138, 138, 138, 138, 138, 138, 138, 138,
|
||||
138, 138, 138, 138, 138, 138, 138, 138, 138, 599,
|
||||
599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
|
||||
599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
|
||||
599, 599, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 599, -21, -21, -21, -21, 599,
|
||||
-21, -21, -21, -21, -21, -21, -21, 599, 599, 599,
|
||||
599, 599, 599, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 599, -21, -21, -21, -21,
|
||||
599, -21, -21, -21, -21, -21, -21, -21, 599, 599,
|
||||
599, 599, 599, 599, 599, 599, 599, 599, 599, 599,
|
||||
599, 599, 599, 599, 599, -21, 599, 599, 599, -21,
|
||||
382, -21, 382, 382, 382, 382, 382, 382, 382, 382,
|
||||
599, 599, 599, 599, 599, 599, -21, 599, 599, 599,
|
||||
-21, 382, -21, 382, 382, 382, 382, 382, 382, 382,
|
||||
382, 382, 382, 382, 382, 382, 382, 382, 382, 382,
|
||||
382, 382, 382, 382, 382, 382, 382, 382, 382, 382,
|
||||
382, 382, 382, 382, 382, 382, 382, 382, 382, 382,
|
||||
382, 382, 382, 382, 382, 382, 599, 0, 0, 599,
|
||||
-21, 599, -21, 599, -21, -21, 599, 599, 599, 599,
|
||||
599, 599, 599, -21, -21, -21, -21, -21, -21, 0,
|
||||
561, 561, 561, 561, -21, -21, -21, -21, 382, 382,
|
||||
382, 382, 382, 382, 259, 382, 382, 382, 382, 382,
|
||||
382, 382, 382, 382, 382, 382, 561, 561, -3, -3,
|
||||
382, 382, 382, 382, 382, 259, 382, 382, 463, 689,
|
||||
689, 689, 137, 137, 137, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 137, 463, 0,
|
||||
463, 0, 382, 463, 689, 463, 657, 137, 689, 689,
|
||||
463, 869, 616, 616, 616, 616, 328, 278, 0, 0,
|
||||
689, 689, 0, 0, 0, 0, 0, 689, 0, 0,
|
||||
0, 0, 0, 0, 869, 0, 0, 0, 0, 0,
|
||||
667, 247, 0, 705, 335, 0, 0, 0, 0, 0,
|
||||
0, 705, 335, 347, 347, 0, 684, 667, 667, 667,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 328
|
||||
382, 382, 382, 382, 382, 382, 382, 599, 0, 0,
|
||||
599, -21, 599, -21, 599, -21, -21, 599, 599, 599,
|
||||
599, 599, 599, 599, -21, -21, -21, -21, -21, -21,
|
||||
0, 561, 561, 561, 561, -21, -21, -21, -21, 382,
|
||||
382, 382, 382, 382, 382, 259, 382, 382, 382, 382,
|
||||
382, 382, 382, 382, 382, 382, 382, 561, 561, -3,
|
||||
-3, 382, 382, 382, 382, 382, 259, 382, 382, 463,
|
||||
689, 689, 689, 137, 137, 137, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 137, 463,
|
||||
0, 463, 0, 382, 463, 689, 463, 657, 137, 689,
|
||||
689, 463, 783, 616, 616, 616, 616, 328, 278, 0,
|
||||
0, 689, 689, 0, 0, 0, 0, 0, 689, 0,
|
||||
0, 0, 0, 0, 0, 783, 0, 0, 0, 0,
|
||||
0, 667, 247, 0, 705, 335, 0, 0, 0, 0,
|
||||
0, 0, 705, 335, 347, 347, 0, 684, 667, 667,
|
||||
667, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 328
|
||||
);
|
||||
|
||||
protected $actionDefault = array(
|
||||
@@ -629,90 +629,90 @@ class Php5 extends \PhpParser\ParserAbstract
|
||||
32767, 190, 173,32767, 400, 175, 498,32767,32767, 240,
|
||||
32767, 240,32767, 400, 240,32767,32767, 240,32767, 415,
|
||||
439,32767,32767,32767,32767,32767,32767,32767,32767,32767,
|
||||
32767,32767,32767,32767,32767,32767, 379, 380, 493, 506,
|
||||
32767, 507,32767, 413, 343, 344, 346, 322,32767, 324,
|
||||
369, 370, 371, 372, 373, 374, 375, 377,32767, 419,
|
||||
32767, 422,32767,32767,32767, 257,32767, 557,32767,32767,
|
||||
306, 557,32767,32767,32767, 551,32767,32767, 300,32767,
|
||||
32767,32767,32767, 253,32767, 169,32767, 541,32767, 558,
|
||||
32767, 515,32767, 342,32767,32767,32767,32767,32767,32767,
|
||||
32767,32767,32767, 516,32767,32767,32767,32767, 229,32767,
|
||||
452,32767, 116,32767,32767,32767, 189,32767,32767, 304,
|
||||
248,32767,32767, 550,32767,32767,32767,32767,32767,32767,
|
||||
32767,32767, 114,32767, 170,32767,32767,32767, 191,32767,
|
||||
32767, 515,32767,32767,32767,32767,32767,32767,32767, 295,
|
||||
32767,32767,32767,32767,32767, 379, 380, 493, 506,32767,
|
||||
507,32767, 413, 343, 344, 346, 322,32767, 324, 369,
|
||||
370, 371, 372, 373, 374, 375, 377,32767, 419,32767,
|
||||
422,32767,32767,32767, 257,32767, 557,32767,32767, 306,
|
||||
557,32767,32767,32767, 551,32767,32767, 300,32767,32767,
|
||||
32767,32767, 253,32767, 169,32767, 541,32767, 558,32767,
|
||||
515,32767, 342,32767,32767,32767,32767,32767,32767,32767,
|
||||
32767,32767, 516,32767,32767,32767,32767, 229,32767, 452,
|
||||
32767, 116,32767,32767,32767, 189,32767,32767, 304, 248,
|
||||
32767,32767, 550,32767,32767,32767,32767,32767,32767,32767,
|
||||
32767, 114,32767, 170,32767,32767,32767, 191,32767,32767,
|
||||
515,32767,32767,32767,32767,32767,32767,32767,32767, 295,
|
||||
32767,32767,32767,32767,32767,32767,32767, 515,32767,32767,
|
||||
233,32767,32767,32767,32767,32767,32767,32767,32767,32767,
|
||||
415,32767, 276,32767,32767,32767,32767,32767,32767,32767,
|
||||
32767,32767,32767,32767, 127, 127, 3, 127, 127, 260,
|
||||
3, 260, 127, 260, 260, 127, 127, 127, 127, 127,
|
||||
127, 127, 127, 127, 127, 216, 219, 208, 208, 164,
|
||||
127, 127, 268
|
||||
32767, 415,32767, 276,32767,32767,32767,32767,32767,32767,
|
||||
32767,32767,32767,32767,32767, 127, 127, 3, 127, 127,
|
||||
260, 3, 260, 127, 260, 260, 127, 127, 127, 127,
|
||||
127, 127, 127, 127, 127, 127, 216, 219, 208, 208,
|
||||
164, 127, 127, 268
|
||||
);
|
||||
|
||||
protected $goto = array(
|
||||
166, 140, 140, 140, 166, 187, 168, 144, 147, 141,
|
||||
142, 143, 149, 163, 163, 163, 163, 144, 144, 165,
|
||||
165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
|
||||
138, 159, 160, 161, 162, 184, 139, 185, 494, 495,
|
||||
377, 496, 500, 501, 502, 503, 504, 505, 506, 507,
|
||||
970, 164, 145, 146, 148, 171, 176, 186, 203, 253,
|
||||
138, 159, 160, 161, 162, 184, 139, 185, 493, 494,
|
||||
377, 495, 499, 500, 501, 502, 503, 504, 505, 506,
|
||||
971, 164, 145, 146, 148, 171, 176, 186, 203, 253,
|
||||
256, 258, 260, 263, 264, 265, 266, 267, 268, 269,
|
||||
277, 278, 279, 280, 303, 304, 328, 329, 330, 394,
|
||||
395, 396, 543, 188, 189, 190, 191, 192, 193, 194,
|
||||
395, 396, 542, 188, 189, 190, 191, 192, 193, 194,
|
||||
195, 196, 197, 198, 199, 200, 201, 150, 151, 152,
|
||||
167, 153, 169, 154, 204, 170, 155, 156, 157, 205,
|
||||
158, 136, 621, 561, 757, 561, 561, 561, 561, 561,
|
||||
561, 561, 561, 561, 561, 561, 561, 561, 561, 561,
|
||||
561, 561, 561, 561, 561, 561, 561, 561, 561, 561,
|
||||
561, 561, 561, 561, 561, 561, 561, 561, 561, 561,
|
||||
561, 561, 561, 561, 561, 561, 561, 561, 561, 1113,
|
||||
629, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113,
|
||||
1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113,
|
||||
1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113,
|
||||
1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113, 1113,
|
||||
1113, 1113, 1113, 1113, 1113, 758, 520, 531, 509, 656,
|
||||
556, 1183, 750, 509, 592, 786, 1183, 888, 612, 613,
|
||||
884, 617, 618, 624, 626, 631, 633, 817, 855, 855,
|
||||
855, 855, 850, 856, 174, 891, 891, 1205, 1205, 177,
|
||||
158, 136, 622, 560, 758, 560, 560, 560, 560, 560,
|
||||
560, 560, 560, 560, 560, 560, 560, 560, 560, 560,
|
||||
560, 560, 560, 560, 560, 560, 560, 560, 560, 560,
|
||||
560, 560, 560, 560, 560, 560, 560, 560, 560, 560,
|
||||
560, 560, 560, 560, 560, 560, 560, 560, 560, 1114,
|
||||
630, 1114, 1114, 1114, 1114, 1114, 1114, 1114, 1114, 1114,
|
||||
1114, 1114, 1114, 1114, 1114, 1114, 1114, 1114, 1114, 1114,
|
||||
1114, 1114, 1114, 1114, 1114, 1114, 1114, 1114, 1114, 1114,
|
||||
1114, 1114, 1114, 1114, 1114, 1114, 1114, 1114, 1114, 1114,
|
||||
1114, 1114, 1114, 1114, 1114, 759, 519, 530, 508, 657,
|
||||
555, 1184, 350, 508, 591, 787, 1184, 889, 613, 614,
|
||||
885, 618, 619, 625, 627, 632, 634, 751, 856, 856,
|
||||
856, 856, 851, 857, 174, 892, 892, 1206, 1206, 177,
|
||||
178, 179, 401, 402, 403, 404, 173, 202, 206, 208,
|
||||
257, 259, 261, 262, 270, 271, 272, 273, 274, 275,
|
||||
281, 282, 283, 284, 305, 306, 331, 332, 333, 406,
|
||||
407, 408, 409, 175, 180, 254, 255, 181, 182, 183,
|
||||
498, 498, 498, 498, 498, 498, 861, 498, 498, 498,
|
||||
498, 498, 498, 498, 498, 498, 498, 510, 586, 538,
|
||||
601, 602, 510, 545, 546, 547, 548, 549, 550, 551,
|
||||
552, 554, 587, 1209, 560, 350, 560, 560, 560, 560,
|
||||
560, 560, 560, 560, 560, 560, 560, 560, 560, 560,
|
||||
560, 560, 560, 560, 560, 560, 560, 560, 560, 560,
|
||||
560, 560, 560, 560, 560, 560, 560, 560, 560, 560,
|
||||
560, 560, 560, 560, 560, 560, 560, 560, 560, 560,
|
||||
400, 607, 537, 537, 569, 533, 909, 535, 535, 497,
|
||||
499, 525, 541, 570, 573, 584, 591, 298, 296, 296,
|
||||
296, 298, 289, 299, 611, 378, 511, 614, 595, 947,
|
||||
375, 511, 437, 437, 437, 437, 437, 437, 1163, 437,
|
||||
437, 437, 437, 437, 437, 437, 437, 437, 437, 1077,
|
||||
948, 338, 1175, 321, 1077, 898, 898, 898, 898, 606,
|
||||
898, 898, 1217, 1217, 1202, 753, 576, 605, 756, 1077,
|
||||
1077, 1077, 1077, 1077, 1077, 1069, 384, 384, 384, 391,
|
||||
1217, 877, 859, 857, 859, 655, 466, 512, 886, 881,
|
||||
753, 384, 753, 384, 968, 384, 895, 385, 588, 353,
|
||||
414, 384, 1231, 1019, 542, 1197, 1197, 1197, 568, 1094,
|
||||
386, 386, 386, 904, 915, 515, 1029, 19, 15, 372,
|
||||
389, 915, 940, 448, 450, 632, 340, 1216, 1216, 1114,
|
||||
615, 938, 840, 555, 775, 386, 913, 1070, 1073, 1074,
|
||||
399, 1069, 1182, 660, 23, 1216, 773, 1182, 544, 603,
|
||||
1066, 1219, 1071, 1174, 1071, 519, 1199, 1199, 1199, 1089,
|
||||
1088, 1072, 343, 523, 534, 519, 519, 772, 351, 352,
|
||||
13, 579, 583, 627, 1061, 388, 782, 562, 771, 515,
|
||||
783, 1181, 3, 4, 918, 956, 865, 451, 574, 1160,
|
||||
497, 497, 497, 497, 497, 497, 818, 497, 497, 497,
|
||||
497, 497, 497, 497, 497, 497, 497, 509, 585, 862,
|
||||
601, 602, 509, 544, 545, 546, 547, 548, 549, 550,
|
||||
551, 553, 586, 338, 559, 321, 559, 559, 559, 559,
|
||||
559, 559, 559, 559, 559, 559, 559, 559, 559, 559,
|
||||
559, 559, 559, 559, 559, 559, 559, 559, 559, 559,
|
||||
559, 559, 559, 559, 559, 559, 559, 559, 559, 559,
|
||||
559, 559, 559, 559, 559, 559, 559, 559, 559, 559,
|
||||
400, 607, 536, 536, 568, 532, 537, 534, 534, 496,
|
||||
498, 524, 540, 569, 572, 583, 590, 298, 296, 296,
|
||||
296, 298, 289, 299, 611, 1210, 510, 615, 910, 948,
|
||||
375, 510, 437, 437, 437, 437, 437, 437, 594, 437,
|
||||
437, 437, 437, 437, 437, 437, 437, 437, 437, 1078,
|
||||
949, 388, 1176, 561, 1078, 899, 899, 899, 899, 378,
|
||||
899, 899, 1218, 1218, 1164, 754, 351, 352, 757, 1078,
|
||||
1078, 1078, 1078, 1078, 1078, 1070, 384, 384, 384, 606,
|
||||
1218, 878, 860, 858, 860, 656, 466, 511, 887, 882,
|
||||
754, 384, 754, 384, 969, 384, 391, 385, 587, 353,
|
||||
414, 384, 1232, 1203, 541, 1198, 1198, 1198, 567, 1095,
|
||||
386, 386, 386, 1020, 916, 514, 1030, 19, 15, 372,
|
||||
776, 916, 941, 448, 450, 633, 896, 1217, 1217, 1115,
|
||||
616, 939, 841, 554, 905, 386, 340, 1071, 1074, 1075,
|
||||
399, 1070, 1183, 914, 23, 1217, 774, 1183, 543, 603,
|
||||
389, 1220, 1072, 1175, 1072, 518, 1200, 1200, 1200, 575,
|
||||
605, 1073, 343, 522, 533, 518, 518, 773, 1090, 1089,
|
||||
13, 578, 582, 628, 3, 4, 783, 1067, 772, 514,
|
||||
1062, 1182, 784, 661, 919, 451, 866, 573, 957, 1161,
|
||||
464, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 514, 529, 0, 0, 0, 0,
|
||||
514, 0, 529, 0, 0, 0, 0, 610, 513, 516,
|
||||
439, 440, 1067, 619, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 780, 1224, 0, 0, 0, 0,
|
||||
0, 524, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 778, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 513, 528, 0, 0, 0, 0,
|
||||
513, 0, 528, 0, 0, 0, 0, 610, 512, 515,
|
||||
439, 440, 1068, 620, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 781, 1225, 0, 0, 0, 0,
|
||||
0, 523, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 779, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 301, 301
|
||||
);
|
||||
@@ -739,40 +739,40 @@ class Php5 extends \PhpParser\ParserAbstract
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 16, 102, 32, 69, 32,
|
||||
32, 120, 6, 69, 32, 29, 120, 32, 32, 32,
|
||||
32, 32, 32, 32, 32, 32, 32, 50, 69, 69,
|
||||
32, 120, 72, 69, 32, 29, 120, 32, 32, 32,
|
||||
32, 32, 32, 32, 32, 32, 32, 6, 69, 69,
|
||||
69, 69, 69, 69, 27, 77, 77, 77, 77, 27,
|
||||
27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
119, 119, 119, 119, 119, 119, 33, 119, 119, 119,
|
||||
119, 119, 119, 119, 119, 119, 119, 119, 67, 110,
|
||||
119, 119, 119, 119, 119, 119, 50, 119, 119, 119,
|
||||
119, 119, 119, 119, 119, 119, 119, 119, 67, 33,
|
||||
67, 67, 119, 111, 111, 111, 111, 111, 111, 111,
|
||||
111, 111, 111, 142, 57, 72, 57, 57, 57, 57,
|
||||
111, 111, 111, 127, 57, 127, 57, 57, 57, 57,
|
||||
57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
|
||||
57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
|
||||
57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
|
||||
57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
|
||||
51, 51, 51, 51, 51, 51, 84, 51, 51, 51,
|
||||
51, 51, 51, 51, 51, 51, 110, 51, 51, 51,
|
||||
51, 51, 51, 51, 51, 51, 51, 5, 5, 5,
|
||||
5, 5, 5, 5, 63, 46, 124, 63, 129, 98,
|
||||
63, 124, 57, 57, 57, 57, 57, 57, 133, 57,
|
||||
5, 5, 5, 5, 63, 142, 124, 63, 84, 98,
|
||||
63, 124, 57, 57, 57, 57, 57, 57, 129, 57,
|
||||
57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
|
||||
98, 127, 82, 127, 57, 57, 57, 57, 57, 49,
|
||||
57, 57, 144, 144, 140, 11, 40, 40, 14, 57,
|
||||
57, 57, 57, 57, 57, 82, 13, 13, 13, 48,
|
||||
98, 12, 82, 12, 57, 57, 57, 57, 57, 46,
|
||||
57, 57, 144, 144, 133, 11, 72, 72, 14, 57,
|
||||
57, 57, 57, 57, 57, 82, 13, 13, 13, 49,
|
||||
144, 14, 14, 14, 14, 14, 57, 14, 14, 14,
|
||||
11, 13, 11, 13, 102, 13, 79, 11, 70, 70,
|
||||
70, 13, 13, 103, 2, 9, 9, 9, 2, 34,
|
||||
125, 125, 125, 81, 13, 13, 34, 34, 34, 34,
|
||||
17, 13, 8, 8, 8, 8, 18, 143, 143, 8,
|
||||
8, 8, 9, 34, 25, 125, 85, 82, 82, 82,
|
||||
125, 82, 121, 74, 34, 143, 24, 121, 47, 34,
|
||||
116, 143, 82, 82, 82, 47, 121, 121, 121, 126,
|
||||
126, 82, 58, 58, 58, 47, 47, 23, 72, 72,
|
||||
58, 62, 62, 62, 114, 12, 23, 12, 23, 13,
|
||||
26, 121, 30, 30, 86, 100, 71, 65, 66, 132,
|
||||
11, 13, 11, 13, 102, 13, 48, 11, 70, 70,
|
||||
70, 13, 13, 140, 2, 9, 9, 9, 2, 34,
|
||||
125, 125, 125, 103, 13, 13, 34, 34, 34, 34,
|
||||
25, 13, 8, 8, 8, 8, 79, 143, 143, 8,
|
||||
8, 8, 9, 34, 81, 125, 18, 82, 82, 82,
|
||||
125, 82, 121, 85, 34, 143, 24, 121, 47, 34,
|
||||
17, 143, 82, 82, 82, 47, 121, 121, 121, 40,
|
||||
40, 82, 58, 58, 58, 47, 47, 23, 126, 126,
|
||||
58, 62, 62, 62, 30, 30, 23, 116, 23, 13,
|
||||
114, 121, 26, 74, 86, 65, 71, 66, 100, 132,
|
||||
109, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, 9, 9, -1, -1, -1, -1,
|
||||
9, -1, 9, -1, -1, -1, -1, 13, 9, 9,
|
||||
@@ -785,39 +785,39 @@ class Php5 extends \PhpParser\ParserAbstract
|
||||
);
|
||||
|
||||
protected $gotoBase = array(
|
||||
0, 0, -172, 0, 0, 353, 201, 0, 477, 149,
|
||||
0, 110, 195, 117, 426, 112, 203, 140, 171, 0,
|
||||
0, 0, 0, 168, 164, 157, 119, 27, 0, 205,
|
||||
-118, 0, -428, 266, 51, 0, 0, 0, 0, 0,
|
||||
388, 0, 0, -24, 0, 0, 345, 484, 146, 133,
|
||||
209, 75, 0, 0, 0, 0, 0, 107, 161, 0,
|
||||
0, 0, 222, -77, 0, 106, 97, -343, 0, -94,
|
||||
135, 123, -129, 0, 129, 0, 0, -50, 0, 143,
|
||||
0, 159, 64, 0, 338, 132, 122, 0, 0, 0,
|
||||
0, 0, -173, 0, 0, 353, 216, 0, 477, 149,
|
||||
0, 110, 71, 117, 426, 112, 203, 170, 181, 0,
|
||||
0, 0, 0, 168, 164, 143, 121, 27, 0, 205,
|
||||
-127, 0, -429, 279, 51, 0, 0, 0, 0, 0,
|
||||
481, 0, 0, -24, 0, 0, 379, 484, 163, 153,
|
||||
268, 75, 0, 0, 0, 0, 0, 107, 161, 0,
|
||||
0, 0, 222, -77, 0, 104, 96, -344, 0, -94,
|
||||
135, 123, -232, 0, 169, 0, 0, -50, 0, 173,
|
||||
0, 180, 64, 0, 360, 139, 122, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 98, 0,
|
||||
121, 0, 165, 156, 0, 0, 0, 0, 0, 87,
|
||||
273, 259, 0, 0, 114, 0, 150, 0, 0, -5,
|
||||
-91, 200, 0, 0, 84, 154, 202, 77, -48, 178,
|
||||
0, 0, 93, 187, 0, 0, 0, 0, 0, 0,
|
||||
136, 0, 286, 167, 102, 0, 0
|
||||
124, 0, 165, 166, 0, 0, 0, 0, 0, 87,
|
||||
340, 259, 0, 0, 120, 0, 177, 0, 0, -5,
|
||||
-91, 200, 0, 0, 84, 154, 211, -21, -48, 188,
|
||||
0, 0, 93, 213, 0, 0, 0, 0, 0, 0,
|
||||
175, 0, 358, 167, 102, 0, 0
|
||||
);
|
||||
|
||||
protected $gotoDefault = array(
|
||||
-32768, 468, 664, 2, 665, 835, 740, 748, 598, 482,
|
||||
630, 582, 380, 1193, 792, 793, 794, 381, 368, 483,
|
||||
379, 410, 405, 781, 774, 776, 784, 172, 411, 787,
|
||||
1, 789, 518, 825, 1020, 365, 797, 366, 590, 799,
|
||||
527, 801, 802, 137, 382, 383, 528, 484, 390, 577,
|
||||
816, 276, 387, 818, 367, 819, 828, 371, 465, 455,
|
||||
460, 530, 557, 609, 432, 447, 571, 565, 536, 1086,
|
||||
566, 864, 349, 872, 661, 880, 883, 485, 558, 894,
|
||||
452, 902, 1099, 397, 908, 914, 919, 291, 922, 417,
|
||||
412, 585, 927, 928, 5, 932, 622, 623, 8, 312,
|
||||
955, 599, 969, 420, 1039, 1041, 486, 487, 522, 459,
|
||||
508, 526, 488, 1062, 441, 413, 1065, 433, 489, 490,
|
||||
434, 435, 1083, 355, 1168, 354, 449, 320, 1155, 580,
|
||||
1118, 456, 1208, 1164, 348, 491, 492, 376, 1187, 392,
|
||||
1203, 438, 1210, 1218, 344, 540, 567
|
||||
-32768, 468, 665, 2, 666, 836, 741, 749, 598, 482,
|
||||
631, 581, 380, 1194, 793, 794, 795, 381, 368, 766,
|
||||
379, 410, 405, 782, 775, 777, 785, 172, 411, 788,
|
||||
1, 790, 517, 826, 1021, 365, 798, 366, 589, 800,
|
||||
526, 802, 803, 137, 382, 383, 527, 483, 390, 576,
|
||||
817, 276, 387, 819, 367, 820, 829, 371, 465, 455,
|
||||
460, 529, 556, 609, 432, 447, 570, 564, 535, 1087,
|
||||
565, 865, 349, 873, 662, 881, 884, 484, 557, 895,
|
||||
452, 903, 1100, 397, 909, 915, 920, 291, 923, 417,
|
||||
412, 584, 928, 929, 5, 933, 623, 624, 8, 312,
|
||||
956, 599, 970, 420, 1040, 1042, 485, 486, 521, 459,
|
||||
507, 525, 487, 1063, 441, 413, 1066, 433, 488, 489,
|
||||
434, 435, 1084, 355, 1169, 354, 449, 320, 1156, 579,
|
||||
1119, 456, 1209, 1165, 348, 490, 491, 376, 1188, 392,
|
||||
1204, 438, 1211, 1219, 344, 539, 566
|
||||
);
|
||||
|
||||
protected $ruleToNonTerminal = array(
|
||||
@@ -891,7 +891,7 @@ class Php5 extends \PhpParser\ParserAbstract
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 3, 5, 4,
|
||||
3, 4, 2, 3, 1, 1, 7, 6, 3, 1,
|
||||
3, 4, 1, 3, 1, 1, 8, 7, 3, 1,
|
||||
3, 1, 3, 1, 1, 3, 1, 3, 1, 2,
|
||||
3, 1, 3, 3, 1, 3, 2, 0, 1, 1,
|
||||
1, 1, 1, 3, 5, 8, 3, 5, 9, 3,
|
||||
@@ -1256,7 +1256,7 @@ class Php5 extends \PhpParser\ParserAbstract
|
||||
$this->semValue = new Stmt\Use_($this->semStack[$stackPos-(4-3)], $this->semStack[$stackPos-(4-2)], $this->startAttributeStack[$stackPos-(4-1)] + $this->endAttributes);
|
||||
},
|
||||
102 => function ($stackPos) {
|
||||
$this->semValue = $this->semStack[$stackPos-(2-1)];
|
||||
$this->semValue = $this->semStack[$stackPos-(1-1)];
|
||||
},
|
||||
103 => function ($stackPos) {
|
||||
$this->semValue = new Stmt\Const_($this->semStack[$stackPos-(3-2)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes);
|
||||
@@ -1268,10 +1268,10 @@ class Php5 extends \PhpParser\ParserAbstract
|
||||
$this->semValue = Stmt\Use_::TYPE_CONSTANT;
|
||||
},
|
||||
106 => function ($stackPos) {
|
||||
$this->semValue = new Stmt\GroupUse($this->semStack[$stackPos-(7-3)], $this->semStack[$stackPos-(7-6)], $this->semStack[$stackPos-(7-2)], $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes);
|
||||
$this->semValue = new Stmt\GroupUse($this->semStack[$stackPos-(8-3)], $this->semStack[$stackPos-(8-6)], $this->semStack[$stackPos-(8-2)], $this->startAttributeStack[$stackPos-(8-1)] + $this->endAttributes);
|
||||
},
|
||||
107 => function ($stackPos) {
|
||||
$this->semValue = new Stmt\GroupUse($this->semStack[$stackPos-(6-2)], $this->semStack[$stackPos-(6-5)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(6-1)] + $this->endAttributes);
|
||||
$this->semValue = new Stmt\GroupUse($this->semStack[$stackPos-(7-2)], $this->semStack[$stackPos-(7-5)], Stmt\Use_::TYPE_UNKNOWN, $this->startAttributeStack[$stackPos-(7-1)] + $this->endAttributes);
|
||||
},
|
||||
108 => function ($stackPos) {
|
||||
$this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)];
|
||||
@@ -1738,7 +1738,7 @@ class Php5 extends \PhpParser\ParserAbstract
|
||||
$this->semValue = new Stmt\StaticVar($this->semStack[$stackPos-(3-1)], $this->semStack[$stackPos-(3-3)], $this->startAttributeStack[$stackPos-(3-1)] + $this->endAttributes);
|
||||
},
|
||||
259 => function ($stackPos) {
|
||||
if ($this->semStack[$stackPos-(2-2)] !== null) { $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; }
|
||||
if ($this->semStack[$stackPos-(2-2)] !== null) { $this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)]; } else { $this->semValue = $this->semStack[$stackPos-(2-1)]; }
|
||||
},
|
||||
260 => function ($stackPos) {
|
||||
$this->semValue = array();
|
||||
@@ -2627,7 +2627,7 @@ class Php5 extends \PhpParser\ParserAbstract
|
||||
$this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(2-2)], null, true, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes);
|
||||
},
|
||||
552 => function ($stackPos) {
|
||||
$this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(2-2)], null, false, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes, true, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes);
|
||||
$this->semValue = new Expr\ArrayItem($this->semStack[$stackPos-(2-2)], null, false, $this->startAttributeStack[$stackPos-(2-1)] + $this->endAttributes, true);
|
||||
},
|
||||
553 => function ($stackPos) {
|
||||
$this->semStack[$stackPos-(2-1)][] = $this->semStack[$stackPos-(2-2)]; $this->semValue = $this->semStack[$stackPos-(2-1)];
|
||||
|
||||
+1318
-1301
File diff suppressed because it is too large
Load Diff
@@ -155,7 +155,7 @@ abstract class ParserAbstract implements Parser
|
||||
* @return Node\Stmt[]|null Array of statements (or null non-throwing error handler is used and
|
||||
* the parser was unable to recover from an error).
|
||||
*/
|
||||
public function parse(string $code, ErrorHandler $errorHandler = null) {
|
||||
public function parse(string $code, ?ErrorHandler $errorHandler = null) {
|
||||
$this->errorHandler = $errorHandler ?: new ErrorHandler\Throwing;
|
||||
|
||||
$this->lexer->startLexing($code, $this->errorHandler);
|
||||
|
||||
+33
-1
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
use PhpParser\Lexer\Emulative;
|
||||
use PhpParser\Parser\Php7;
|
||||
|
||||
class ParserFactory
|
||||
{
|
||||
const PREFER_PHP7 = 1;
|
||||
@@ -18,7 +21,7 @@ class ParserFactory
|
||||
*
|
||||
* @return Parser The parser instance
|
||||
*/
|
||||
public function create(int $kind, Lexer $lexer = null, array $parserOptions = []) : Parser {
|
||||
public function create(int $kind, ?Lexer $lexer = null, array $parserOptions = []) : Parser {
|
||||
if (null === $lexer) {
|
||||
$lexer = new Lexer\Emulative();
|
||||
}
|
||||
@@ -41,4 +44,33 @@ class ParserFactory
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a parser targeting the newest version supported by this library. Code for older
|
||||
* versions will be accepted if there have been no relevant backwards-compatibility breaks in
|
||||
* PHP.
|
||||
*
|
||||
* All supported lexer attributes (comments, startLine, endLine, startTokenPos, endTokenPos,
|
||||
* startFilePos, endFilePos) will be enabled.
|
||||
*/
|
||||
public function createForNewestSupportedVersion(): Parser {
|
||||
return new Php7(new Emulative($this->getLexerOptions()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a parser targeting the host PHP version, that is the PHP version we're currently
|
||||
* running on. This parser will not use any token emulation.
|
||||
*
|
||||
* All supported lexer attributes (comments, startLine, endLine, startTokenPos, endTokenPos,
|
||||
* startFilePos, endFilePos) will be enabled.
|
||||
*/
|
||||
public function createForHostVersion(): Parser {
|
||||
return new Php7(new Lexer($this->getLexerOptions()));
|
||||
}
|
||||
|
||||
private function getLexerOptions(): array {
|
||||
return ['usedAttributes' => [
|
||||
'comments', 'startLine', 'endLine', 'startTokenPos', 'endTokenPos', 'startFilePos', 'endFilePos',
|
||||
]];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ class Standard extends PrettyPrinterAbstract
|
||||
|
||||
// Try to find a short full-precision representation
|
||||
$stringValue = sprintf('%.16G', $node->value);
|
||||
if ($node->value !== (double) $stringValue) {
|
||||
if ($node->value !== (float) $stringValue) {
|
||||
$stringValue = sprintf('%.17G', $node->value);
|
||||
}
|
||||
|
||||
@@ -529,7 +529,7 @@ class Standard extends PrettyPrinterAbstract
|
||||
}
|
||||
|
||||
protected function pExpr_StaticCall(Expr\StaticCall $node) {
|
||||
return $this->pDereferenceLhs($node->class) . '::'
|
||||
return $this->pStaticDereferenceLhs($node->class) . '::'
|
||||
. ($node->name instanceof Expr
|
||||
? ($node->name instanceof Expr\Variable
|
||||
? $this->p($node->name)
|
||||
@@ -606,7 +606,7 @@ class Standard extends PrettyPrinterAbstract
|
||||
}
|
||||
|
||||
protected function pExpr_ClassConstFetch(Expr\ClassConstFetch $node) {
|
||||
return $this->pDereferenceLhs($node->class) . '::' . $this->p($node->name);
|
||||
return $this->pStaticDereferenceLhs($node->class) . '::' . $this->pObjectProperty($node->name);
|
||||
}
|
||||
|
||||
protected function pExpr_PropertyFetch(Expr\PropertyFetch $node) {
|
||||
@@ -618,7 +618,7 @@ class Standard extends PrettyPrinterAbstract
|
||||
}
|
||||
|
||||
protected function pExpr_StaticPropertyFetch(Expr\StaticPropertyFetch $node) {
|
||||
return $this->pDereferenceLhs($node->class) . '::$' . $this->pObjectProperty($node->name);
|
||||
return $this->pStaticDereferenceLhs($node->class) . '::$' . $this->pObjectProperty($node->name);
|
||||
}
|
||||
|
||||
protected function pExpr_ShellExec(Expr\ShellExec $node) {
|
||||
@@ -814,7 +814,9 @@ class Standard extends PrettyPrinterAbstract
|
||||
protected function pStmt_ClassConst(Stmt\ClassConst $node) {
|
||||
return $this->pAttrGroups($node->attrGroups)
|
||||
. $this->pModifiers($node->flags)
|
||||
. 'const ' . $this->pCommaSeparated($node->consts) . ';';
|
||||
. 'const '
|
||||
. (null !== $node->type ? $this->p($node->type) . ' ' : '')
|
||||
. $this->pCommaSeparated($node->consts) . ';';
|
||||
}
|
||||
|
||||
protected function pStmt_Function(Stmt\Function_ $node) {
|
||||
@@ -1067,6 +1069,14 @@ class Standard extends PrettyPrinterAbstract
|
||||
}
|
||||
}
|
||||
|
||||
protected function pStaticDereferenceLhs(Node $node) {
|
||||
if (!$this->staticDereferenceLhsRequiresParens($node)) {
|
||||
return $this->p($node);
|
||||
} else {
|
||||
return '(' . $this->p($node) . ')';
|
||||
}
|
||||
}
|
||||
|
||||
protected function pCallLhs(Node $node) {
|
||||
if (!$this->callLhsRequiresParens($node)) {
|
||||
return $this->p($node);
|
||||
@@ -1075,9 +1085,12 @@ class Standard extends PrettyPrinterAbstract
|
||||
}
|
||||
}
|
||||
|
||||
protected function pNewVariable(Node $node) {
|
||||
// TODO: This is not fully accurate.
|
||||
return $this->pDereferenceLhs($node);
|
||||
protected function pNewVariable(Node $node): string {
|
||||
if (!$this->newOperandRequiresParens($node)) {
|
||||
return $this->p($node);
|
||||
} else {
|
||||
return '(' . $this->p($node) . ')';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,8 @@ abstract class PrettyPrinterAbstract
|
||||
const FIXUP_BRACED_NAME = 4; // Name operand that may require bracing
|
||||
const FIXUP_VAR_BRACED_NAME = 5; // Name operand that may require ${} bracing
|
||||
const FIXUP_ENCAPSED = 6; // Encapsed string part
|
||||
const FIXUP_NEW = 7; // New/instanceof operand
|
||||
const FIXUP_STATIC_DEREF_LHS = 8; // LHS of static dereferencing operation
|
||||
|
||||
protected $precedenceMap = [
|
||||
// [precedence, associativity]
|
||||
@@ -656,7 +658,7 @@ abstract class PrettyPrinterAbstract
|
||||
$result .= $extraLeft;
|
||||
|
||||
$origIndentLevel = $this->indentLevel;
|
||||
$this->setIndentLevel($this->origTokens->getIndentationBefore($subStartPos) + $indentAdjustment);
|
||||
$this->setIndentLevel(max($this->origTokens->getIndentationBefore($subStartPos) + $indentAdjustment, 0));
|
||||
|
||||
// If it's the same node that was previously in this position, it certainly doesn't
|
||||
// need fixup. It's important to check this here, because our fixup checks are more
|
||||
@@ -759,7 +761,7 @@ abstract class PrettyPrinterAbstract
|
||||
\assert($itemStartPos >= 0 && $itemEndPos >= 0 && $itemStartPos >= $pos);
|
||||
|
||||
$origIndentLevel = $this->indentLevel;
|
||||
$lastElemIndentLevel = $this->origTokens->getIndentationBefore($itemStartPos) + $indentAdjustment;
|
||||
$lastElemIndentLevel = max($this->origTokens->getIndentationBefore($itemStartPos) + $indentAdjustment, 0);
|
||||
$this->setIndentLevel($lastElemIndentLevel);
|
||||
|
||||
$comments = $arrItem->getComments();
|
||||
@@ -977,6 +979,19 @@ abstract class PrettyPrinterAbstract
|
||||
return '(' . $this->p($subNode) . ')';
|
||||
}
|
||||
break;
|
||||
case self::FIXUP_STATIC_DEREF_LHS:
|
||||
if ($this->staticDereferenceLhsRequiresParens($subNode)
|
||||
&& !$this->origTokens->haveParens($subStartPos, $subEndPos)
|
||||
) {
|
||||
return '(' . $this->p($subNode) . ')';
|
||||
}
|
||||
break;
|
||||
case self::FIXUP_NEW:
|
||||
if ($this->newOperandRequiresParens($subNode)
|
||||
&& !$this->origTokens->haveParens($subStartPos, $subEndPos)) {
|
||||
return '(' . $this->p($subNode) . ')';
|
||||
}
|
||||
break;
|
||||
case self::FIXUP_BRACED_NAME:
|
||||
case self::FIXUP_VAR_BRACED_NAME:
|
||||
if ($subNode instanceof Expr
|
||||
@@ -1047,13 +1062,26 @@ abstract class PrettyPrinterAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the LHS of a dereferencing operation must be wrapped in parenthesis.
|
||||
* Determines whether the LHS of an array/object operation must be wrapped in parentheses.
|
||||
*
|
||||
* @param Node $node LHS of dereferencing operation
|
||||
*
|
||||
* @return bool Whether parentheses are required
|
||||
*/
|
||||
protected function dereferenceLhsRequiresParens(Node $node) : bool {
|
||||
// A constant can occur on the LHS of an array/object deref, but not a static deref.
|
||||
return $this->staticDereferenceLhsRequiresParens($node)
|
||||
&& !$node instanceof Expr\ConstFetch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the LHS of a static operation must be wrapped in parentheses.
|
||||
*
|
||||
* @param Node $node LHS of dereferencing operation
|
||||
*
|
||||
* @return bool Whether parentheses are required
|
||||
*/
|
||||
protected function staticDereferenceLhsRequiresParens(Node $node): bool {
|
||||
return !($node instanceof Expr\Variable
|
||||
|| $node instanceof Node\Name
|
||||
|| $node instanceof Expr\ArrayDimFetch
|
||||
@@ -1066,10 +1094,31 @@ abstract class PrettyPrinterAbstract
|
||||
|| $node instanceof Expr\StaticCall
|
||||
|| $node instanceof Expr\Array_
|
||||
|| $node instanceof Scalar\String_
|
||||
|| $node instanceof Expr\ConstFetch
|
||||
|| $node instanceof Expr\ClassConstFetch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether an expression used in "new" or "instanceof" requires parentheses.
|
||||
*
|
||||
* @param Node $node New or instanceof operand
|
||||
*
|
||||
* @return bool Whether parentheses are required
|
||||
*/
|
||||
protected function newOperandRequiresParens(Node $node): bool {
|
||||
if ($node instanceof Node\Name || $node instanceof Expr\Variable) {
|
||||
return false;
|
||||
}
|
||||
if ($node instanceof Expr\ArrayDimFetch || $node instanceof Expr\PropertyFetch ||
|
||||
$node instanceof Expr\NullsafePropertyFetch
|
||||
) {
|
||||
return $this->newOperandRequiresParens($node->var);
|
||||
}
|
||||
if ($node instanceof Expr\StaticPropertyFetch) {
|
||||
return $this->newOperandRequiresParens($node->class);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print modifiers, including trailing whitespace.
|
||||
*
|
||||
@@ -1171,7 +1220,7 @@ abstract class PrettyPrinterAbstract
|
||||
Expr\PostDec::class => ['var' => self::FIXUP_PREC_LEFT],
|
||||
Expr\Instanceof_::class => [
|
||||
'expr' => self::FIXUP_PREC_LEFT,
|
||||
'class' => self::FIXUP_PREC_RIGHT, // TODO: FIXUP_NEW_VARIABLE
|
||||
'class' => self::FIXUP_NEW,
|
||||
],
|
||||
Expr\Ternary::class => [
|
||||
'cond' => self::FIXUP_PREC_LEFT,
|
||||
@@ -1179,10 +1228,13 @@ abstract class PrettyPrinterAbstract
|
||||
],
|
||||
|
||||
Expr\FuncCall::class => ['name' => self::FIXUP_CALL_LHS],
|
||||
Expr\StaticCall::class => ['class' => self::FIXUP_DEREF_LHS],
|
||||
Expr\StaticCall::class => ['class' => self::FIXUP_STATIC_DEREF_LHS],
|
||||
Expr\ArrayDimFetch::class => ['var' => self::FIXUP_DEREF_LHS],
|
||||
Expr\ClassConstFetch::class => ['var' => self::FIXUP_DEREF_LHS],
|
||||
Expr\New_::class => ['class' => self::FIXUP_DEREF_LHS], // TODO: FIXUP_NEW_VARIABLE
|
||||
Expr\ClassConstFetch::class => [
|
||||
'class' => self::FIXUP_STATIC_DEREF_LHS,
|
||||
'name' => self::FIXUP_BRACED_NAME,
|
||||
],
|
||||
Expr\New_::class => ['class' => self::FIXUP_NEW],
|
||||
Expr\MethodCall::class => [
|
||||
'var' => self::FIXUP_DEREF_LHS,
|
||||
'name' => self::FIXUP_BRACED_NAME,
|
||||
@@ -1192,7 +1244,7 @@ abstract class PrettyPrinterAbstract
|
||||
'name' => self::FIXUP_BRACED_NAME,
|
||||
],
|
||||
Expr\StaticPropertyFetch::class => [
|
||||
'class' => self::FIXUP_DEREF_LHS,
|
||||
'class' => self::FIXUP_STATIC_DEREF_LHS,
|
||||
'name' => self::FIXUP_VAR_BRACED_NAME,
|
||||
],
|
||||
Expr\PropertyFetch::class => [
|
||||
@@ -1278,6 +1330,7 @@ abstract class PrettyPrinterAbstract
|
||||
'Param->default' => $stripEquals,
|
||||
'Stmt_Break->num' => $stripBoth,
|
||||
'Stmt_Catch->var' => $stripLeft,
|
||||
'Stmt_ClassConst->type' => $stripRight,
|
||||
'Stmt_ClassMethod->returnType' => $stripColon,
|
||||
'Stmt_Class->extends' => ['left' => \T_EXTENDS],
|
||||
'Stmt_Enum->scalarType' => $stripColon,
|
||||
@@ -1319,6 +1372,7 @@ abstract class PrettyPrinterAbstract
|
||||
'Stmt_Break->num' => [\T_BREAK, false, ' ', null],
|
||||
'Stmt_Catch->var' => [null, false, ' ', null],
|
||||
'Stmt_ClassMethod->returnType' => [')', false, ' : ', null],
|
||||
'Stmt_ClassConst->type' => [\T_CONST, false, ' ', null],
|
||||
'Stmt_Class->extends' => [null, false, ' extends ', null],
|
||||
'Stmt_Enum->scalarType' => [null, false, ' : ', null],
|
||||
'Stmt_EnumCase->expr' => [null, false, ' = ', null],
|
||||
@@ -1508,6 +1562,7 @@ abstract class PrettyPrinterAbstract
|
||||
'Stmt_ClassMethod->flags' => \T_FUNCTION,
|
||||
'Stmt_Class->flags' => \T_CLASS,
|
||||
'Stmt_Property->flags' => \T_VARIABLE,
|
||||
'Expr_PrintableNewAnonClass->flags' => \T_CLASS,
|
||||
'Param->flags' => \T_VARIABLE,
|
||||
//'Stmt_TraitUseAdaptation_Alias->newModifier' => 0, // TODO
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user