mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-06-21 07:21:24 +02:00
Compare commits
35 Commits
v4.0.0alph
...
v4.0.0beta
Author | SHA1 | Date | |
---|---|---|---|
c18bb27723 | |||
dd0adcc96c | |||
e4505de346 | |||
a513ccabb7 | |||
d817818b5d | |||
6a273c9fbd | |||
c2d3ecad35 | |||
e57b3a0978 | |||
1cdb280a30 | |||
d01fafcb40 | |||
67df02c844 | |||
b85b6b3519 | |||
94c715d97e | |||
4dacbb8d39 | |||
aa685e711a | |||
edafeb85c4 | |||
68d07c4662 | |||
8fae99aafe | |||
c7ada124d0 | |||
f6617e6d25 | |||
2499534729 | |||
e0a2043089 | |||
e6e52abae7 | |||
7f72c84122 | |||
fc8ac71e76 | |||
a8968caa5b | |||
5285df8f22 | |||
4366aa2fb0 | |||
bf7d811cda | |||
248b29ecf6 | |||
bcb45d31eb | |||
3bc31488ce | |||
92b39e3d1f | |||
1c7fd314d1 | |||
fb8175567e |
35
CHANGELOG.md
35
CHANGELOG.md
@ -3,15 +3,31 @@ Version 4.0.0-dev
|
||||
|
||||
Nothing yet.
|
||||
|
||||
Version 4.0.0-beta1 (2018-01-27)
|
||||
--------------------------------
|
||||
|
||||
### Fixed
|
||||
|
||||
* In formatting-preserving pretty printer: Fixed indentation when inserting into lists. (#466)
|
||||
|
||||
### Added
|
||||
|
||||
* In formatting-preserving pretty printer: Improved formatting of elements inserted into multi-line
|
||||
arrays.
|
||||
|
||||
### Removed
|
||||
|
||||
* The `Autoloader` class has been removed. It is now required to use the Composer autoloader.
|
||||
|
||||
Version 4.0.0-alpha3 (2017-12-26)
|
||||
---------------------------------
|
||||
|
||||
### Fixed
|
||||
|
||||
* In the formatting-preserving pretty printer:
|
||||
* Fixed comment indentation.
|
||||
* Fixed handling of inline HTML in the fallback case.
|
||||
* Fixed insertion into list nodes that require creation of a code block.
|
||||
* Fixed comment indentation.
|
||||
* Fixed handling of inline HTML in the fallback case.
|
||||
* Fixed insertion into list nodes that require creation of a code block.
|
||||
|
||||
### Added
|
||||
|
||||
@ -92,11 +108,18 @@ Version 4.0.0-alpha1 (2017-10-18)
|
||||
* The `BuilderAbstract` class has been removed. It's functionality is moved into `BuilderHelpers`.
|
||||
However, this is an internal class and should not be used directly.
|
||||
|
||||
Version 3.1.4-dev
|
||||
Version 3.1.5-dev
|
||||
-----------------
|
||||
|
||||
Nothing yet.
|
||||
|
||||
Version 3.1.4 (2018-01-25)
|
||||
--------------------------
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fixed pretty printing of `-(-$x)` and `+(+$x)`. (#459)
|
||||
|
||||
Version 3.1.3 (2017-12-26)
|
||||
--------------------------
|
||||
|
||||
@ -134,7 +157,7 @@ Version 3.1.0 (2017-07-28)
|
||||
* [PHP 7.2] Added support for trailing comma in group use statements.
|
||||
* [PHP 7.2] Added support for `object` type. This means `object` types will now be represented as a
|
||||
builtin type (a simple `"object"` string), rather than a class `Name`.
|
||||
|
||||
|
||||
### Fixed
|
||||
|
||||
* Floating-point numbers are now printed correctly if the LC_NUMERIC locale uses a comma as decimal
|
||||
@ -254,7 +277,7 @@ This release primarily improves our support for error recovery.
|
||||
`NameResolver::__construct()`.
|
||||
* The `NameResolver` now adds a `namespacedName` attribute on name nodes that cannot be statically
|
||||
resolved (unqualified unaliased function or constant names in namespaces).
|
||||
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fixed attribute assignment for `GroupUse` prefix and variables in interpolated strings.
|
||||
|
4
LICENSE
4
LICENSE
@ -1,4 +1,4 @@
|
||||
Copyright (c) 2011 by Nikita Popov.
|
||||
Copyright (c) 2011-2018 by Nikita Popov.
|
||||
|
||||
Some rights reserved.
|
||||
|
||||
@ -28,4 +28,4 @@ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
11
README.md
11
README.md
@ -8,7 +8,7 @@ manipulation.
|
||||
|
||||
[**Documentation for version 3.x**][doc_3_x] (stable; for running on PHP >= 5.5; for parsing PHP 5.2 to PHP 7.2).
|
||||
|
||||
[Documentation for version 4.x][doc_master] (development; for running on PHP >= 7.0; for parsing PHP 5.2 to PHP 7.2).
|
||||
[Documentation for version 4.x][doc_master] (beta; for running on PHP >= 7.0; for parsing PHP 5.2 to PHP 7.2).
|
||||
|
||||
Features
|
||||
--------
|
||||
@ -184,8 +184,6 @@ Documentation
|
||||
1. [Introduction](doc/0_Introduction.markdown)
|
||||
2. [Usage of basic components](doc/2_Usage_of_basic_components.markdown)
|
||||
3. [Other node tree representations](doc/3_Other_node_tree_representations.markdown)
|
||||
4. [Code generation](doc/4_Code_generation.markdown)
|
||||
5. [Frequently asked questions](doc/5_FAQ.markdown)
|
||||
|
||||
Component documentation:
|
||||
|
||||
@ -196,6 +194,8 @@ Component documentation:
|
||||
* Converting AST back to PHP code
|
||||
* Customizing formatting
|
||||
* Formatting-preserving code transformations
|
||||
* [AST builders](component/AST_builders.markdown)
|
||||
* Fluent builders for AST nodes
|
||||
* [Lexer](doc/component/Lexer.markdown)
|
||||
* Lexer options
|
||||
* Token and file positions for nodes
|
||||
@ -203,10 +203,15 @@ Component documentation:
|
||||
* [Error handling](doc/component/Error_handling.markdown)
|
||||
* Column information for errors
|
||||
* Error recovery (parsing of syntactically incorrect code)
|
||||
* [Constant expression evaluation](component/Constant_expression_evaluation.markdown)
|
||||
* Evaluating constant/property/etc initializers
|
||||
* Handling errors and unsupported expressions
|
||||
* [Performance](doc/component/Performance.markdown)
|
||||
* Disabling XDebug
|
||||
* Reusing objects
|
||||
* Garbage collection impact
|
||||
* [Frequently asked questions](component/FAQ.markdown)
|
||||
* Parent and sibling references
|
||||
|
||||
[doc_3_x]: https://github.com/nikic/PHP-Parser/tree/3.x/doc
|
||||
[doc_master]: https://github.com/nikic/PHP-Parser/tree/master/doc
|
||||
|
@ -52,7 +52,7 @@ Because HHVM does not support PHP 7, HHVM is no longer supported.
|
||||
* The `alias` subnode of `UseUse` is now `null` if no explicit alias is given. As such,
|
||||
`use Foo\Bar` and `use Foo\Bar as Bar` are now represented differently. The `getAlias()` method
|
||||
can be used to get the effective alias, even if it is not explicitly given.
|
||||
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
* The indentation handling in the pretty printer has been changed (this is only relevant if you
|
||||
@ -73,4 +73,5 @@ Because HHVM does not support PHP 7, HHVM is no longer supported.
|
||||
* The XML serializer has been removed. As such, the classes `Serializer\XML`, and
|
||||
`Unserializer\XML`, as well as the interfaces `Serializer` and `Unserializer` no longer exist.
|
||||
* The `BuilderAbstract` class has been removed. It's functionality is moved into `BuilderHelpers`.
|
||||
However, this is an internal class and should not be used directly.
|
||||
However, this is an internal class and should not be used directly.
|
||||
* The `Autoloader` class has been removed in favor of relying on the Composer autoloader.
|
@ -1,7 +1,7 @@
|
||||
Introduction
|
||||
============
|
||||
|
||||
This project is a PHP 5.2 to PHP 7.1 parser **written in PHP itself**.
|
||||
This project is a PHP 5.2 to PHP 7.2 parser **written in PHP itself**.
|
||||
|
||||
What is this for?
|
||||
-----------------
|
||||
@ -26,11 +26,11 @@ programmatic PHP code analysis are incidentally PHP developers, not C developers
|
||||
What can it parse?
|
||||
------------------
|
||||
|
||||
The parser supports parsing PHP 5.2-5.6 and PHP 7.
|
||||
The parser supports parsing PHP 5.2-7.2.
|
||||
|
||||
As the parser is based on the tokens returned by `token_get_all` (which is only able to lex the PHP
|
||||
version it runs on), additionally a wrapper for emulating tokens from newer versions is provided.
|
||||
This allows to parse PHP 7.1 source code running on PHP 5.5, for example. This emulation is somewhat
|
||||
This allows to parse PHP 7.2 source code running on PHP 5.5, for example. This emulation is somewhat
|
||||
hacky and not perfect, but it should work well on any sane code.
|
||||
|
||||
What output does it produce?
|
||||
|
@ -7,12 +7,10 @@ Guide
|
||||
1. [Introduction](0_Introduction.markdown)
|
||||
2. [Usage of basic components](2_Usage_of_basic_components.markdown)
|
||||
3. [Other node tree representations](3_Other_node_tree_representations.markdown)
|
||||
4. [Code generation](4_Code_generation.markdown)
|
||||
5. [Frequently asked questions](5_FAQ.markdown)
|
||||
|
||||
|
||||
Component documentation
|
||||
-----------------------
|
||||
|
||||
|
||||
* [Name resolution](component/Name_resolution.markdown)
|
||||
* Name resolver options
|
||||
* Name resolution context
|
||||
@ -20,6 +18,8 @@ Component documentation
|
||||
* Converting AST back to PHP code
|
||||
* Customizing formatting
|
||||
* Formatting-preserving code transformations
|
||||
* [AST builders](component/AST_builders.markdown)
|
||||
* Fluent builders for AST nodes
|
||||
* [Lexer](component/Lexer.markdown)
|
||||
* Lexer options
|
||||
* Token and file positions for nodes
|
||||
@ -27,7 +27,12 @@ Component documentation
|
||||
* [Error handling](component/Error_handling.markdown)
|
||||
* Column information for errors
|
||||
* Error recovery (parsing of syntactically incorrect code)
|
||||
* [Constant expression evaluation](component/Constant_expression_evaluation.markdown)
|
||||
* Evaluating constant/property/etc initializers
|
||||
* Handling errors and unsupported expressions
|
||||
* [Performance](component/Performance.markdown)
|
||||
* Disabling XDebug
|
||||
* Reusing objects
|
||||
* Garbage collection impact
|
||||
* [Frequently asked questions](component/FAQ.markdown)
|
||||
* Parent and sibling references
|
||||
|
@ -1,9 +1,17 @@
|
||||
Code generation
|
||||
===============
|
||||
AST builders
|
||||
============
|
||||
|
||||
It is also possible to generate code using the parser, by first creating an Abstract Syntax Tree and then using the
|
||||
pretty printer to convert it to PHP code. To simplify code generation, the project comes with builders which allow
|
||||
creating node trees using a fluid interface, instead of instantiating all nodes manually. Builders are available for
|
||||
When PHP-Parser is used to generate (or modify) code, by first creating an Abstract Syntax Tree and
|
||||
then using the [pretty printer](Pretty_printing.markdown) to convert it to PHP code, it can often
|
||||
be tedious to manually construct AST nodes. The project provides a number of utilities to simplify
|
||||
the construction of common AST nodes.
|
||||
|
||||
Fluent builders
|
||||
---------------
|
||||
|
||||
The library comes with a number of builders, which allow creating node trees using a fluent
|
||||
interface. Builders are created using the `BuilderFactory` and the final constructed node is
|
||||
accessed through `getNode()`. Fluent builders are available for
|
||||
the following syntactic elements:
|
||||
|
||||
* namespaces and use statements
|
||||
@ -82,3 +90,17 @@ abstract class SomeOtherClass extends SomeClass implements A\Few, \Interfaces
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Additional helper methods
|
||||
-------------------------
|
||||
|
||||
The `BuilderFactory` also provides a number of additional helper methods, which directly return
|
||||
nodes. The following methods are currently available:
|
||||
|
||||
* `val($value)`: Creates an AST node for a literal value like `42` or `[1, 2, 3]`.
|
||||
* `args(array $args)`: Creates an array of function/method arguments, including the required `Arg`
|
||||
wrappers. Also converts literals to AST nodes.
|
||||
* `concat(...$exprs)`: Create a tree of `BinaryOp\Concat` nodes for the given expressions.
|
||||
|
||||
These methods may be expanded on an as-needed basis. Please open an issue or PR if a common
|
||||
operation is missing.
|
115
doc/component/Constant_expression_evaluation.markdown
Normal file
115
doc/component/Constant_expression_evaluation.markdown
Normal file
@ -0,0 +1,115 @@
|
||||
Constant expression evaluation
|
||||
==============================
|
||||
|
||||
Initializers for constants, properties, parameters, etc. have limited support for expressions. For
|
||||
example:
|
||||
|
||||
```php
|
||||
<?php
|
||||
class Test {
|
||||
const SECONDS_IN_HOUR = 60 * 60;
|
||||
const SECONDS_IN_DAY = 24 * self::SECONDS_IN_HOUR;
|
||||
}
|
||||
```
|
||||
|
||||
PHP-Parser supports evaluation of such constant expressions through the `ConstExprEvaluator` class:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use PhpParser\{ConstExprEvaluator, ConstExprEvaluationException};
|
||||
|
||||
$evalutator = new ConstExprEvaluator();
|
||||
try {
|
||||
$value = $evalutator->evaluateSilently($someExpr);
|
||||
} catch (ConstExprEvaluationException $e) {
|
||||
// Either the expression contains unsupported expression types,
|
||||
// or an error occurred during evaluation
|
||||
}
|
||||
```
|
||||
|
||||
Error handling
|
||||
--------------
|
||||
|
||||
The constant evaluator provides two methods, `evaluateDirectly()` and `evaluateSilently()`, which
|
||||
differ in error behavior. `evaluateDirectly()` will evaluate the expression as PHP would, including
|
||||
any generated warnings or Errors. `evaluateSilently()` will instead convert warnings and Errors into
|
||||
a `ConstExprEvaluationException`. For example:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use PhpParser\{ConstExprEvaluator, ConstExprEvaluationException};
|
||||
use PhpParser\Node\{Expr, Scalar};
|
||||
|
||||
$evaluator = new ConstExprEvaluator();
|
||||
|
||||
// 10 / 0
|
||||
$expr = new Expr\BinaryOp\Div(new Scalar\LNumber(10), new Scalar\LNumber(0));
|
||||
|
||||
var_dump($evaluator->evaluateDirectly($expr)); // float(INF)
|
||||
// Warning: Division by zero
|
||||
|
||||
try {
|
||||
$evaluator->evaluateSilently($expr);
|
||||
} catch (ConstExprEvaluationException $e) {
|
||||
var_dump($e->getPrevious()->getMessage()); // Division by zero
|
||||
}
|
||||
```
|
||||
|
||||
For the purposes of static analysis, you will likely want to use `evaluateSilently()` and leave
|
||||
erroring expressions unevaluated.
|
||||
|
||||
Unsupported expressions and evaluator fallback
|
||||
----------------------------------------------
|
||||
|
||||
The constant expression evaluator supports all expression types that are permitted in constant
|
||||
expressions, apart from the following:
|
||||
|
||||
* `Scalar\MagicConst\*`
|
||||
* `Expr\ConstFetch` (only null/false/true are handled)
|
||||
* `Expr\ClassConstFetch`
|
||||
|
||||
Handling these expression types requires non-local information, such as which global constants are
|
||||
defined. By default, the evaluator will throw a `ConstExprEvaluationException` when it encounters
|
||||
an unsupported expression type.
|
||||
|
||||
It is possible to override this behavior and support resolution for these expression types by
|
||||
specifying an evaluation fallback function:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use PhpParser\{ConstExprEvaluator, ConstExprEvaluationException};
|
||||
use PhpParser\Node\Expr;
|
||||
|
||||
$evalutator = new ConstExprEvaluator(function(Expr $expr) {
|
||||
if ($expr instanceof Expr\ConstFetch) {
|
||||
return fetchConstantSomehow($expr);
|
||||
}
|
||||
if ($expr instanceof Expr\ClassConstFetch) {
|
||||
return fetchClassConstantSomehow($expr);
|
||||
}
|
||||
// etc.
|
||||
throw new ConstExprEvaluationException(
|
||||
"Expression of type {$expr->getType()} cannot be evaluated");
|
||||
});
|
||||
|
||||
try {
|
||||
$evalutator->evaluateSilently($someExpr);
|
||||
} catch (ConstExprEvaluationException $e) {
|
||||
// Handle exception
|
||||
}
|
||||
```
|
||||
|
||||
Implementers are advised to ensure that evaluation of indirect constant references cannot lead to
|
||||
infinite recursion. For example, the following code could lead to infinite recursion if constant
|
||||
lookup is implemented naively.
|
||||
|
||||
```php
|
||||
<?php
|
||||
class Test {
|
||||
const A = self::B;
|
||||
const B = self::A;
|
||||
}
|
||||
```
|
@ -50,14 +50,13 @@ Formatting-preserving pretty printing
|
||||
|
||||
For automated code refactoring, migration and similar, you will usually only want to modify a small
|
||||
portion of the code and leave the remainder alone. The basic pretty printer is not suitable for
|
||||
this, because it will also reformat parts of the code, which have not been modified.
|
||||
this, because it will also reformat parts of the code which have not been modified.
|
||||
|
||||
Since PHP-Parser 4.0 an experimental formatting-preserving pretty-printing mode is available, which
|
||||
attempts to preserve the formatting of code, those AST nodes have not changed, and only reformat
|
||||
code which has been modified or newly inserted.
|
||||
|
||||
Use of the formatting-preservation functionality currently requires some additional preparatory
|
||||
steps:
|
||||
Use of the formatting-preservation functionality requires some additional preparatory steps:
|
||||
|
||||
```php
|
||||
use PhpParser\{Lexer, NodeTraverser, NodeVisitor, Parser, PrettyPrinter};
|
||||
@ -86,6 +85,11 @@ $newStmts = $traverser->traverse($oldStmts);
|
||||
$newCode = $printer->printFormatPreserving($newStmts, $oldStmts, $oldTokens);
|
||||
```
|
||||
|
||||
If you make use of the name resolution functionality, you will likely want to disable the
|
||||
`replaceNames` option. This will add resolved names as attributes, instead of directlying modifying
|
||||
the AST and causing spurious changes to the pretty printed code. For more information, see the
|
||||
[name resolution documentation](Name_resolution.markdown).
|
||||
|
||||
This functionality is experimental and not yet fully implemented. It should not provide incorrect
|
||||
code, but it may sometimes reformat more code than necessary. Open issues are tracked in
|
||||
[issue #344](https://github.com/nikic/PHP-Parser/issues/344). If you encounter problems while using
|
||||
|
@ -937,7 +937,7 @@ list_expr_element:
|
||||
|
||||
array_pair_list:
|
||||
inner_array_pair_list
|
||||
{ $$ = $1; $end = count($$)-1; if ($$[$end] === null) unset($$[$end]); }
|
||||
{ $$ = $1; $end = count($$)-1; if ($$[$end] === null) array_pop($$); }
|
||||
;
|
||||
|
||||
inner_array_pair_list:
|
||||
|
@ -1,40 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class Autoloader
|
||||
{
|
||||
/** @var bool Whether the autoloader has been registered. */
|
||||
private static $registered = false;
|
||||
|
||||
/**
|
||||
* Registers PhpParser\Autoloader as an SPL autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader instead of appending
|
||||
*/
|
||||
static public function register(bool $prepend = false) {
|
||||
if (self::$registered === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
spl_autoload_register([__CLASS__, 'autoload'], true, $prepend);
|
||||
self::$registered = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles autoloading of classes.
|
||||
*
|
||||
* @param string $class A class name.
|
||||
*/
|
||||
static public function autoload(string $class) {
|
||||
if (0 === strpos($class, 'PhpParser\\')) {
|
||||
$fileName = __DIR__ . strtr(substr($class, 9), '\\', '/') . '.php';
|
||||
if (file_exists($fileName)) {
|
||||
require $fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -10,4 +10,4 @@ interface Builder
|
||||
* @return Node The built node
|
||||
*/
|
||||
public function getNode() : Node;
|
||||
}
|
||||
}
|
||||
|
@ -119,4 +119,4 @@ class Class_ extends Declaration
|
||||
'stmts' => array_merge($this->uses, $this->constants, $this->properties, $this->methods),
|
||||
], $this->attributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,4 +40,4 @@ abstract class Declaration implements PhpParser\Builder
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class Interface_ extends Declaration
|
||||
|
||||
if ($stmt instanceof Stmt\ClassConst) {
|
||||
$this->constants[] = $stmt;
|
||||
} else if ($stmt instanceof Stmt\ClassMethod) {
|
||||
} elseif ($stmt instanceof Stmt\ClassMethod) {
|
||||
// we erase all statements in the body of an interface method
|
||||
$stmt->stmts = null;
|
||||
$this->methods[] = $stmt;
|
||||
@ -72,4 +72,4 @@ class Interface_ extends Declaration
|
||||
'stmts' => array_merge($this->constants, $this->methods),
|
||||
], $this->attributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,4 +109,4 @@ class Property implements PhpParser\Builder
|
||||
$this->attributes
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ class Trait_ extends Declaration
|
||||
|
||||
if ($stmt instanceof Stmt\Property) {
|
||||
$this->properties[] = $stmt;
|
||||
} else if ($stmt instanceof Stmt\ClassMethod) {
|
||||
} elseif ($stmt instanceof Stmt\ClassMethod) {
|
||||
$this->methods[] = $stmt;
|
||||
} else if ($stmt instanceof Stmt\TraitUse) {
|
||||
} elseif ($stmt instanceof Stmt\TraitUse) {
|
||||
$this->uses[] = $stmt;
|
||||
} else {
|
||||
throw new \LogicException(sprintf('Unexpected node of type "%s"', $stmt->getType()));
|
||||
|
@ -7,7 +7,8 @@ use PhpParser\BuilderHelpers;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class Use_ implements Builder {
|
||||
class Use_ implements Builder
|
||||
{
|
||||
protected $name;
|
||||
protected $type;
|
||||
protected $alias = null;
|
||||
|
@ -14,7 +14,8 @@ use PhpParser\Node\Stmt;
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class BuilderHelpers {
|
||||
final class BuilderHelpers
|
||||
{
|
||||
/**
|
||||
* Normalizes a node: Converts builder objects to nodes.
|
||||
*
|
||||
@ -184,7 +185,7 @@ final class BuilderHelpers {
|
||||
public static function normalizeDocComment($docComment) : Comment\Doc {
|
||||
if ($docComment instanceof Comment\Doc) {
|
||||
return $docComment;
|
||||
} else if (is_string($docComment)) {
|
||||
} elseif (is_string($docComment)) {
|
||||
return new Comment\Doc($docComment);
|
||||
} else {
|
||||
throw new \LogicException('Doc comment must be a string or an instance of PhpParser\Comment\Doc');
|
||||
|
@ -164,4 +164,4 @@ class Comment implements \JsonSerializable
|
||||
'tokenPos' => $this->tokenPos,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,4 +4,4 @@ namespace PhpParser\Comment;
|
||||
|
||||
class Doc extends \PhpParser\Comment
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -2,4 +2,5 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
class ConstExprEvaluationException extends \Exception {}
|
||||
class ConstExprEvaluationException extends \Exception
|
||||
{}
|
||||
|
@ -20,15 +20,12 @@ use PhpParser\Node\Scalar;
|
||||
*
|
||||
* The fallback evaluator should throw ConstExprEvaluationException for nodes it cannot evaluate.
|
||||
*
|
||||
* The evaluation is performed as PHP would perform it, and as such may generate notices, warnings
|
||||
* or Errors. For example, if the expression `1%0` is evaluated, an ArithmeticError is thrown. It is
|
||||
* left to the consumer to handle these as appropriate.
|
||||
*
|
||||
* The evaluation is also dependent on runtime configuration in two respects: Firstly, floating
|
||||
* The evaluation is dependent on runtime configuration in two respects: Firstly, floating
|
||||
* point to string conversions are affected by the precision ini setting. Secondly, they are also
|
||||
* affected by the LC_NUMERIC locale.
|
||||
*/
|
||||
class ConstExprEvaluator {
|
||||
class ConstExprEvaluator
|
||||
{
|
||||
private $fallbackEvaluator;
|
||||
|
||||
/**
|
||||
@ -48,7 +45,10 @@ class ConstExprEvaluator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates a constant expression into a PHP value.
|
||||
* Silently evaluates a constant expression into a PHP value.
|
||||
*
|
||||
* Thrown Errors, warnings or notices will be converted into a ConstExprEvaluationException.
|
||||
* The original source of the exception is available through getPrevious().
|
||||
*
|
||||
* If some part of the expression cannot be evaluated, the fallback evaluator passed to the
|
||||
* constructor will be invoked. By default, if no fallback is provided, an exception of type
|
||||
@ -58,9 +58,49 @@ class ConstExprEvaluator {
|
||||
*
|
||||
* @param Expr $expr Constant expression to evaluate
|
||||
* @return mixed Result of evaluation
|
||||
*
|
||||
* @throws ConstExprEvaluationException if the expression cannot be evaluated or an error occurred
|
||||
*/
|
||||
public function evaluateSilently(Expr $expr) {
|
||||
set_error_handler(function($num, $str, $file, $line) {
|
||||
throw new \ErrorException($str, 0, $num, $file, $line);
|
||||
});
|
||||
|
||||
try {
|
||||
return $this->evaluate($expr);
|
||||
} catch (\Throwable $e) {
|
||||
if (!$e instanceof ConstExprEvaluationException) {
|
||||
$e = new ConstExprEvaluationException(
|
||||
"An error occurred during constant expression evaluation", 0, $e);
|
||||
}
|
||||
throw $e;
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly evaluates a constant expression into a PHP value.
|
||||
*
|
||||
* May generate Error exceptions, warnings or notices. Use evaluateSilently() to convert these
|
||||
* into a ConstExprEvaluationException.
|
||||
*
|
||||
* If some part of the expression cannot be evaluated, the fallback evaluator passed to the
|
||||
* constructor will be invoked. By default, if no fallback is provided, an exception of type
|
||||
* ConstExprEvaluationException is thrown.
|
||||
*
|
||||
* See class doc comment for caveats and limitations.
|
||||
*
|
||||
* @param Expr $expr Constant expression to evaluate
|
||||
* @return mixed Result of evaluation
|
||||
*
|
||||
* @throws ConstExprEvaluationException if the expression cannot be evaluated
|
||||
*/
|
||||
public function evaluate(Expr $expr) {
|
||||
public function evaluateDirectly(Expr $expr) {
|
||||
return $this->evaluate($expr);
|
||||
}
|
||||
|
||||
private function evaluate(Expr $expr) {
|
||||
if ($expr instanceof Scalar\LNumber
|
||||
|| $expr instanceof Scalar\DNumber
|
||||
|| $expr instanceof Scalar\String_
|
||||
@ -183,4 +223,4 @@ class ConstExprEvaluator {
|
||||
|
||||
return ($this->fallbackEvaluator)($expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,6 @@ class Error extends \RuntimeException
|
||||
return $this->attributes['endLine'] ?? -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the attributes of the node/token the error occurred at.
|
||||
*
|
||||
@ -99,7 +98,7 @@ class Error extends \RuntimeException
|
||||
* @return bool
|
||||
*/
|
||||
public function hasColumnInfo() : bool {
|
||||
return isset($this->attributes['startFilePos']) && isset($this->attributes['endFilePos']);
|
||||
return isset($this->attributes['startFilePos'], $this->attributes['endFilePos']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -10,4 +10,4 @@ interface ErrorHandler
|
||||
* @param Error $error The error that needs to be handled
|
||||
*/
|
||||
public function handleError(Error $error);
|
||||
}
|
||||
}
|
||||
|
@ -43,4 +43,4 @@ class Collecting implements ErrorHandler
|
||||
public function clearErrors() {
|
||||
$this->errors = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,4 +15,4 @@ class Throwing implements ErrorHandler
|
||||
public function handleError(Error $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,8 @@ namespace PhpParser\Internal;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class DiffElem {
|
||||
class DiffElem
|
||||
{
|
||||
const TYPE_KEEP = 0;
|
||||
const TYPE_REMOVE = 1;
|
||||
const TYPE_ADD = 2;
|
||||
@ -23,4 +24,4 @@ class DiffElem {
|
||||
$this->old = $old;
|
||||
$this->new = $new;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,13 +10,14 @@ namespace PhpParser\Internal;
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Differ {
|
||||
class Differ
|
||||
{
|
||||
private $isEqual;
|
||||
|
||||
/**
|
||||
* Create differ over the given equality relation.
|
||||
*
|
||||
* @param callable $isEqual Equality relation with signature function($a, $b): bool
|
||||
* @param callable $isEqual Equality relation with signature function($a, $b) : bool
|
||||
*/
|
||||
public function __construct(callable $isEqual) {
|
||||
$this->isEqual = $isEqual;
|
||||
@ -160,4 +161,4 @@ class Differ {
|
||||
}
|
||||
return $newDiff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,8 @@ use PhpParser\Node\Expr;
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class PrintableNewAnonClassNode extends Expr {
|
||||
class PrintableNewAnonClassNode extends Expr
|
||||
{
|
||||
/** @var Node\Arg[] Arguments */
|
||||
public $args;
|
||||
/** @var null|Node\Name Name of extended class */
|
||||
@ -45,11 +46,11 @@ class PrintableNewAnonClassNode extends Expr {
|
||||
);
|
||||
}
|
||||
|
||||
public function getType(): string {
|
||||
public function getType() : string {
|
||||
return 'Expr_PrintableNewAnonClass';
|
||||
}
|
||||
|
||||
public function getSubNodeNames() : array {
|
||||
return ['args', 'extends', 'implements', 'stmts'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace PhpParser;
|
||||
namespace PhpParser\Internal;
|
||||
|
||||
/**
|
||||
* Provides operations on token streams, for use by pretty printer.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class TokenStream {
|
||||
class TokenStream
|
||||
{
|
||||
/** @var array Tokens (in token_get_all format) */
|
||||
private $tokens;
|
||||
/** @var int[] Map from position to indentation */
|
||||
@ -214,7 +215,7 @@ class TokenStream {
|
||||
// TODO Handle non-space indentation
|
||||
if ($indent < 0) {
|
||||
$result .= str_replace("\n" . str_repeat(" ", -$indent), "\n", $content);
|
||||
} else if ($indent > 0) {
|
||||
} elseif ($indent > 0) {
|
||||
$result .= str_replace("\n", "\n" . str_repeat(" ", $indent), $content);
|
||||
} else {
|
||||
$result .= $content;
|
||||
@ -252,4 +253,4 @@ class TokenStream {
|
||||
|
||||
return $indentMap;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,8 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
class JsonDecoder {
|
||||
class JsonDecoder
|
||||
{
|
||||
/** @var \ReflectionClass[] Node type to reflection class map */
|
||||
private $reflectionClassCache;
|
||||
|
||||
@ -97,4 +98,4 @@ class JsonDecoder {
|
||||
|
||||
throw new \RuntimeException("Unknown node type \"$nodeType\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ class Lexer
|
||||
$nextFilePos = strpos($this->code, $tokenValue, $filePos);
|
||||
$this->handleInvalidCharacterRange(
|
||||
$filePos, $nextFilePos, $line, $errorHandler);
|
||||
$filePos = (int)$nextFilePos;
|
||||
$filePos = (int) $nextFilePos;
|
||||
}
|
||||
|
||||
$filePos += $tokenLen;
|
||||
@ -255,7 +255,7 @@ class Lexer
|
||||
$id = $this->tokenMap[$token[0]];
|
||||
if (\T_CLOSE_TAG === $token[0]) {
|
||||
$this->prevCloseTagHasNewline = false !== strpos($token[1], "\n");
|
||||
} else if (\T_INLINE_HTML === $token[0]) {
|
||||
} elseif (\T_INLINE_HTML === $token[0]) {
|
||||
$startAttributes['hasLeadingNewline'] = $this->prevCloseTagHasNewline;
|
||||
}
|
||||
|
||||
@ -357,7 +357,7 @@ class Lexer
|
||||
if ('T_HASHBANG' === $name) {
|
||||
// HHVM uses a special token for #! hashbang lines
|
||||
$tokenMap[$i] = Tokens::T_INLINE_HTML;
|
||||
} else if (defined($name = Tokens::class . '::' . $name)) {
|
||||
} elseif (defined($name = Tokens::class . '::' . $name)) {
|
||||
// Other tokens can be mapped directly
|
||||
$tokenMap[$i] = constant($name);
|
||||
}
|
||||
|
@ -2,8 +2,7 @@
|
||||
|
||||
namespace PhpParser\Lexer;
|
||||
|
||||
|
||||
class Emulative extends \PhpParser\Lexer
|
||||
{
|
||||
/* No features requiring emulation have been added in PHP > 7.0 */
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,8 @@ use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Stmt;
|
||||
|
||||
class NameContext {
|
||||
class NameContext
|
||||
{
|
||||
/** @var null|Name Current namespace */
|
||||
protected $namespace;
|
||||
|
||||
@ -281,4 +282,4 @@ class NameContext {
|
||||
$shortName = substr($name, $nsSep + 1);
|
||||
return strtolower($ns) . '\\' . $shortName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ interface Node
|
||||
*
|
||||
* @return Comment[]
|
||||
*/
|
||||
public function getComments(): array;
|
||||
public function getComments() : array;
|
||||
|
||||
/**
|
||||
* Gets the doc comment of the node.
|
||||
|
@ -32,7 +32,7 @@ class Arg extends NodeAbstract
|
||||
return ['value', 'byRef', 'unpack'];
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Arg';
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ class Const_ extends NodeAbstract
|
||||
return ['name', 'value'];
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Const';
|
||||
}
|
||||
}
|
||||
|
@ -6,4 +6,4 @@ use PhpParser\NodeAbstract;
|
||||
|
||||
abstract class Expr extends NodeAbstract
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class ArrayDimFetch extends Expr
|
||||
return ['var', 'dim'];
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_ArrayDimFetch';
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class ArrayItem extends Expr
|
||||
return ['key', 'value', 'byRef'];
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_ArrayItem';
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class Array_ extends Expr
|
||||
return ['items'];
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_Array';
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class Assign extends Expr
|
||||
return ['var', 'expr'];
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_Assign';
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class BitwiseAnd extends AssignOp
|
||||
{
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_AssignOp_BitwiseAnd';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class BitwiseOr extends AssignOp
|
||||
{
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_AssignOp_BitwiseOr';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class BitwiseXor extends AssignOp
|
||||
{
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_AssignOp_BitwiseXor';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class Concat extends AssignOp
|
||||
{
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_AssignOp_Concat';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class Div extends AssignOp
|
||||
{
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_AssignOp_Div';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class Minus extends AssignOp
|
||||
{
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_AssignOp_Minus';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class Mod extends AssignOp
|
||||
{
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_AssignOp_Mod';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class Mul extends AssignOp
|
||||
{
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_AssignOp_Mul';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class Plus extends AssignOp
|
||||
{
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_AssignOp_Plus';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class Pow extends AssignOp
|
||||
{
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_AssignOp_Pow';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class ShiftLeft extends AssignOp
|
||||
{
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_AssignOp_ShiftLeft';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
||||
|
||||
class ShiftRight extends AssignOp
|
||||
{
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_AssignOp_ShiftRight';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class AssignRef extends Expr
|
||||
return ['var', 'expr'];
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_AssignRef';
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class BitwiseAnd extends BinaryOp
|
||||
return '&';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_BitwiseAnd';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class BitwiseOr extends BinaryOp
|
||||
return '|';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_BitwiseOr';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class BitwiseXor extends BinaryOp
|
||||
return '^';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_BitwiseXor';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class BooleanAnd extends BinaryOp
|
||||
return '&&';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_BooleanAnd';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class BooleanOr extends BinaryOp
|
||||
return '||';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_BooleanOr';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class Coalesce extends BinaryOp
|
||||
return '??';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_Coalesce';
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class Concat extends BinaryOp
|
||||
return '.';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_Concat';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class Div extends BinaryOp
|
||||
return '/';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_Div';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class Equal extends BinaryOp
|
||||
return '==';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_Equal';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class Greater extends BinaryOp
|
||||
return '>';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_Greater';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class GreaterOrEqual extends BinaryOp
|
||||
return '>=';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_GreaterOrEqual';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class Identical extends BinaryOp
|
||||
return '===';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_Identical';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class LogicalAnd extends BinaryOp
|
||||
return 'and';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_LogicalAnd';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class LogicalOr extends BinaryOp
|
||||
return 'or';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_LogicalOr';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class LogicalXor extends BinaryOp
|
||||
return 'xor';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_LogicalXor';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class Minus extends BinaryOp
|
||||
return '-';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_Minus';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class Mod extends BinaryOp
|
||||
return '%';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_Mod';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class Mul extends BinaryOp
|
||||
return '*';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_Mul';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class NotEqual extends BinaryOp
|
||||
return '!=';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_NotEqual';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class NotIdentical extends BinaryOp
|
||||
return '!==';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_NotIdentical';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class Plus extends BinaryOp
|
||||
return '+';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_Plus';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class Pow extends BinaryOp
|
||||
return '**';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_Pow';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class ShiftLeft extends BinaryOp
|
||||
return '<<';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_ShiftLeft';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class ShiftRight extends BinaryOp
|
||||
return '>>';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_ShiftRight';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class Smaller extends BinaryOp
|
||||
return '<';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_Smaller';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class SmallerOrEqual extends BinaryOp
|
||||
return '<=';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_SmallerOrEqual';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class Spaceship extends BinaryOp
|
||||
return '<=>';
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BinaryOp_Spaceship';
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class BitwiseNot extends Expr
|
||||
return ['expr'];
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BitwiseNot';
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class BooleanNot extends Expr
|
||||
return ['expr'];
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_BooleanNot';
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\Node\Expr\Cast;
|
||||
|
||||
class Array_ extends Cast
|
||||
{
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_Cast_Array';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\Node\Expr\Cast;
|
||||
|
||||
class Bool_ extends Cast
|
||||
{
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_Cast_Bool';
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\Node\Expr\Cast;
|
||||
|
||||
class Double extends Cast
|
||||
{
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_Cast_Double';
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\Node\Expr\Cast;
|
||||
|
||||
class Int_ extends Cast
|
||||
{
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_Cast_Int';
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\Node\Expr\Cast;
|
||||
|
||||
class Object_ extends Cast
|
||||
{
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_Cast_Object';
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\Node\Expr\Cast;
|
||||
|
||||
class String_ extends Cast
|
||||
{
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_Cast_String';
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use PhpParser\Node\Expr\Cast;
|
||||
|
||||
class Unset_ extends Cast
|
||||
{
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_Cast_Unset';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class ClassConstFetch extends Expr
|
||||
return ['class', 'name'];
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_ClassConstFetch';
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class Clone_ extends Expr
|
||||
return ['expr'];
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_Clone';
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ class Closure extends Expr implements FunctionLike
|
||||
return $this->stmts;
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_Closure';
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class ClosureUse extends Expr
|
||||
return ['var', 'byRef'];
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_ClosureUse';
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class ConstFetch extends Expr
|
||||
return ['name'];
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_ConstFetch';
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class Empty_ extends Expr
|
||||
return ['expr'];
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_Empty';
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class Error extends Expr
|
||||
return [];
|
||||
}
|
||||
|
||||
function getType() : string {
|
||||
public function getType() : string {
|
||||
return 'Expr_Error';
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user