updated packages
This commit is contained in:
1
vendor/nikic/php-parser/.travis.yml
vendored
1
vendor/nikic/php-parser/.travis.yml
vendored
@@ -11,6 +11,7 @@ php:
|
||||
- 7.1
|
||||
- 7.2
|
||||
- 7.3
|
||||
- 7.4snapshot
|
||||
- nightly
|
||||
|
||||
install:
|
||||
|
||||
24
vendor/nikic/php-parser/CHANGELOG.md
vendored
24
vendor/nikic/php-parser/CHANGELOG.md
vendored
@@ -1,15 +1,35 @@
|
||||
Version 4.1.2-dev
|
||||
Version 4.2.2-dev
|
||||
-----------------
|
||||
|
||||
Nothing yet.
|
||||
|
||||
Version 4.2.1 (2019-02-16)
|
||||
--------------------------
|
||||
|
||||
### Added
|
||||
|
||||
* [PHP 7.4] Add support for `??=` operator through a new `AssignOp\Coalesce` node. (#575)
|
||||
|
||||
Version 4.2.0 (2019-01-12)
|
||||
--------------------------
|
||||
|
||||
### Added
|
||||
|
||||
* [PHP 7.4] Add support for typed properties through a new `type` subnode of `Stmt\Property`.
|
||||
Additionally `Builder\Property` now has a `setType()` method. (#567)
|
||||
* Add `kind` attribute to `Cast\Double_`, which allows to distinguish between `(float)`,
|
||||
`(double)` and `(real)`. The form of the cast will be preserved by the pretty printer. (#565)
|
||||
|
||||
### Fixed
|
||||
|
||||
* Remove assertion when pretty printing anonymous class with a name (#554).
|
||||
|
||||
Version 4.1.1 (2018-12-26)
|
||||
--------------------------
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fix "undefined offset" notice when parsing specific malformed code (#551).
|
||||
* Remove assertion when pretty printing anonymous class with a name (#554).
|
||||
|
||||
### Added
|
||||
|
||||
|
||||
0
vendor/nikic/php-parser/bin/php-parse
vendored
Normal file → Executable file
0
vendor/nikic/php-parser/bin/php-parse
vendored
Normal file → Executable file
24
vendor/nikic/php-parser/composer.json
vendored
24
vendor/nikic/php-parser/composer.json
vendored
@@ -1,8 +1,11 @@
|
||||
{
|
||||
"name": "nikic/php-parser",
|
||||
"description": "A PHP parser written in PHP",
|
||||
"keywords": ["php", "parser"],
|
||||
"type": "library",
|
||||
"description": "A PHP parser written in PHP",
|
||||
"keywords": [
|
||||
"php",
|
||||
"parser"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"authors": [
|
||||
{
|
||||
@@ -16,15 +19,22 @@
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.5 || ^7.0"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.2-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PhpParser\\": "lib/PhpParser"
|
||||
}
|
||||
},
|
||||
"bin": ["bin/php-parse"],
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.1-dev"
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"PhpParser\\": "test/PhpParser/"
|
||||
}
|
||||
}
|
||||
},
|
||||
"bin": [
|
||||
"bin/php-parse"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ $node = $factory->namespace('Name\Space')
|
||||
->makePublic()
|
||||
->makeAbstract() // ->makeFinal()
|
||||
->setReturnType('bool') // ->makeReturnByRef()
|
||||
->addParam($factory->param('someParam')->setTypeHint('SomeClass'))
|
||||
->addParam($factory->param('someParam')->setType('SomeClass'))
|
||||
->setDocComment('/**
|
||||
* This method does something.
|
||||
*
|
||||
|
||||
6
vendor/nikic/php-parser/grammar/php5.y
vendored
6
vendor/nikic/php-parser/grammar/php5.y
vendored
@@ -579,6 +579,7 @@ expr:
|
||||
| variable T_SL_EQUAL expr { $$ = Expr\AssignOp\ShiftLeft [$1, $3]; }
|
||||
| variable T_SR_EQUAL expr { $$ = Expr\AssignOp\ShiftRight[$1, $3]; }
|
||||
| variable T_POW_EQUAL expr { $$ = Expr\AssignOp\Pow [$1, $3]; }
|
||||
| variable T_COALESCE_EQUAL expr { $$ = Expr\AssignOp\Coalesce [$1, $3]; }
|
||||
| variable T_INC { $$ = Expr\PostInc[$1]; }
|
||||
| T_INC variable { $$ = Expr\PreInc [$2]; }
|
||||
| variable T_DEC { $$ = Expr\PostDec[$1]; }
|
||||
@@ -628,7 +629,10 @@ expr:
|
||||
| T_REQUIRE expr { $$ = Expr\Include_[$2, Expr\Include_::TYPE_REQUIRE]; }
|
||||
| T_REQUIRE_ONCE expr { $$ = Expr\Include_[$2, Expr\Include_::TYPE_REQUIRE_ONCE]; }
|
||||
| T_INT_CAST expr { $$ = Expr\Cast\Int_ [$2]; }
|
||||
| T_DOUBLE_CAST expr { $$ = Expr\Cast\Double [$2]; }
|
||||
| T_DOUBLE_CAST expr
|
||||
{ $attrs = attributes();
|
||||
$attrs['kind'] = $this->getFloatCastKind($1);
|
||||
$$ = new Expr\Cast\Double($2, $attrs); }
|
||||
| T_STRING_CAST expr { $$ = Expr\Cast\String_ [$2]; }
|
||||
| T_ARRAY_CAST expr { $$ = Expr\Cast\Array_ [$2]; }
|
||||
| T_OBJECT_CAST expr { $$ = Expr\Cast\Object_ [$2]; }
|
||||
|
||||
19
vendor/nikic/php-parser/grammar/php7.y
vendored
19
vendor/nikic/php-parser/grammar/php7.y
vendored
@@ -450,11 +450,11 @@ non_empty_parameter_list:
|
||||
;
|
||||
|
||||
parameter:
|
||||
optional_param_type optional_ref optional_ellipsis plain_variable
|
||||
optional_type optional_ref optional_ellipsis plain_variable
|
||||
{ $$ = Node\Param[$4, null, $1, $2, $3]; $this->checkParam($$); }
|
||||
| optional_param_type optional_ref optional_ellipsis plain_variable '=' expr
|
||||
| optional_type optional_ref optional_ellipsis plain_variable '=' expr
|
||||
{ $$ = Node\Param[$4, $6, $1, $2, $3]; $this->checkParam($$); }
|
||||
| optional_param_type optional_ref optional_ellipsis error
|
||||
| optional_type optional_ref optional_ellipsis error
|
||||
{ $$ = Node\Param[Expr\Error[], null, $1, $2, $3]; }
|
||||
;
|
||||
|
||||
@@ -469,7 +469,7 @@ type:
|
||||
| T_CALLABLE { $$ = Node\Identifier['callable']; }
|
||||
;
|
||||
|
||||
optional_param_type:
|
||||
optional_type:
|
||||
/* empty */ { $$ = null; }
|
||||
| type_expr { $$ = $1; }
|
||||
;
|
||||
@@ -535,8 +535,9 @@ class_statement_list:
|
||||
;
|
||||
|
||||
class_statement:
|
||||
variable_modifiers property_declaration_list ';'
|
||||
{ $$ = Stmt\Property[$1, $2]; $this->checkProperty($$, #1); }
|
||||
variable_modifiers optional_type property_declaration_list ';'
|
||||
{ $attrs = attributes();
|
||||
$$ = new Stmt\Property($1, $3, $attrs, $2); $this->checkProperty($$, #1); }
|
||||
| method_modifiers T_CONST class_const_list ';'
|
||||
{ $$ = Stmt\ClassConst[$3, $1]; $this->checkClassConst($$, #1); }
|
||||
| method_modifiers T_FUNCTION optional_ref identifier_ex '(' parameter_list ')' optional_return_type method_body
|
||||
@@ -659,6 +660,7 @@ expr:
|
||||
| variable T_SL_EQUAL expr { $$ = Expr\AssignOp\ShiftLeft [$1, $3]; }
|
||||
| variable T_SR_EQUAL expr { $$ = Expr\AssignOp\ShiftRight[$1, $3]; }
|
||||
| variable T_POW_EQUAL expr { $$ = Expr\AssignOp\Pow [$1, $3]; }
|
||||
| variable T_COALESCE_EQUAL expr { $$ = Expr\AssignOp\Coalesce [$1, $3]; }
|
||||
| variable T_INC { $$ = Expr\PostInc[$1]; }
|
||||
| T_INC variable { $$ = Expr\PreInc [$2]; }
|
||||
| variable T_DEC { $$ = Expr\PostDec[$1]; }
|
||||
@@ -706,7 +708,10 @@ expr:
|
||||
| T_REQUIRE expr { $$ = Expr\Include_[$2, Expr\Include_::TYPE_REQUIRE]; }
|
||||
| T_REQUIRE_ONCE expr { $$ = Expr\Include_[$2, Expr\Include_::TYPE_REQUIRE_ONCE]; }
|
||||
| T_INT_CAST expr { $$ = Expr\Cast\Int_ [$2]; }
|
||||
| T_DOUBLE_CAST expr { $$ = Expr\Cast\Double [$2]; }
|
||||
| T_DOUBLE_CAST expr
|
||||
{ $attrs = attributes();
|
||||
$attrs['kind'] = $this->getFloatCastKind($1);
|
||||
$$ = new Expr\Cast\Double($2, $attrs); }
|
||||
| T_STRING_CAST expr { $$ = Expr\Cast\String_ [$2]; }
|
||||
| T_ARRAY_CAST expr { $$ = Expr\Cast\Array_ [$2]; }
|
||||
| T_OBJECT_CAST expr { $$ = Expr\Cast\Object_ [$2]; }
|
||||
|
||||
2
vendor/nikic/php-parser/grammar/tokens.y
vendored
2
vendor/nikic/php-parser/grammar/tokens.y
vendored
@@ -10,7 +10,7 @@
|
||||
%right T_YIELD
|
||||
%right T_DOUBLE_ARROW
|
||||
%right T_YIELD_FROM
|
||||
%left '=' T_PLUS_EQUAL T_MINUS_EQUAL T_MUL_EQUAL T_DIV_EQUAL T_CONCAT_EQUAL T_MOD_EQUAL T_AND_EQUAL T_OR_EQUAL T_XOR_EQUAL T_SL_EQUAL T_SR_EQUAL T_POW_EQUAL
|
||||
%left '=' T_PLUS_EQUAL T_MINUS_EQUAL T_MUL_EQUAL T_DIV_EQUAL T_CONCAT_EQUAL T_MOD_EQUAL T_AND_EQUAL T_OR_EQUAL T_XOR_EQUAL T_SL_EQUAL T_SR_EQUAL T_POW_EQUAL T_COALESCE_EQUAL
|
||||
%left '?' ':'
|
||||
%right T_COALESCE
|
||||
%left T_BOOLEAN_OR
|
||||
|
||||
@@ -4,6 +4,9 @@ namespace PhpParser\Builder;
|
||||
|
||||
use PhpParser;
|
||||
use PhpParser\BuilderHelpers;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\NullableType;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class Property implements PhpParser\Builder
|
||||
@@ -14,6 +17,9 @@ class Property implements PhpParser\Builder
|
||||
protected $default = null;
|
||||
protected $attributes = [];
|
||||
|
||||
/** @var null|Identifier|Name|NullableType */
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* Creates a property builder.
|
||||
*
|
||||
@@ -95,6 +101,19 @@ class Property implements PhpParser\Builder
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the property type for PHP 7.4+.
|
||||
*
|
||||
* @param string|Name|NullableType|Identifier $type
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setType($type) {
|
||||
$this->type = BuilderHelpers::normalizeType($type);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the built class node.
|
||||
*
|
||||
@@ -106,7 +125,8 @@ class Property implements PhpParser\Builder
|
||||
[
|
||||
new Stmt\PropertyProperty($this->name, $this->default)
|
||||
],
|
||||
$this->attributes
|
||||
$this->attributes,
|
||||
$this->type
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ use PhpParser\Node\Expr\BinaryOp\Concat;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
|
||||
class BuilderFactory
|
||||
@@ -77,7 +76,7 @@ class BuilderFactory
|
||||
* @return Builder\TraitUseAdaptation The create trait use adaptation builder
|
||||
*/
|
||||
public function traitUseAdaptation($trait, $method = null) : Builder\TraitUseAdaptation {
|
||||
if (is_null($method)) {
|
||||
if ($method === null) {
|
||||
$method = $trait;
|
||||
$trait = null;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ class PrintableNewAnonClassNode extends Expr
|
||||
assert($class instanceof Node\Stmt\Class_);
|
||||
// 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.
|
||||
assert($class->name === null);
|
||||
return new self(
|
||||
$newNode->args, $class->extends, $class->implements,
|
||||
$class->stmts, $newNode->getAttributes()
|
||||
|
||||
@@ -4,27 +4,54 @@ namespace PhpParser\Lexer;
|
||||
|
||||
use PhpParser\Error;
|
||||
use PhpParser\ErrorHandler;
|
||||
use PhpParser\Parser;
|
||||
|
||||
class Emulative extends \PhpParser\Lexer
|
||||
{
|
||||
const PHP_7_3 = '7.3.0dev';
|
||||
const PHP_7_4 = '7.4.0dev';
|
||||
|
||||
const FLEXIBLE_DOC_STRING_REGEX = <<<'REGEX'
|
||||
/<<<[ \t]*(['"]?)([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)\1\r?\n
|
||||
(?:.*\r?\n)*?
|
||||
(?<indentation>\h*)\2(?![a-zA-Z_\x80-\xff])(?<separator>(?:;?[\r\n])?)/x
|
||||
REGEX;
|
||||
|
||||
const T_COALESCE_EQUAL = 1007;
|
||||
|
||||
/**
|
||||
* @var array Patches used to reverse changes introduced in the code
|
||||
* @var mixed[] Patches used to reverse changes introduced in the code
|
||||
*/
|
||||
private $patches;
|
||||
private $patches = [];
|
||||
|
||||
/**
|
||||
* @param mixed[] $options
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
parent::__construct($options);
|
||||
|
||||
// add emulated tokens here
|
||||
$this->tokenMap[self::T_COALESCE_EQUAL] = Parser\Tokens::T_COALESCE_EQUAL;
|
||||
}
|
||||
|
||||
public function startLexing(string $code, ErrorHandler $errorHandler = null) {
|
||||
$this->patches = [];
|
||||
$preparedCode = $this->prepareCode($code);
|
||||
if (null === $preparedCode) {
|
||||
|
||||
if ($this->isEmulationNeeded($code) === false) {
|
||||
// Nothing to emulate, yay
|
||||
parent::startLexing($code, $errorHandler);
|
||||
return;
|
||||
}
|
||||
|
||||
$collector = new ErrorHandler\Collecting();
|
||||
|
||||
// 1. emulation of heredoc and nowdoc new syntax
|
||||
$preparedCode = $this->processHeredocNowdoc($code);
|
||||
parent::startLexing($preparedCode, $collector);
|
||||
|
||||
// 2. emulation of ??= token
|
||||
$this->processCoaleseEqual($code);
|
||||
$this->fixupTokens();
|
||||
|
||||
$errors = $collector->getErrors();
|
||||
@@ -36,30 +63,60 @@ class Emulative extends \PhpParser\Lexer
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares code for emulation. If nothing has to be emulated null is returned.
|
||||
*
|
||||
* @param string $code
|
||||
* @return null|string
|
||||
*/
|
||||
private function prepareCode(string $code) {
|
||||
private function isCoalesceEqualEmulationNeeded(string $code): bool
|
||||
{
|
||||
// skip version where this works without emulation
|
||||
if (version_compare(\PHP_VERSION, self::PHP_7_4, '>=')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return strpos($code, '??=') !== false;
|
||||
}
|
||||
|
||||
private function processCoaleseEqual(string $code)
|
||||
{
|
||||
if ($this->isCoalesceEqualEmulationNeeded($code) === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We need to manually iterate and manage a count because we'll change
|
||||
// the tokens array on the way
|
||||
$line = 1;
|
||||
for ($i = 0, $c = count($this->tokens); $i < $c; ++$i) {
|
||||
if (isset($this->tokens[$i + 1])) {
|
||||
if ($this->tokens[$i][0] === T_COALESCE && $this->tokens[$i + 1] === '=') {
|
||||
array_splice($this->tokens, $i, 2, [
|
||||
[self::T_COALESCE_EQUAL, '??=', $line]
|
||||
]);
|
||||
$c--;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (\is_array($this->tokens[$i])) {
|
||||
$line += substr_count($this->tokens[$i][1], "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function isHeredocNowdocEmulationNeeded(string $code): bool
|
||||
{
|
||||
// skip version where this works without emulation
|
||||
if (version_compare(\PHP_VERSION, self::PHP_7_3, '>=')) {
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strpos($code, '<<<') === false) {
|
||||
// Definitely doesn't contain heredoc/nowdoc
|
||||
return null;
|
||||
return strpos($code, '<<<') !== false;
|
||||
}
|
||||
|
||||
private function processHeredocNowdoc(string $code): string
|
||||
{
|
||||
if ($this->isHeredocNowdocEmulationNeeded($code) === false) {
|
||||
return $code;
|
||||
}
|
||||
|
||||
$flexibleDocStringRegex = <<<'REGEX'
|
||||
/<<<[ \t]*(['"]?)([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)\1\r?\n
|
||||
(?:.*\r?\n)*?
|
||||
(?<indentation>\h*)\2(?![a-zA-Z_\x80-\xff])(?<separator>(?:;?[\r\n])?)/x
|
||||
REGEX;
|
||||
if (!preg_match_all($flexibleDocStringRegex, $code, $matches, PREG_SET_ORDER|PREG_OFFSET_CAPTURE)) {
|
||||
if (!preg_match_all(self::FLEXIBLE_DOC_STRING_REGEX, $code, $matches, PREG_SET_ORDER|PREG_OFFSET_CAPTURE)) {
|
||||
// No heredoc/nowdoc found
|
||||
return null;
|
||||
return $code;
|
||||
}
|
||||
|
||||
// Keep track of how much we need to adjust string offsets due to the modifications we
|
||||
@@ -93,19 +150,31 @@ REGEX;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->patches)) {
|
||||
// We did not end up emulating anything
|
||||
return null;
|
||||
}
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
private function fixupTokens() {
|
||||
assert(count($this->patches) > 0);
|
||||
private function isEmulationNeeded(string $code): bool
|
||||
{
|
||||
if ($this->isHeredocNowdocEmulationNeeded($code)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->isCoalesceEqualEmulationNeeded($code)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function fixupTokens()
|
||||
{
|
||||
if (\count($this->patches) === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Load first patch
|
||||
$patchIdx = 0;
|
||||
|
||||
list($patchPos, $patchType, $patchText) = $this->patches[$patchIdx];
|
||||
|
||||
// We use a manual loop over the tokens, because we modify the array on the fly
|
||||
@@ -200,4 +269,4 @@ REGEX;
|
||||
$error->setAttributes($attrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,11 @@ use PhpParser\Node\Expr\Cast;
|
||||
|
||||
class Double extends Cast
|
||||
{
|
||||
// For use in "kind" attribute
|
||||
const KIND_DOUBLE = 1; // "double" syntax
|
||||
const KIND_FLOAT = 2; // "float" syntax
|
||||
const KIND_REAL = 3; // "real" syntax
|
||||
|
||||
public function getType() : string {
|
||||
return 'Expr_Cast_Double';
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use PhpParser\NodeAbstract;
|
||||
|
||||
class Param extends NodeAbstract
|
||||
{
|
||||
/** @var null|Identifier|Name|NullableType Typehint */
|
||||
/** @var null|Identifier|Name|NullableType Type declaration */
|
||||
public $type;
|
||||
/** @var bool Whether parameter is passed by reference */
|
||||
public $byRef;
|
||||
@@ -20,12 +20,12 @@ class Param extends NodeAbstract
|
||||
/**
|
||||
* Constructs a parameter node.
|
||||
*
|
||||
* @param Expr\Variable|Expr\Error $var Parameter variable
|
||||
* @param null|Expr $default Default value
|
||||
* @param null|string|Name|NullableType $type Typehint
|
||||
* @param bool $byRef Whether is passed by reference
|
||||
* @param bool $variadic Whether this is a variadic argument
|
||||
* @param array $attributes Additional attributes
|
||||
* @param Expr\Variable|Expr\Error $var Parameter variable
|
||||
* @param null|Expr $default Default value
|
||||
* @param null|string|Identifier|Name|NullableType $type Type declaration
|
||||
* @param bool $byRef Whether is passed by reference
|
||||
* @param bool $variadic Whether this is a variadic argument
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(
|
||||
$var, Expr $default = null, $type = null,
|
||||
@@ -42,7 +42,7 @@ class Param extends NodeAbstract
|
||||
public function getSubNodeNames() : array {
|
||||
return ['type', 'byRef', 'variadic', 'var', 'default'];
|
||||
}
|
||||
|
||||
|
||||
public function getType() : string {
|
||||
return 'Param';
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\NullableType;
|
||||
|
||||
class Property extends Node\Stmt
|
||||
{
|
||||
@@ -10,22 +13,26 @@ class Property extends Node\Stmt
|
||||
public $flags;
|
||||
/** @var PropertyProperty[] Properties */
|
||||
public $props;
|
||||
/** @var null|Identifier|Name|NullableType Type declaration */
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* Constructs a class property list node.
|
||||
*
|
||||
* @param int $flags Modifiers
|
||||
* @param PropertyProperty[] $props Properties
|
||||
* @param array $attributes Additional attributes
|
||||
* @param int $flags Modifiers
|
||||
* @param PropertyProperty[] $props Properties
|
||||
* @param array $attributes Additional attributes
|
||||
* @param null|string|Identifier|Name|NullableType $type Type declaration
|
||||
*/
|
||||
public function __construct(int $flags, array $props, array $attributes = []) {
|
||||
public function __construct(int $flags, array $props, array $attributes = [], $type = null) {
|
||||
parent::__construct($attributes);
|
||||
$this->flags = $flags;
|
||||
$this->props = $props;
|
||||
$this->type = \is_string($type) ? new Identifier($type) : $type;
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
return ['flags', 'props'];
|
||||
return ['flags', 'type', 'props'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,7 +71,7 @@ class Property extends Node\Stmt
|
||||
public function isStatic() : bool {
|
||||
return (bool) ($this->flags & Class_::MODIFIER_STATIC);
|
||||
}
|
||||
|
||||
|
||||
public function getType() : string {
|
||||
return 'Stmt_Property';
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
use PhpParser\Node;
|
||||
|
||||
abstract class NodeAbstract implements Node, \JsonSerializable
|
||||
{
|
||||
protected $attributes;
|
||||
@@ -159,11 +157,11 @@ abstract class NodeAbstract implements Node, \JsonSerializable
|
||||
}
|
||||
|
||||
public function getAttribute(string $key, $default = null) {
|
||||
if (!array_key_exists($key, $this->attributes)) {
|
||||
return $default;
|
||||
} else {
|
||||
if (array_key_exists($key, $this->attributes)) {
|
||||
return $this->attributes[$key];
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
public function getAttributes() : array {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace PhpParser\NodeVisitor;
|
||||
|
||||
use PhpParser\Error;
|
||||
use PhpParser\ErrorHandler;
|
||||
use PhpParser\NameContext;
|
||||
use PhpParser\Node;
|
||||
@@ -94,6 +93,10 @@ class NameResolver extends NodeVisitorAbstract
|
||||
|| $node instanceof Expr\Closure
|
||||
) {
|
||||
$this->resolveSignature($node);
|
||||
} elseif ($node instanceof Stmt\Property) {
|
||||
if (null !== $node->type) {
|
||||
$node->type = $this->resolveType($node->type);
|
||||
}
|
||||
} elseif ($node instanceof Stmt\Const_) {
|
||||
foreach ($node->consts as $const) {
|
||||
$this->addNamespacedName($const);
|
||||
|
||||
1820
vendor/nikic/php-parser/lib/PhpParser/Parser/Php5.php
vendored
1820
vendor/nikic/php-parser/lib/PhpParser/Parser/Php5.php
vendored
File diff suppressed because it is too large
Load Diff
1466
vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php
vendored
1466
vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php
vendored
File diff suppressed because it is too large
Load Diff
@@ -30,115 +30,116 @@ final class Tokens
|
||||
const T_SL_EQUAL = 278;
|
||||
const T_SR_EQUAL = 279;
|
||||
const T_POW_EQUAL = 280;
|
||||
const T_COALESCE = 281;
|
||||
const T_BOOLEAN_OR = 282;
|
||||
const T_BOOLEAN_AND = 283;
|
||||
const T_IS_EQUAL = 284;
|
||||
const T_IS_NOT_EQUAL = 285;
|
||||
const T_IS_IDENTICAL = 286;
|
||||
const T_IS_NOT_IDENTICAL = 287;
|
||||
const T_SPACESHIP = 288;
|
||||
const T_IS_SMALLER_OR_EQUAL = 289;
|
||||
const T_IS_GREATER_OR_EQUAL = 290;
|
||||
const T_SL = 291;
|
||||
const T_SR = 292;
|
||||
const T_INSTANCEOF = 293;
|
||||
const T_INC = 294;
|
||||
const T_DEC = 295;
|
||||
const T_INT_CAST = 296;
|
||||
const T_DOUBLE_CAST = 297;
|
||||
const T_STRING_CAST = 298;
|
||||
const T_ARRAY_CAST = 299;
|
||||
const T_OBJECT_CAST = 300;
|
||||
const T_BOOL_CAST = 301;
|
||||
const T_UNSET_CAST = 302;
|
||||
const T_POW = 303;
|
||||
const T_NEW = 304;
|
||||
const T_CLONE = 305;
|
||||
const T_EXIT = 306;
|
||||
const T_IF = 307;
|
||||
const T_ELSEIF = 308;
|
||||
const T_ELSE = 309;
|
||||
const T_ENDIF = 310;
|
||||
const T_LNUMBER = 311;
|
||||
const T_DNUMBER = 312;
|
||||
const T_STRING = 313;
|
||||
const T_STRING_VARNAME = 314;
|
||||
const T_VARIABLE = 315;
|
||||
const T_NUM_STRING = 316;
|
||||
const T_INLINE_HTML = 317;
|
||||
const T_CHARACTER = 318;
|
||||
const T_BAD_CHARACTER = 319;
|
||||
const T_ENCAPSED_AND_WHITESPACE = 320;
|
||||
const T_CONSTANT_ENCAPSED_STRING = 321;
|
||||
const T_ECHO = 322;
|
||||
const T_DO = 323;
|
||||
const T_WHILE = 324;
|
||||
const T_ENDWHILE = 325;
|
||||
const T_FOR = 326;
|
||||
const T_ENDFOR = 327;
|
||||
const T_FOREACH = 328;
|
||||
const T_ENDFOREACH = 329;
|
||||
const T_DECLARE = 330;
|
||||
const T_ENDDECLARE = 331;
|
||||
const T_AS = 332;
|
||||
const T_SWITCH = 333;
|
||||
const T_ENDSWITCH = 334;
|
||||
const T_CASE = 335;
|
||||
const T_DEFAULT = 336;
|
||||
const T_BREAK = 337;
|
||||
const T_CONTINUE = 338;
|
||||
const T_GOTO = 339;
|
||||
const T_FUNCTION = 340;
|
||||
const T_CONST = 341;
|
||||
const T_RETURN = 342;
|
||||
const T_TRY = 343;
|
||||
const T_CATCH = 344;
|
||||
const T_FINALLY = 345;
|
||||
const T_THROW = 346;
|
||||
const T_USE = 347;
|
||||
const T_INSTEADOF = 348;
|
||||
const T_GLOBAL = 349;
|
||||
const T_STATIC = 350;
|
||||
const T_ABSTRACT = 351;
|
||||
const T_FINAL = 352;
|
||||
const T_PRIVATE = 353;
|
||||
const T_PROTECTED = 354;
|
||||
const T_PUBLIC = 355;
|
||||
const T_VAR = 356;
|
||||
const T_UNSET = 357;
|
||||
const T_ISSET = 358;
|
||||
const T_EMPTY = 359;
|
||||
const T_HALT_COMPILER = 360;
|
||||
const T_CLASS = 361;
|
||||
const T_TRAIT = 362;
|
||||
const T_INTERFACE = 363;
|
||||
const T_EXTENDS = 364;
|
||||
const T_IMPLEMENTS = 365;
|
||||
const T_OBJECT_OPERATOR = 366;
|
||||
const T_LIST = 367;
|
||||
const T_ARRAY = 368;
|
||||
const T_CALLABLE = 369;
|
||||
const T_CLASS_C = 370;
|
||||
const T_TRAIT_C = 371;
|
||||
const T_METHOD_C = 372;
|
||||
const T_FUNC_C = 373;
|
||||
const T_LINE = 374;
|
||||
const T_FILE = 375;
|
||||
const T_COMMENT = 376;
|
||||
const T_DOC_COMMENT = 377;
|
||||
const T_OPEN_TAG = 378;
|
||||
const T_OPEN_TAG_WITH_ECHO = 379;
|
||||
const T_CLOSE_TAG = 380;
|
||||
const T_WHITESPACE = 381;
|
||||
const T_START_HEREDOC = 382;
|
||||
const T_END_HEREDOC = 383;
|
||||
const T_DOLLAR_OPEN_CURLY_BRACES = 384;
|
||||
const T_CURLY_OPEN = 385;
|
||||
const T_PAAMAYIM_NEKUDOTAYIM = 386;
|
||||
const T_NAMESPACE = 387;
|
||||
const T_NS_C = 388;
|
||||
const T_DIR = 389;
|
||||
const T_NS_SEPARATOR = 390;
|
||||
const T_ELLIPSIS = 391;
|
||||
const T_COALESCE_EQUAL = 281;
|
||||
const T_COALESCE = 282;
|
||||
const T_BOOLEAN_OR = 283;
|
||||
const T_BOOLEAN_AND = 284;
|
||||
const T_IS_EQUAL = 285;
|
||||
const T_IS_NOT_EQUAL = 286;
|
||||
const T_IS_IDENTICAL = 287;
|
||||
const T_IS_NOT_IDENTICAL = 288;
|
||||
const T_SPACESHIP = 289;
|
||||
const T_IS_SMALLER_OR_EQUAL = 290;
|
||||
const T_IS_GREATER_OR_EQUAL = 291;
|
||||
const T_SL = 292;
|
||||
const T_SR = 293;
|
||||
const T_INSTANCEOF = 294;
|
||||
const T_INC = 295;
|
||||
const T_DEC = 296;
|
||||
const T_INT_CAST = 297;
|
||||
const T_DOUBLE_CAST = 298;
|
||||
const T_STRING_CAST = 299;
|
||||
const T_ARRAY_CAST = 300;
|
||||
const T_OBJECT_CAST = 301;
|
||||
const T_BOOL_CAST = 302;
|
||||
const T_UNSET_CAST = 303;
|
||||
const T_POW = 304;
|
||||
const T_NEW = 305;
|
||||
const T_CLONE = 306;
|
||||
const T_EXIT = 307;
|
||||
const T_IF = 308;
|
||||
const T_ELSEIF = 309;
|
||||
const T_ELSE = 310;
|
||||
const T_ENDIF = 311;
|
||||
const T_LNUMBER = 312;
|
||||
const T_DNUMBER = 313;
|
||||
const T_STRING = 314;
|
||||
const T_STRING_VARNAME = 315;
|
||||
const T_VARIABLE = 316;
|
||||
const T_NUM_STRING = 317;
|
||||
const T_INLINE_HTML = 318;
|
||||
const T_CHARACTER = 319;
|
||||
const T_BAD_CHARACTER = 320;
|
||||
const T_ENCAPSED_AND_WHITESPACE = 321;
|
||||
const T_CONSTANT_ENCAPSED_STRING = 322;
|
||||
const T_ECHO = 323;
|
||||
const T_DO = 324;
|
||||
const T_WHILE = 325;
|
||||
const T_ENDWHILE = 326;
|
||||
const T_FOR = 327;
|
||||
const T_ENDFOR = 328;
|
||||
const T_FOREACH = 329;
|
||||
const T_ENDFOREACH = 330;
|
||||
const T_DECLARE = 331;
|
||||
const T_ENDDECLARE = 332;
|
||||
const T_AS = 333;
|
||||
const T_SWITCH = 334;
|
||||
const T_ENDSWITCH = 335;
|
||||
const T_CASE = 336;
|
||||
const T_DEFAULT = 337;
|
||||
const T_BREAK = 338;
|
||||
const T_CONTINUE = 339;
|
||||
const T_GOTO = 340;
|
||||
const T_FUNCTION = 341;
|
||||
const T_CONST = 342;
|
||||
const T_RETURN = 343;
|
||||
const T_TRY = 344;
|
||||
const T_CATCH = 345;
|
||||
const T_FINALLY = 346;
|
||||
const T_THROW = 347;
|
||||
const T_USE = 348;
|
||||
const T_INSTEADOF = 349;
|
||||
const T_GLOBAL = 350;
|
||||
const T_STATIC = 351;
|
||||
const T_ABSTRACT = 352;
|
||||
const T_FINAL = 353;
|
||||
const T_PRIVATE = 354;
|
||||
const T_PROTECTED = 355;
|
||||
const T_PUBLIC = 356;
|
||||
const T_VAR = 357;
|
||||
const T_UNSET = 358;
|
||||
const T_ISSET = 359;
|
||||
const T_EMPTY = 360;
|
||||
const T_HALT_COMPILER = 361;
|
||||
const T_CLASS = 362;
|
||||
const T_TRAIT = 363;
|
||||
const T_INTERFACE = 364;
|
||||
const T_EXTENDS = 365;
|
||||
const T_IMPLEMENTS = 366;
|
||||
const T_OBJECT_OPERATOR = 367;
|
||||
const T_LIST = 368;
|
||||
const T_ARRAY = 369;
|
||||
const T_CALLABLE = 370;
|
||||
const T_CLASS_C = 371;
|
||||
const T_TRAIT_C = 372;
|
||||
const T_METHOD_C = 373;
|
||||
const T_FUNC_C = 374;
|
||||
const T_LINE = 375;
|
||||
const T_FILE = 376;
|
||||
const T_COMMENT = 377;
|
||||
const T_DOC_COMMENT = 378;
|
||||
const T_OPEN_TAG = 379;
|
||||
const T_OPEN_TAG_WITH_ECHO = 380;
|
||||
const T_CLOSE_TAG = 381;
|
||||
const T_WHITESPACE = 382;
|
||||
const T_START_HEREDOC = 383;
|
||||
const T_END_HEREDOC = 384;
|
||||
const T_DOLLAR_OPEN_CURLY_BRACES = 385;
|
||||
const T_CURLY_OPEN = 386;
|
||||
const T_PAAMAYIM_NEKUDOTAYIM = 387;
|
||||
const T_NAMESPACE = 388;
|
||||
const T_NS_C = 389;
|
||||
const T_DIR = 390;
|
||||
const T_NS_SEPARATOR = 391;
|
||||
const T_ELLIPSIS = 392;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace PhpParser;
|
||||
* turn is based on work by Masato Bito.
|
||||
*/
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\Cast\Double;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Scalar\Encapsed;
|
||||
@@ -680,6 +681,20 @@ abstract class ParserAbstract implements Parser
|
||||
return $this->startAttributeStack[$pos] + $this->endAttributeStack[$pos];
|
||||
}
|
||||
|
||||
protected function getFloatCastKind(string $cast): int
|
||||
{
|
||||
$cast = strtolower($cast);
|
||||
if (strpos($cast, 'float') !== false) {
|
||||
return Double::KIND_FLOAT;
|
||||
}
|
||||
|
||||
if (strpos($cast, 'real') !== false) {
|
||||
return Double::KIND_REAL;
|
||||
}
|
||||
|
||||
return Double::KIND_DOUBLE;
|
||||
}
|
||||
|
||||
protected function parseLNumber($str, $attributes, $allowInvalidOctal = false) {
|
||||
try {
|
||||
return LNumber::fromString($str, $attributes, $allowInvalidOctal);
|
||||
|
||||
@@ -260,6 +260,10 @@ class Standard extends PrettyPrinterAbstract
|
||||
return $this->pInfixOp(AssignOp\Pow::class, $node->var, ' **= ', $node->expr);
|
||||
}
|
||||
|
||||
protected function pExpr_AssignOp_Coalesce(AssignOp\Coalesce $node) {
|
||||
return $this->pInfixOp(AssignOp\Coalesce::class, $node->var, ' ??= ', $node->expr);
|
||||
}
|
||||
|
||||
// Binary expressions
|
||||
|
||||
protected function pExpr_BinaryOp_Plus(BinaryOp\Plus $node) {
|
||||
@@ -435,7 +439,15 @@ class Standard extends PrettyPrinterAbstract
|
||||
}
|
||||
|
||||
protected function pExpr_Cast_Double(Cast\Double $node) {
|
||||
return $this->pPrefixOp(Cast\Double::class, '(double) ', $node->expr);
|
||||
$kind = $node->getAttribute('kind', Cast\Double::KIND_DOUBLE);
|
||||
if ($kind === Cast\Double::KIND_DOUBLE) {
|
||||
$cast = '(double)';
|
||||
} elseif ($kind === Cast\Double::KIND_FLOAT) {
|
||||
$cast = '(float)';
|
||||
} elseif ($kind === Cast\Double::KIND_REAL) {
|
||||
$cast = '(real)';
|
||||
}
|
||||
return $this->pPrefixOp(Cast\Double::class, $cast . ' ', $node->expr);
|
||||
}
|
||||
|
||||
protected function pExpr_Cast_String(Cast\String_ $node) {
|
||||
@@ -680,7 +692,9 @@ class Standard extends PrettyPrinterAbstract
|
||||
}
|
||||
|
||||
protected function pStmt_Property(Stmt\Property $node) {
|
||||
return (0 === $node->flags ? 'var ' : $this->pModifiers($node->flags)) . $this->pCommaSeparated($node->props) . ';';
|
||||
return (0 === $node->flags ? 'var ' : $this->pModifiers($node->flags))
|
||||
. ($node->type ? $this->p($node->type) . ' ' : '')
|
||||
. $this->pCommaSeparated($node->props) . ';';
|
||||
}
|
||||
|
||||
protected function pStmt_PropertyProperty(Stmt\PropertyProperty $node) {
|
||||
|
||||
@@ -9,7 +9,6 @@ use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\AssignOp;
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
use PhpParser\Node\Expr\Cast;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Scalar;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
@@ -83,6 +82,7 @@ abstract class PrettyPrinterAbstract
|
||||
AssignOp\ShiftLeft::class => [160, 1],
|
||||
AssignOp\ShiftRight::class => [160, 1],
|
||||
AssignOp\Pow::class => [160, 1],
|
||||
AssignOp\Coalesce::class => [160, 1],
|
||||
Expr\YieldFrom::class => [165, 1],
|
||||
Expr\Print_::class => [168, 1],
|
||||
BinaryOp\LogicalAnd::class => [170, -1],
|
||||
@@ -617,12 +617,14 @@ abstract class PrettyPrinterAbstract
|
||||
return $this->pFallback($fallbackNode);
|
||||
}
|
||||
|
||||
list($findToken, $extraLeft, $extraRight) = $this->insertionMap[$key];
|
||||
list($findToken, $beforeToken, $extraLeft, $extraRight) = $this->insertionMap[$key];
|
||||
if (null !== $findToken) {
|
||||
$subStartPos = $this->origTokens->findRight($pos, $findToken) + 1;
|
||||
$subStartPos = $this->origTokens->findRight($pos, $findToken)
|
||||
+ (int) !$beforeToken;
|
||||
} else {
|
||||
$subStartPos = $pos;
|
||||
}
|
||||
|
||||
if (null === $extraLeft && null !== $extraRight) {
|
||||
// If inserting on the right only, skipping whitespace looks better
|
||||
$subStartPos = $this->origTokens->skipRightWhitespace($subStartPos);
|
||||
@@ -1155,7 +1157,7 @@ abstract class PrettyPrinterAbstract
|
||||
Expr\Assign::class, Expr\AssignRef::class, AssignOp\Plus::class, AssignOp\Minus::class,
|
||||
AssignOp\Mul::class, AssignOp\Div::class, AssignOp\Concat::class, AssignOp\Mod::class,
|
||||
AssignOp\BitwiseAnd::class, AssignOp\BitwiseOr::class, AssignOp\BitwiseXor::class,
|
||||
AssignOp\ShiftLeft::class, AssignOp\ShiftRight::class, AssignOp\Pow::class,
|
||||
AssignOp\ShiftLeft::class, AssignOp\ShiftRight::class, AssignOp\Pow::class, AssignOp\Coalesce::class
|
||||
];
|
||||
foreach ($assignOps as $assignOp) {
|
||||
$this->fixupMap[$assignOp] = [
|
||||
@@ -1209,6 +1211,7 @@ abstract class PrettyPrinterAbstract
|
||||
'Stmt_Function->returnType' => $stripColon,
|
||||
'Stmt_If->else' => $stripLeft,
|
||||
'Stmt_Namespace->name' => $stripLeft,
|
||||
'Stmt_Property->type' => $stripRight,
|
||||
'Stmt_PropertyProperty->default' => $stripEquals,
|
||||
'Stmt_Return->expr' => $stripBoth,
|
||||
'Stmt_StaticVar->default' => $stripEquals,
|
||||
@@ -1226,28 +1229,29 @@ abstract class PrettyPrinterAbstract
|
||||
|
||||
// TODO: "yield" where both key and value are inserted doesn't work
|
||||
$this->insertionMap = [
|
||||
'Expr_ArrayDimFetch->dim' => ['[', null, null],
|
||||
'Expr_ArrayItem->key' => [null, null, ' => '],
|
||||
'Expr_Closure->returnType' => [')', ' : ', null],
|
||||
'Expr_Ternary->if' => ['?', ' ', ' '],
|
||||
'Expr_Yield->key' => [\T_YIELD, null, ' => '],
|
||||
'Expr_Yield->value' => [\T_YIELD, ' ', null],
|
||||
'Param->type' => [null, null, ' '],
|
||||
'Param->default' => [null, ' = ', null],
|
||||
'Stmt_Break->num' => [\T_BREAK, ' ', null],
|
||||
'Stmt_ClassMethod->returnType' => [')', ' : ', null],
|
||||
'Stmt_Class->extends' => [null, ' extends ', null],
|
||||
'Expr_ArrayDimFetch->dim' => ['[', false, null, null],
|
||||
'Expr_ArrayItem->key' => [null, false, null, ' => '],
|
||||
'Expr_Closure->returnType' => [')', false, ' : ', null],
|
||||
'Expr_Ternary->if' => ['?', false, ' ', ' '],
|
||||
'Expr_Yield->key' => [\T_YIELD, false, null, ' => '],
|
||||
'Expr_Yield->value' => [\T_YIELD, false, ' ', null],
|
||||
'Param->type' => [null, false, null, ' '],
|
||||
'Param->default' => [null, false, ' = ', null],
|
||||
'Stmt_Break->num' => [\T_BREAK, false, ' ', null],
|
||||
'Stmt_ClassMethod->returnType' => [')', false, ' : ', null],
|
||||
'Stmt_Class->extends' => [null, false, ' extends ', null],
|
||||
'Expr_PrintableNewAnonClass->extends' => [null, ' extends ', null],
|
||||
'Stmt_Continue->num' => [\T_CONTINUE, ' ', null],
|
||||
'Stmt_Foreach->keyVar' => [\T_AS, null, ' => '],
|
||||
'Stmt_Function->returnType' => [')', ' : ', null],
|
||||
'Stmt_If->else' => [null, ' ', null],
|
||||
'Stmt_Namespace->name' => [\T_NAMESPACE, ' ', null],
|
||||
'Stmt_PropertyProperty->default' => [null, ' = ', null],
|
||||
'Stmt_Return->expr' => [\T_RETURN, ' ', null],
|
||||
'Stmt_StaticVar->default' => [null, ' = ', null],
|
||||
//'Stmt_TraitUseAdaptation_Alias->newName' => [T_AS, ' ', null], // TODO
|
||||
'Stmt_TryCatch->finally' => [null, ' ', null],
|
||||
'Stmt_Continue->num' => [\T_CONTINUE, false, ' ', null],
|
||||
'Stmt_Foreach->keyVar' => [\T_AS, false, null, ' => '],
|
||||
'Stmt_Function->returnType' => [')', false, ' : ', null],
|
||||
'Stmt_If->else' => [null, false, ' ', null],
|
||||
'Stmt_Namespace->name' => [\T_NAMESPACE, false, ' ', null],
|
||||
'Stmt_Property->type' => [\T_VARIABLE, true, null, ' '],
|
||||
'Stmt_PropertyProperty->default' => [null, false, ' = ', null],
|
||||
'Stmt_Return->expr' => [\T_RETURN, false, ' ', null],
|
||||
'Stmt_StaticVar->default' => [null, false, ' = ', null],
|
||||
//'Stmt_TraitUseAdaptation_Alias->newName' => [T_AS, false, ' ', null], // TODO
|
||||
'Stmt_TryCatch->finally' => [null, false, ' ', null],
|
||||
|
||||
// 'Expr_Exit->expr': Complicated due to optional ()
|
||||
// 'Stmt_Case->cond': Conversion from default to case
|
||||
|
||||
4
vendor/nikic/php-parser/phpunit.xml.dist
vendored
4
vendor/nikic/php-parser/phpunit.xml.dist
vendored
@@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit backupGlobals="false"
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
beStrictAboutTestsThatDoNotTestAnything="false"
|
||||
bootstrap="./test/bootstrap.php">
|
||||
|
||||
@@ -6,9 +6,8 @@ use PhpParser\Comment;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ClassTest extends TestCase
|
||||
class ClassTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected function createClassBuilder($class) {
|
||||
return new Class_($class);
|
||||
|
||||
@@ -8,9 +8,8 @@ use PhpParser\Node\Expr\Print_;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FunctionTest extends TestCase
|
||||
class FunctionTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function createFunctionBuilder($name) {
|
||||
return new Function_($name);
|
||||
|
||||
@@ -6,9 +6,8 @@ use PhpParser\Comment;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Scalar\DNumber;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class InterfaceTest extends TestCase
|
||||
class InterfaceTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/** @var Interface_ */
|
||||
protected $builder;
|
||||
|
||||
@@ -8,9 +8,8 @@ use PhpParser\Node\Expr\Print_;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class MethodTest extends TestCase
|
||||
class MethodTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function createMethodBuilder($name) {
|
||||
return new Method($name);
|
||||
|
||||
@@ -5,9 +5,8 @@ namespace PhpParser\Builder;
|
||||
use PhpParser\Comment\Doc;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class NamespaceTest extends TestCase
|
||||
class NamespaceTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected function createNamespaceBuilder($fqn) {
|
||||
return new Namespace_($fqn);
|
||||
|
||||
@@ -5,9 +5,8 @@ namespace PhpParser\Builder;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Scalar;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ParamTest extends TestCase
|
||||
class ParamTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function createParamBuilder($name) {
|
||||
return new Param($name);
|
||||
|
||||
@@ -7,9 +7,8 @@ use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Scalar;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PropertyTest extends TestCase
|
||||
class PropertyTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function createPropertyBuilder($name) {
|
||||
return new Property($name);
|
||||
|
||||
@@ -5,9 +5,8 @@ namespace PhpParser\Builder;
|
||||
use PhpParser\Comment;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class TraitTest extends TestCase
|
||||
class TraitTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected function createTraitBuilder($class) {
|
||||
return new Trait_($class);
|
||||
|
||||
@@ -2,14 +2,11 @@
|
||||
|
||||
namespace PhpParser\Builder;
|
||||
|
||||
use PhpParser\Comment;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class TraitUseAdaptationTest extends TestCase
|
||||
class TraitUseAdaptationTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected function createTraitUseAdaptationBuilder($trait, $method) {
|
||||
return new TraitUseAdaptation($trait, $method);
|
||||
|
||||
@@ -2,13 +2,10 @@
|
||||
|
||||
namespace PhpParser\Builder;
|
||||
|
||||
use PhpParser\Comment;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class TraitUseTest extends TestCase
|
||||
class TraitUseTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected function createTraitUseBuilder(...$traits) {
|
||||
return new TraitUse(...$traits);
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace PhpParser\Builder;
|
||||
|
||||
use PhpParser\Builder;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class UseTest extends TestCase
|
||||
class UseTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected function createUseBuilder($name, $type = Stmt\Use_::TYPE_NORMAL) {
|
||||
return new Builder\Use_($name, $type);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
use PhpParser\Builder;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\BinaryOp\Concat;
|
||||
@@ -10,10 +9,8 @@ use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Scalar\LNumber;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Yaml\Tests\A;
|
||||
|
||||
class BuilderFactoryTest extends TestCase
|
||||
class BuilderFactoryTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTestFactory
|
||||
|
||||
@@ -5,8 +5,6 @@ namespace PhpParser;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
require_once __DIR__ . '/CodeTestAbstract.php';
|
||||
|
||||
class CodeParsingTest extends CodeTestAbstract
|
||||
{
|
||||
/**
|
||||
@@ -79,9 +77,9 @@ class CodeParsingTest extends CodeTestAbstract
|
||||
private function formatErrorMessage(Error $e, $code) {
|
||||
if ($e->hasColumnInfo()) {
|
||||
return $e->getMessageWithColumnInfo($code);
|
||||
} else {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
private function checkAttributes($stmts) {
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
require_once __DIR__ . '/CodeTestParser.php';
|
||||
|
||||
abstract class CodeTestAbstract extends TestCase
|
||||
abstract class CodeTestAbstract extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected function getTests($directory, $fileExtension, $chunksPerTest = 2) {
|
||||
$parser = new CodeTestParser;
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CommentTest extends TestCase
|
||||
class CommentTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testGetSet() {
|
||||
$comment = new Comment('/* Some comment */', 1, 10, 2);
|
||||
|
||||
@@ -4,9 +4,8 @@ namespace PhpParser;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Scalar;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ConstExprEvaluatorTest extends TestCase
|
||||
class ConstExprEvaluatorTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/** @dataProvider provideTestEvaluate */
|
||||
public function testEvaluate($exprString, $expected) {
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
namespace PhpParser\ErrorHandler;
|
||||
|
||||
use PhpParser\Error;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CollectingTest extends TestCase
|
||||
class CollectingTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testHandleError() {
|
||||
$errorHandler = new Collecting();
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
namespace PhpParser\ErrorHandler;
|
||||
|
||||
use PhpParser\Error;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ThrowingTest extends TestCase
|
||||
class ThrowingTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testHandleError() {
|
||||
$this->expectException(Error::class);
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ErrorTest extends TestCase
|
||||
class ErrorTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testConstruct() {
|
||||
$attributes = [
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace PhpParser\Internal;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DifferTest extends TestCase
|
||||
class DifferTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private function formatDiffString(array $diff) {
|
||||
$diffStr = '';
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class JsonDecoderTest extends TestCase
|
||||
class JsonDecoderTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testRoundTrip() {
|
||||
$code = <<<'PHP'
|
||||
|
||||
@@ -6,8 +6,6 @@ use PhpParser\ErrorHandler;
|
||||
use PhpParser\LexerTest;
|
||||
use PhpParser\Parser\Tokens;
|
||||
|
||||
require_once __DIR__ . '/../LexerTest.php';
|
||||
|
||||
class EmulativeTest extends LexerTest
|
||||
{
|
||||
protected function getLexer(array $options = []) {
|
||||
@@ -110,6 +108,10 @@ class EmulativeTest extends LexerTest
|
||||
|
||||
public function provideTestLexNewFeatures() {
|
||||
return [
|
||||
// PHP 7.4
|
||||
['??=', [
|
||||
[Tokens::T_COALESCE_EQUAL, '??='],
|
||||
]],
|
||||
['yield from', [
|
||||
[Tokens::T_YIELD_FROM, 'yield from'],
|
||||
]],
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
namespace PhpParser;
|
||||
|
||||
use PhpParser\Parser\Tokens;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class LexerTest extends TestCase
|
||||
class LexerTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/* To allow overwriting in parent class */
|
||||
protected function getLexer(array $options = []) {
|
||||
|
||||
@@ -4,9 +4,8 @@ namespace PhpParser;
|
||||
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class NameContextTest extends TestCase
|
||||
class NameContextTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTestGetPossibleNames
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace PhpParser\Node;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class IdentifierTest extends TestCase
|
||||
class IdentifierTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testToString() {
|
||||
$identifier = new Identifier('Foo');
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace PhpParser\Node;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class NameTest extends TestCase
|
||||
class NameTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testConstruct() {
|
||||
$name = new Name(['foo', 'bar']);
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace PhpParser\Node\Scalar;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class MagicConstTest extends TestCase
|
||||
class MagicConstTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTestGetName
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace PhpParser\Node\Scalar;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class StringTest extends TestCase
|
||||
class StringTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTestParseEscapeSequences
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ClassConstTest extends TestCase
|
||||
class ClassConstTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideModifiers
|
||||
|
||||
@@ -5,9 +5,8 @@ namespace PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Param;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ClassMethodTest extends TestCase
|
||||
class ClassMethodTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideModifiers
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ClassTest extends TestCase
|
||||
class ClassTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testIsAbstract() {
|
||||
$class = new Class_('Foo', ['type' => Class_::MODIFIER_ABSTRACT]);
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class InterfaceTest extends TestCase
|
||||
class InterfaceTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testGetMethods() {
|
||||
$methods = [
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace PhpParser\Node\Stmt;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PropertyTest extends TestCase
|
||||
class PropertyTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideModifiers
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DummyNode extends NodeAbstract
|
||||
{
|
||||
public $subNode1;
|
||||
@@ -25,7 +23,7 @@ class DummyNode extends NodeAbstract
|
||||
}
|
||||
}
|
||||
|
||||
class NodeAbstractTest extends TestCase
|
||||
class NodeAbstractTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function provideNodes() {
|
||||
$attributes = [
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class NodeDumperTest extends TestCase
|
||||
class NodeDumperTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private function canonicalize($string) {
|
||||
return str_replace("\r\n", "\n", $string);
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
namespace PhpParser;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class NodeFinderTest extends TestCase
|
||||
class NodeFinderTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private function getStmtsAndVars() {
|
||||
$assign = new Expr\Assign(new Expr\Variable('a'), new Expr\BinaryOp\Concat(
|
||||
|
||||
@@ -4,10 +4,8 @@ namespace PhpParser;
|
||||
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\NodeVisitor;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class NodeTraverserTest extends TestCase
|
||||
class NodeTraverserTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testNonModifying() {
|
||||
$str1Node = new String_('Foo');
|
||||
@@ -43,32 +41,32 @@ class NodeTraverserTest extends TestCase
|
||||
|
||||
// replace empty statements with string1 node
|
||||
$visitor1->expects($this->at(0))->method('beforeTraverse')->with([])
|
||||
->will($this->returnValue([$str1Node]));
|
||||
->willReturn([$str1Node]);
|
||||
$visitor2->expects($this->at(0))->method('beforeTraverse')->with([$str1Node]);
|
||||
|
||||
// replace string1 node with print node
|
||||
$visitor1->expects($this->at(1))->method('enterNode')->with($str1Node)
|
||||
->will($this->returnValue($printNode));
|
||||
->willReturn($printNode);
|
||||
$visitor2->expects($this->at(1))->method('enterNode')->with($printNode);
|
||||
|
||||
// replace string1 node with string2 node
|
||||
$visitor1->expects($this->at(2))->method('enterNode')->with($str1Node)
|
||||
->will($this->returnValue($str2Node));
|
||||
->willReturn($str2Node);
|
||||
$visitor2->expects($this->at(2))->method('enterNode')->with($str2Node);
|
||||
|
||||
// replace string2 node with string1 node again
|
||||
$visitor1->expects($this->at(3))->method('leaveNode')->with($str2Node)
|
||||
->will($this->returnValue($str1Node));
|
||||
->willReturn($str1Node);
|
||||
$visitor2->expects($this->at(3))->method('leaveNode')->with($str1Node);
|
||||
|
||||
// replace print node with string1 node again
|
||||
$visitor1->expects($this->at(4))->method('leaveNode')->with($printNode)
|
||||
->will($this->returnValue($str1Node));
|
||||
->willReturn($str1Node);
|
||||
$visitor2->expects($this->at(4))->method('leaveNode')->with($str1Node);
|
||||
|
||||
// replace string1 node with empty statements again
|
||||
$visitor1->expects($this->at(5))->method('afterTraverse')->with([$str1Node])
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
$visitor2->expects($this->at(5))->method('afterTraverse')->with([]);
|
||||
|
||||
$traverser = new NodeTraverser;
|
||||
@@ -87,7 +85,7 @@ class NodeTraverserTest extends TestCase
|
||||
|
||||
// remove the string1 node, leave the string2 node
|
||||
$visitor->expects($this->at(2))->method('leaveNode')->with($str1Node)
|
||||
->will($this->returnValue(NodeTraverser::REMOVE_NODE));
|
||||
->willReturn(NodeTraverser::REMOVE_NODE);
|
||||
|
||||
$traverser = new NodeTraverser;
|
||||
$traverser->addVisitor($visitor);
|
||||
@@ -106,7 +104,7 @@ class NodeTraverserTest extends TestCase
|
||||
|
||||
// replace strMiddle with strR1 and strR2 by merge
|
||||
$visitor->expects($this->at(4))->method('leaveNode')->with($strMiddle)
|
||||
->will($this->returnValue([$strR1, $strR2]));
|
||||
->willReturn([$strR1, $strR2]);
|
||||
|
||||
$traverser = new NodeTraverser;
|
||||
$traverser->addVisitor($visitor);
|
||||
@@ -139,7 +137,7 @@ class NodeTraverserTest extends TestCase
|
||||
$visitor2 = $this->getMockBuilder(NodeVisitor::class)->getMock();
|
||||
|
||||
$visitor1->expects($this->at(1))->method('enterNode')->with($printNode)
|
||||
->will($this->returnValue(NodeTraverser::DONT_TRAVERSE_CHILDREN));
|
||||
->willReturn(NodeTraverser::DONT_TRAVERSE_CHILDREN);
|
||||
$visitor2->expects($this->at(1))->method('enterNode')->with($printNode);
|
||||
|
||||
$visitor1->expects($this->at(2))->method('leaveNode')->with($printNode);
|
||||
@@ -150,7 +148,7 @@ class NodeTraverserTest extends TestCase
|
||||
|
||||
$visitor1->expects($this->at(4))->method('enterNode')->with($mulNode);
|
||||
$visitor2->expects($this->at(4))->method('enterNode')->with($mulNode)
|
||||
->will($this->returnValue(NodeTraverser::DONT_TRAVERSE_CHILDREN));
|
||||
->willReturn(NodeTraverser::DONT_TRAVERSE_CHILDREN);
|
||||
|
||||
$visitor1->expects($this->at(5))->method('leaveNode')->with($mulNode);
|
||||
$visitor2->expects($this->at(5))->method('leaveNode')->with($mulNode);
|
||||
@@ -179,14 +177,14 @@ class NodeTraverserTest extends TestCase
|
||||
$visitor2 = $this->getMockBuilder(NodeVisitor::class)->getMock();
|
||||
|
||||
$visitor1->expects($this->at(1))->method('enterNode')->with($printNode)
|
||||
->will($this->returnValue(NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN));
|
||||
->willReturn(NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN);
|
||||
$visitor1->expects($this->at(2))->method('leaveNode')->with($printNode);
|
||||
|
||||
$visitor1->expects($this->at(3))->method('enterNode')->with($negNode);
|
||||
$visitor2->expects($this->at(1))->method('enterNode')->with($negNode);
|
||||
|
||||
$visitor1->expects($this->at(4))->method('enterNode')->with($mulNode)
|
||||
->will($this->returnValue(NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN));
|
||||
->willReturn(NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN);
|
||||
$visitor1->expects($this->at(5))->method('leaveNode')->with($mulNode)->willReturn($divNode);
|
||||
|
||||
$visitor1->expects($this->at(6))->method('leaveNode')->with($negNode);
|
||||
@@ -212,7 +210,7 @@ class NodeTraverserTest extends TestCase
|
||||
// From enterNode() with array parent
|
||||
$visitor = $this->getMockBuilder(NodeVisitor::class)->getMock();
|
||||
$visitor->expects($this->at(1))->method('enterNode')->with($mulNode)
|
||||
->will($this->returnValue(NodeTraverser::STOP_TRAVERSAL));
|
||||
->willReturn(NodeTraverser::STOP_TRAVERSAL);
|
||||
$visitor->expects($this->at(2))->method('afterTraverse');
|
||||
$traverser = new NodeTraverser;
|
||||
$traverser->addVisitor($visitor);
|
||||
@@ -221,7 +219,7 @@ class NodeTraverserTest extends TestCase
|
||||
// From enterNode with Node parent
|
||||
$visitor = $this->getMockBuilder(NodeVisitor::class)->getMock();
|
||||
$visitor->expects($this->at(2))->method('enterNode')->with($varNode1)
|
||||
->will($this->returnValue(NodeTraverser::STOP_TRAVERSAL));
|
||||
->willReturn(NodeTraverser::STOP_TRAVERSAL);
|
||||
$visitor->expects($this->at(3))->method('afterTraverse');
|
||||
$traverser = new NodeTraverser;
|
||||
$traverser->addVisitor($visitor);
|
||||
@@ -230,7 +228,7 @@ class NodeTraverserTest extends TestCase
|
||||
// From leaveNode with Node parent
|
||||
$visitor = $this->getMockBuilder(NodeVisitor::class)->getMock();
|
||||
$visitor->expects($this->at(3))->method('leaveNode')->with($varNode1)
|
||||
->will($this->returnValue(NodeTraverser::STOP_TRAVERSAL));
|
||||
->willReturn(NodeTraverser::STOP_TRAVERSAL);
|
||||
$visitor->expects($this->at(4))->method('afterTraverse');
|
||||
$traverser = new NodeTraverser;
|
||||
$traverser->addVisitor($visitor);
|
||||
@@ -239,7 +237,7 @@ class NodeTraverserTest extends TestCase
|
||||
// From leaveNode with array parent
|
||||
$visitor = $this->getMockBuilder(NodeVisitor::class)->getMock();
|
||||
$visitor->expects($this->at(6))->method('leaveNode')->with($mulNode)
|
||||
->will($this->returnValue(NodeTraverser::STOP_TRAVERSAL));
|
||||
->willReturn(NodeTraverser::STOP_TRAVERSAL);
|
||||
$visitor->expects($this->at(7))->method('afterTraverse');
|
||||
$traverser = new NodeTraverser;
|
||||
$traverser->addVisitor($visitor);
|
||||
@@ -248,9 +246,9 @@ class NodeTraverserTest extends TestCase
|
||||
// Check that pending array modifications are still carried out
|
||||
$visitor = $this->getMockBuilder(NodeVisitor::class)->getMock();
|
||||
$visitor->expects($this->at(6))->method('leaveNode')->with($mulNode)
|
||||
->will($this->returnValue(NodeTraverser::REMOVE_NODE));
|
||||
->willReturn(NodeTraverser::REMOVE_NODE);
|
||||
$visitor->expects($this->at(7))->method('enterNode')->with($printNode)
|
||||
->will($this->returnValue(NodeTraverser::STOP_TRAVERSAL));
|
||||
->willReturn(NodeTraverser::STOP_TRAVERSAL);
|
||||
$visitor->expects($this->at(8))->method('afterTraverse');
|
||||
$traverser = new NodeTraverser;
|
||||
$traverser->addVisitor($visitor);
|
||||
|
||||
@@ -5,9 +5,8 @@ namespace PhpParser\NodeVisitor;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\NodeTraverser;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FindingVisitorTest extends TestCase
|
||||
class FindingVisitorTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testFindVariables() {
|
||||
$traverser = new NodeTraverser();
|
||||
|
||||
@@ -5,9 +5,8 @@ namespace PhpParser\NodeVisitor;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\NodeTraverser;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FirstFindingVisitorTest extends TestCase
|
||||
class FirstFindingVisitorTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testFindFirstVariable() {
|
||||
$traverser = new NodeTraverser();
|
||||
|
||||
@@ -7,16 +7,15 @@ use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class NameResolverTest extends TestCase
|
||||
class NameResolverTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private function canonicalize($string) {
|
||||
return str_replace("\r\n", "\n", $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PhpParser\NodeVisitor\NameResolver
|
||||
* @covers \PhpParser\NodeVisitor\NameResolver
|
||||
*/
|
||||
public function testResolveNames() {
|
||||
$code = <<<'EOC'
|
||||
@@ -95,6 +94,13 @@ namespace Baz {
|
||||
C;
|
||||
E;
|
||||
K;
|
||||
|
||||
class ClassWithTypeProperties
|
||||
{
|
||||
public float $php = 7.4;
|
||||
public ?Foo $person;
|
||||
protected static ?bool $probability;
|
||||
}
|
||||
}
|
||||
EOC;
|
||||
$expectedCode = <<<'EOC'
|
||||
@@ -163,6 +169,12 @@ namespace Baz {
|
||||
\Y\T\B\C;
|
||||
\Y\T\D\E;
|
||||
\Z\T\K;
|
||||
class ClassWithTypeProperties
|
||||
{
|
||||
public float $php = 7.4;
|
||||
public ?\Baz\Foo $person;
|
||||
protected static ?bool $probability;
|
||||
}
|
||||
}
|
||||
EOC;
|
||||
|
||||
@@ -181,7 +193,7 @@ EOC;
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers PhpParser\NodeVisitor\NameResolver
|
||||
* @covers \PhpParser\NodeVisitor\NameResolver
|
||||
*/
|
||||
public function testResolveLocations() {
|
||||
$code = <<<'EOC'
|
||||
|
||||
@@ -9,8 +9,6 @@ use PhpParser\Node\Scalar\LNumber;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\ParserTest;
|
||||
|
||||
require_once __DIR__ . '/../ParserTest.php';
|
||||
|
||||
class MultipleTest extends ParserTest
|
||||
{
|
||||
// This provider is for the generic parser tests, just pick an arbitrary order here
|
||||
@@ -84,11 +82,11 @@ class MultipleTest extends ParserTest
|
||||
|
||||
$parserA = $this->getMockBuilder(\PhpParser\Parser::class)->getMock();
|
||||
$parserA->expects($this->at(0))
|
||||
->method('parse')->will($this->throwException(new Error('FAIL A')));
|
||||
->method('parse')->willThrowException(new Error('FAIL A'));
|
||||
|
||||
$parserB = $this->getMockBuilder(\PhpParser\Parser::class)->getMock();
|
||||
$parserB->expects($this->at(0))
|
||||
->method('parse')->will($this->throwException(new Error('FAIL B')));
|
||||
->method('parse')->willThrowException(new Error('FAIL B'));
|
||||
|
||||
$parser = new Multiple([$parserA, $parserB]);
|
||||
$parser->parse('dummy');
|
||||
|
||||
@@ -5,8 +5,6 @@ namespace PhpParser\Parser;
|
||||
use PhpParser\Lexer;
|
||||
use PhpParser\ParserTest;
|
||||
|
||||
require_once __DIR__ . '/../ParserTest.php';
|
||||
|
||||
class Php5Test extends ParserTest
|
||||
{
|
||||
protected function getParser(Lexer $lexer) {
|
||||
|
||||
@@ -5,8 +5,6 @@ namespace PhpParser\Parser;
|
||||
use PhpParser\Lexer;
|
||||
use PhpParser\ParserTest;
|
||||
|
||||
require_once __DIR__ . '/../ParserTest.php';
|
||||
|
||||
class Php7Test extends ParserTest
|
||||
{
|
||||
protected function getParser(Lexer $lexer) {
|
||||
|
||||
@@ -4,9 +4,8 @@ namespace PhpParser;
|
||||
|
||||
/* This test is very weak, because PHPUnit's assertEquals assertion is way too slow dealing with the
|
||||
* large objects involved here. So we just do some basic instanceof tests instead. */
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ParserFactoryTest extends TestCase
|
||||
class ParserFactoryTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/** @dataProvider provideTestCreate */
|
||||
public function testCreate($kind, $lexer, $expected) {
|
||||
|
||||
@@ -6,9 +6,8 @@ use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Scalar;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class ParserTest extends TestCase
|
||||
abstract class ParserTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/** @returns Parser */
|
||||
abstract protected function getParser(Lexer $lexer);
|
||||
@@ -167,6 +166,10 @@ EOC;
|
||||
["namespace Foo;", ['kind' => Stmt\Namespace_::KIND_SEMICOLON]],
|
||||
["namespace Foo {}", ['kind' => Stmt\Namespace_::KIND_BRACED]],
|
||||
["namespace {}", ['kind' => Stmt\Namespace_::KIND_BRACED]],
|
||||
["(float) 5.0", ['kind' => Expr\Cast\Double::KIND_FLOAT]],
|
||||
["(double) 5.0", ['kind' => Expr\Cast\Double::KIND_DOUBLE]],
|
||||
["(real) 5.0", ['kind' => Expr\Cast\Double::KIND_REAL]],
|
||||
[" ( REAL ) 5.0", ['kind' => Expr\Cast\Double::KIND_REAL]],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,6 @@ use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\PrettyPrinter\Standard;
|
||||
|
||||
require_once __DIR__ . '/CodeTestAbstract.php';
|
||||
|
||||
class PrettyPrinterTest extends CodeTestAbstract
|
||||
{
|
||||
protected function doTestPrettyPrintMethod($method, $name, $code, $expected, $modeLine) {
|
||||
|
||||
@@ -13,4 +13,16 @@ $new->args[] = new Expr\Variable('y');
|
||||
<?php
|
||||
new class
|
||||
($x, $y)
|
||||
{ };
|
||||
{ };
|
||||
-----
|
||||
<?php
|
||||
new class
|
||||
{};
|
||||
-----
|
||||
// Ignore name assigned to anon class
|
||||
$new = $stmts[0]->expr;
|
||||
$new->class->name = new Node\Identifier('Anon1');
|
||||
-----
|
||||
<?php
|
||||
new class
|
||||
{};
|
||||
@@ -18,6 +18,7 @@ array(
|
||||
stmts: array(
|
||||
0: Stmt_Property(
|
||||
flags: MODIFIER_PROTECTED (2)
|
||||
type: null
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: VarLikeIdentifier(
|
||||
|
||||
@@ -756,6 +756,7 @@ array(
|
||||
)
|
||||
3: Stmt_Property(
|
||||
flags: MODIFIER_PUBLIC (1)
|
||||
type: null
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: VarLikeIdentifier(
|
||||
@@ -975,6 +976,7 @@ array(
|
||||
stmts: array(
|
||||
0: Stmt_Property(
|
||||
flags: MODIFIER_PUBLIC (1)
|
||||
type: null
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: VarLikeIdentifier(
|
||||
|
||||
@@ -17,6 +17,7 @@ $a += $b;
|
||||
$a <<= $b;
|
||||
$a >>= $b;
|
||||
$a **= $b;
|
||||
$a ??= $b;
|
||||
|
||||
// chained assign
|
||||
$a = $b *= $c **= $d;
|
||||
@@ -185,6 +186,16 @@ array(
|
||||
)
|
||||
)
|
||||
13: Stmt_Expression(
|
||||
expr: Expr_AssignOp_Coalesce(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_Variable(
|
||||
name: b
|
||||
)
|
||||
)
|
||||
)
|
||||
14: Stmt_Expression(
|
||||
expr: Expr_Assign(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
@@ -213,7 +224,7 @@ array(
|
||||
0: // chained assign
|
||||
)
|
||||
)
|
||||
14: Stmt_Expression(
|
||||
15: Stmt_Expression(
|
||||
expr: Expr_AssignRef(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
@@ -232,7 +243,7 @@ array(
|
||||
0: // by ref assign
|
||||
)
|
||||
)
|
||||
15: Stmt_Expression(
|
||||
16: Stmt_Expression(
|
||||
expr: Expr_Assign(
|
||||
var: Expr_List(
|
||||
items: array(
|
||||
@@ -259,7 +270,7 @@ array(
|
||||
0: // list() assign
|
||||
)
|
||||
)
|
||||
16: Stmt_Expression(
|
||||
17: Stmt_Expression(
|
||||
expr: Expr_Assign(
|
||||
var: Expr_List(
|
||||
items: array(
|
||||
@@ -285,7 +296,7 @@ array(
|
||||
)
|
||||
)
|
||||
)
|
||||
17: Stmt_Expression(
|
||||
18: Stmt_Expression(
|
||||
expr: Expr_Assign(
|
||||
var: Expr_List(
|
||||
items: array(
|
||||
@@ -326,7 +337,7 @@ array(
|
||||
)
|
||||
)
|
||||
)
|
||||
18: Stmt_Expression(
|
||||
19: Stmt_Expression(
|
||||
expr: Expr_PreInc(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
@@ -339,21 +350,21 @@ array(
|
||||
0: // inc/dec
|
||||
)
|
||||
)
|
||||
19: Stmt_Expression(
|
||||
20: Stmt_Expression(
|
||||
expr: Expr_PostInc(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
)
|
||||
20: Stmt_Expression(
|
||||
21: Stmt_Expression(
|
||||
expr: Expr_PreDec(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
)
|
||||
21: Stmt_Expression(
|
||||
22: Stmt_Expression(
|
||||
expr: Expr_PostDec(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
|
||||
@@ -112,6 +112,7 @@ array(
|
||||
)
|
||||
4: Stmt_Property(
|
||||
flags: MODIFIER_PUBLIC (1)
|
||||
type: null
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: VarLikeIdentifier(
|
||||
@@ -123,6 +124,7 @@ array(
|
||||
)
|
||||
5: Stmt_Property(
|
||||
flags: MODIFIER_PUBLIC (1)
|
||||
type: null
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: VarLikeIdentifier(
|
||||
|
||||
@@ -89,6 +89,7 @@ array(
|
||||
stmts: array(
|
||||
0: Stmt_Property(
|
||||
flags: MODIFIER_PUBLIC (1)
|
||||
type: null
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: VarLikeIdentifier(
|
||||
|
||||
@@ -24,6 +24,7 @@ array(
|
||||
stmts: array(
|
||||
0: Stmt_Property(
|
||||
flags: 0
|
||||
type: null
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: VarLikeIdentifier(
|
||||
@@ -35,6 +36,7 @@ array(
|
||||
)
|
||||
1: Stmt_Property(
|
||||
flags: MODIFIER_STATIC (8)
|
||||
type: null
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: VarLikeIdentifier(
|
||||
|
||||
@@ -15,6 +15,7 @@ array(
|
||||
stmts: array(
|
||||
0: Stmt_Property(
|
||||
flags: MODIFIER_PUBLIC (1)
|
||||
type: null
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: VarLikeIdentifier(
|
||||
@@ -43,6 +44,7 @@ array(
|
||||
stmts: array(
|
||||
0: Stmt_Property(
|
||||
flags: MODIFIER_PUBLIC | MODIFIER_PROTECTED (3)
|
||||
type: null
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: VarLikeIdentifier(
|
||||
@@ -99,6 +101,7 @@ array(
|
||||
stmts: array(
|
||||
0: Stmt_Property(
|
||||
flags: MODIFIER_STATIC (8)
|
||||
type: null
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: VarLikeIdentifier(
|
||||
@@ -207,6 +210,7 @@ array(
|
||||
stmts: array(
|
||||
0: Stmt_Property(
|
||||
flags: MODIFIER_ABSTRACT (16)
|
||||
type: null
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: VarLikeIdentifier(
|
||||
@@ -235,6 +239,7 @@ array(
|
||||
stmts: array(
|
||||
0: Stmt_Property(
|
||||
flags: MODIFIER_FINAL (32)
|
||||
type: null
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: VarLikeIdentifier(
|
||||
|
||||
@@ -20,6 +20,7 @@ array(
|
||||
stmts: array(
|
||||
0: Stmt_Property(
|
||||
flags: 0
|
||||
type: null
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: VarLikeIdentifier(
|
||||
|
||||
@@ -63,6 +63,7 @@ array(
|
||||
)
|
||||
1: Stmt_Property(
|
||||
flags: MODIFIER_PUBLIC (1)
|
||||
type: null
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: VarLikeIdentifier(
|
||||
@@ -84,6 +85,7 @@ array(
|
||||
)
|
||||
2: Stmt_Property(
|
||||
flags: MODIFIER_PROTECTED (2)
|
||||
type: null
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: VarLikeIdentifier(
|
||||
@@ -95,6 +97,7 @@ array(
|
||||
)
|
||||
3: Stmt_Property(
|
||||
flags: MODIFIER_PRIVATE (4)
|
||||
type: null
|
||||
props: array(
|
||||
0: Stmt_PropertyProperty(
|
||||
name: VarLikeIdentifier(
|
||||
|
||||
@@ -19,6 +19,9 @@ $a--;
|
||||
(float) $a;
|
||||
(double) $a;
|
||||
(real) $a;
|
||||
( float) $a;
|
||||
(double ) $a;
|
||||
( REAL ) $a;
|
||||
(string) $a;
|
||||
(binary) $a;
|
||||
(array) $a;
|
||||
@@ -53,9 +56,9 @@ $a || $b;
|
||||
$a ? $b : $c;
|
||||
$a ?: $c;
|
||||
$a ?? $c;
|
||||
|
||||
$a = $b;
|
||||
$a **= $b;
|
||||
$a ??= $c;
|
||||
$a *= $b;
|
||||
$a /= $b;
|
||||
$a %= $b;
|
||||
@@ -87,9 +90,12 @@ $a--;
|
||||
+$a;
|
||||
(int) $a;
|
||||
(int) $a;
|
||||
(float) $a;
|
||||
(double) $a;
|
||||
(real) $a;
|
||||
(float) $a;
|
||||
(double) $a;
|
||||
(double) $a;
|
||||
(real) $a;
|
||||
(string) $a;
|
||||
(string) $a;
|
||||
(array) $a;
|
||||
@@ -125,6 +131,7 @@ $a ?: $c;
|
||||
$a ?? $c;
|
||||
$a = $b;
|
||||
$a **= $b;
|
||||
$a ??= $c;
|
||||
$a *= $b;
|
||||
$a /= $b;
|
||||
$a %= $b;
|
||||
|
||||
0
vendor/nikic/php-parser/test_old/run-php-src.sh
vendored
Normal file → Executable file
0
vendor/nikic/php-parser/test_old/run-php-src.sh
vendored
Normal file → Executable file
Reference in New Issue
Block a user