mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-07-23 15:21:23 +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 |
CHANGELOG.mdLICENSEREADME.mdUPGRADE-4.0.mdupdateTests.php
doc
grammar
lib
PhpParser
Autoloader.phpBuilder.php
bootstrap.phpBuilder
BuilderHelpers.phpComment.phpComment
ConstExprEvaluationException.phpConstExprEvaluator.phpError.phpErrorHandler.phpErrorHandler
Internal
JsonDecoder.phpLexer.phpLexer
NameContext.phpNode.phpNode
Arg.phpConst_.phpExpr.php
NodeAbstract.phpNodeDumper.phpNodeFinder.phpNodeTraverser.phpNodeTraverserInterface.phpNodeVisitor.phpExpr
ArrayDimFetch.phpArrayItem.phpArray_.phpAssign.php
Identifier.phpName.phpAssignOp
BitwiseAnd.phpBitwiseOr.phpBitwiseXor.phpConcat.phpDiv.phpMinus.phpMod.phpMul.phpPlus.phpPow.phpShiftLeft.phpShiftRight.php
AssignRef.phpBinaryOp
BitwiseAnd.phpBitwiseOr.phpBitwiseXor.phpBooleanAnd.phpBooleanOr.phpCoalesce.phpConcat.phpDiv.phpEqual.phpGreater.phpGreaterOrEqual.phpIdentical.phpLogicalAnd.phpLogicalOr.phpLogicalXor.phpMinus.phpMod.phpMul.phpNotEqual.phpNotIdentical.phpPlus.phpPow.phpShiftLeft.phpShiftRight.phpSmaller.phpSmallerOrEqual.phpSpaceship.php
BitwiseNot.phpBooleanNot.phpCast
ClassConstFetch.phpClone_.phpClosure.phpClosureUse.phpConstFetch.phpEmpty_.phpError.phpErrorSuppress.phpEval_.phpExit_.phpFuncCall.phpInclude_.phpInstanceof_.phpIsset_.phpList_.phpMethodCall.phpNew_.phpPostDec.phpPostInc.phpPreDec.phpPreInc.phpPrint_.phpPropertyFetch.phpShellExec.phpStaticCall.phpStaticPropertyFetch.phpTernary.phpUnaryMinus.phpUnaryPlus.phpVariable.phpYieldFrom.phpYield_.phpName
NullableType.phpParam.phpScalar.phpScalar
Stmt.phpStmt
Break_.phpCase_.phpCatch_.phpClassConst.phpClassLike.phpClassMethod.phpClass_.phpConst_.phpContinue_.phpDeclareDeclare.phpDeclare_.phpDo_.phpEcho_.phpElseIf_.phpElse_.phpExpression.phpFinally_.phpFor_.phpForeach_.phpFunction_.phpGlobal_.phpGoto_.phpGroupUse.phpHaltCompiler.phpIf_.phpInlineHTML.phpInterface_.phpLabel.phpNamespace_.phpNop.phpProperty.phpPropertyProperty.phpReturn_.phpStaticVar.phpStatic_.phpSwitch_.phpThrow_.phpTraitUse.php
VarLikeIdentifier.phpTraitUseAdaptation
Trait_.phpTryCatch.phpUnset_.phpUseUse.phpUse_.phpWhile_.phpNodeVisitor
Parser.phpParser
ParserFactory.phpPrettyPrinter
PrettyPrinterAbstract.phptest
PhpParser
AutoloaderTest.php
bootstrap.phpBuilder
BuilderFactoryTest.phpCodeParsingTest.phpCodeTestParser.phpConstExprEvaluatorTest.phpInternal
JsonDecoderTest.phpNameContextTest.phpNode
NodeAbstractTest.phpNodeTraverserTest.phpNodeVisitor
Parser
ParserFactoryTest.phpParserTest.phpPrettyPrinterTest.phpcode
formatPreservation
prettyPrinter
expr
test_old
35
CHANGELOG.md
35
CHANGELOG.md
@@ -3,15 +3,31 @@ Version 4.0.0-dev
|
|||||||
|
|
||||||
Nothing yet.
|
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)
|
Version 4.0.0-alpha3 (2017-12-26)
|
||||||
---------------------------------
|
---------------------------------
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
* In the formatting-preserving pretty printer:
|
* In the formatting-preserving pretty printer:
|
||||||
* Fixed comment indentation.
|
* Fixed comment indentation.
|
||||||
* Fixed handling of inline HTML in the fallback case.
|
* Fixed handling of inline HTML in the fallback case.
|
||||||
* Fixed insertion into list nodes that require creation of a code block.
|
* Fixed insertion into list nodes that require creation of a code block.
|
||||||
|
|
||||||
### Added
|
### 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`.
|
* 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.
|
||||||
|
|
||||||
Version 3.1.4-dev
|
Version 3.1.5-dev
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
Nothing yet.
|
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)
|
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 trailing comma in group use statements.
|
||||||
* [PHP 7.2] Added support for `object` type. This means `object` types will now be represented as a
|
* [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`.
|
builtin type (a simple `"object"` string), rather than a class `Name`.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
* Floating-point numbers are now printed correctly if the LC_NUMERIC locale uses a comma as decimal
|
* 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()`.
|
`NameResolver::__construct()`.
|
||||||
* The `NameResolver` now adds a `namespacedName` attribute on name nodes that cannot be statically
|
* The `NameResolver` now adds a `namespacedName` attribute on name nodes that cannot be statically
|
||||||
resolved (unqualified unaliased function or constant names in namespaces).
|
resolved (unqualified unaliased function or constant names in namespaces).
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
* Fixed attribute assignment for `GroupUse` prefix and variables in interpolated strings.
|
* 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.
|
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
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(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 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
|
Features
|
||||||
--------
|
--------
|
||||||
@@ -184,8 +184,6 @@ Documentation
|
|||||||
1. [Introduction](doc/0_Introduction.markdown)
|
1. [Introduction](doc/0_Introduction.markdown)
|
||||||
2. [Usage of basic components](doc/2_Usage_of_basic_components.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)
|
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:
|
Component documentation:
|
||||||
|
|
||||||
@@ -196,6 +194,8 @@ Component documentation:
|
|||||||
* Converting AST back to PHP code
|
* Converting AST back to PHP code
|
||||||
* Customizing formatting
|
* Customizing formatting
|
||||||
* Formatting-preserving code transformations
|
* Formatting-preserving code transformations
|
||||||
|
* [AST builders](component/AST_builders.markdown)
|
||||||
|
* Fluent builders for AST nodes
|
||||||
* [Lexer](doc/component/Lexer.markdown)
|
* [Lexer](doc/component/Lexer.markdown)
|
||||||
* Lexer options
|
* Lexer options
|
||||||
* Token and file positions for nodes
|
* Token and file positions for nodes
|
||||||
@@ -203,10 +203,15 @@ Component documentation:
|
|||||||
* [Error handling](doc/component/Error_handling.markdown)
|
* [Error handling](doc/component/Error_handling.markdown)
|
||||||
* Column information for errors
|
* Column information for errors
|
||||||
* Error recovery (parsing of syntactically incorrect code)
|
* 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)
|
* [Performance](doc/component/Performance.markdown)
|
||||||
* Disabling XDebug
|
* Disabling XDebug
|
||||||
* Reusing objects
|
* Reusing objects
|
||||||
* Garbage collection impact
|
* 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_3_x]: https://github.com/nikic/PHP-Parser/tree/3.x/doc
|
||||||
[doc_master]: https://github.com/nikic/PHP-Parser/tree/master/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,
|
* 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
|
`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.
|
can be used to get the effective alias, even if it is not explicitly given.
|
||||||
|
|
||||||
### Miscellaneous
|
### Miscellaneous
|
||||||
|
|
||||||
* The indentation handling in the pretty printer has been changed (this is only relevant if you
|
* 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
|
* 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.
|
`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`.
|
* 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
|
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?
|
What is this for?
|
||||||
-----------------
|
-----------------
|
||||||
@@ -26,11 +26,11 @@ programmatic PHP code analysis are incidentally PHP developers, not C developers
|
|||||||
What can it parse?
|
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
|
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.
|
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.
|
hacky and not perfect, but it should work well on any sane code.
|
||||||
|
|
||||||
What output does it produce?
|
What output does it produce?
|
||||||
|
@@ -7,12 +7,10 @@ Guide
|
|||||||
1. [Introduction](0_Introduction.markdown)
|
1. [Introduction](0_Introduction.markdown)
|
||||||
2. [Usage of basic components](2_Usage_of_basic_components.markdown)
|
2. [Usage of basic components](2_Usage_of_basic_components.markdown)
|
||||||
3. [Other node tree representations](3_Other_node_tree_representations.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
|
Component documentation
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
* [Name resolution](component/Name_resolution.markdown)
|
* [Name resolution](component/Name_resolution.markdown)
|
||||||
* Name resolver options
|
* Name resolver options
|
||||||
* Name resolution context
|
* Name resolution context
|
||||||
@@ -20,6 +18,8 @@ Component documentation
|
|||||||
* Converting AST back to PHP code
|
* Converting AST back to PHP code
|
||||||
* Customizing formatting
|
* Customizing formatting
|
||||||
* Formatting-preserving code transformations
|
* Formatting-preserving code transformations
|
||||||
|
* [AST builders](component/AST_builders.markdown)
|
||||||
|
* Fluent builders for AST nodes
|
||||||
* [Lexer](component/Lexer.markdown)
|
* [Lexer](component/Lexer.markdown)
|
||||||
* Lexer options
|
* Lexer options
|
||||||
* Token and file positions for nodes
|
* Token and file positions for nodes
|
||||||
@@ -27,7 +27,12 @@ Component documentation
|
|||||||
* [Error handling](component/Error_handling.markdown)
|
* [Error handling](component/Error_handling.markdown)
|
||||||
* Column information for errors
|
* Column information for errors
|
||||||
* Error recovery (parsing of syntactically incorrect code)
|
* 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)
|
* [Performance](component/Performance.markdown)
|
||||||
* Disabling XDebug
|
* Disabling XDebug
|
||||||
* Reusing objects
|
* Reusing objects
|
||||||
* Garbage collection impact
|
* 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
|
When PHP-Parser is used to generate (or modify) code, by first creating an Abstract Syntax Tree and
|
||||||
pretty printer to convert it to PHP code. To simplify code generation, the project comes with builders which allow
|
then using the [pretty printer](Pretty_printing.markdown) to convert it to PHP code, it can often
|
||||||
creating node trees using a fluid interface, instead of instantiating all nodes manually. Builders are available for
|
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:
|
the following syntactic elements:
|
||||||
|
|
||||||
* namespaces and use statements
|
* 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
|
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
|
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
|
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
|
attempts to preserve the formatting of code, those AST nodes have not changed, and only reformat
|
||||||
code which has been modified or newly inserted.
|
code which has been modified or newly inserted.
|
||||||
|
|
||||||
Use of the formatting-preservation functionality currently requires some additional preparatory
|
Use of the formatting-preservation functionality requires some additional preparatory steps:
|
||||||
steps:
|
|
||||||
|
|
||||||
```php
|
```php
|
||||||
use PhpParser\{Lexer, NodeTraverser, NodeVisitor, Parser, PrettyPrinter};
|
use PhpParser\{Lexer, NodeTraverser, NodeVisitor, Parser, PrettyPrinter};
|
||||||
@@ -86,6 +85,11 @@ $newStmts = $traverser->traverse($oldStmts);
|
|||||||
$newCode = $printer->printFormatPreserving($newStmts, $oldStmts, $oldTokens);
|
$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
|
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
|
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
|
[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:
|
array_pair_list:
|
||||||
inner_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:
|
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
|
* @return Node The built node
|
||||||
*/
|
*/
|
||||||
public function getNode() : Node;
|
public function getNode() : Node;
|
||||||
}
|
}
|
||||||
|
@@ -119,4 +119,4 @@ class Class_ extends Declaration
|
|||||||
'stmts' => array_merge($this->uses, $this->constants, $this->properties, $this->methods),
|
'stmts' => array_merge($this->uses, $this->constants, $this->properties, $this->methods),
|
||||||
], $this->attributes);
|
], $this->attributes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -40,4 +40,4 @@ abstract class Declaration implements PhpParser\Builder
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -50,7 +50,7 @@ class Interface_ extends Declaration
|
|||||||
|
|
||||||
if ($stmt instanceof Stmt\ClassConst) {
|
if ($stmt instanceof Stmt\ClassConst) {
|
||||||
$this->constants[] = $stmt;
|
$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
|
// we erase all statements in the body of an interface method
|
||||||
$stmt->stmts = null;
|
$stmt->stmts = null;
|
||||||
$this->methods[] = $stmt;
|
$this->methods[] = $stmt;
|
||||||
@@ -72,4 +72,4 @@ class Interface_ extends Declaration
|
|||||||
'stmts' => array_merge($this->constants, $this->methods),
|
'stmts' => array_merge($this->constants, $this->methods),
|
||||||
], $this->attributes);
|
], $this->attributes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -109,4 +109,4 @@ class Property implements PhpParser\Builder
|
|||||||
$this->attributes
|
$this->attributes
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -34,9 +34,9 @@ class Trait_ extends Declaration
|
|||||||
|
|
||||||
if ($stmt instanceof Stmt\Property) {
|
if ($stmt instanceof Stmt\Property) {
|
||||||
$this->properties[] = $stmt;
|
$this->properties[] = $stmt;
|
||||||
} else if ($stmt instanceof Stmt\ClassMethod) {
|
} elseif ($stmt instanceof Stmt\ClassMethod) {
|
||||||
$this->methods[] = $stmt;
|
$this->methods[] = $stmt;
|
||||||
} else if ($stmt instanceof Stmt\TraitUse) {
|
} elseif ($stmt instanceof Stmt\TraitUse) {
|
||||||
$this->uses[] = $stmt;
|
$this->uses[] = $stmt;
|
||||||
} else {
|
} else {
|
||||||
throw new \LogicException(sprintf('Unexpected node of type "%s"', $stmt->getType()));
|
throw new \LogicException(sprintf('Unexpected node of type "%s"', $stmt->getType()));
|
||||||
|
@@ -7,7 +7,8 @@ use PhpParser\BuilderHelpers;
|
|||||||
use PhpParser\Node;
|
use PhpParser\Node;
|
||||||
use PhpParser\Node\Stmt;
|
use PhpParser\Node\Stmt;
|
||||||
|
|
||||||
class Use_ implements Builder {
|
class Use_ implements Builder
|
||||||
|
{
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $type;
|
protected $type;
|
||||||
protected $alias = null;
|
protected $alias = null;
|
||||||
|
@@ -14,7 +14,8 @@ use PhpParser\Node\Stmt;
|
|||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class BuilderHelpers {
|
final class BuilderHelpers
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Normalizes a node: Converts builder objects to nodes.
|
* Normalizes a node: Converts builder objects to nodes.
|
||||||
*
|
*
|
||||||
@@ -184,7 +185,7 @@ final class BuilderHelpers {
|
|||||||
public static function normalizeDocComment($docComment) : Comment\Doc {
|
public static function normalizeDocComment($docComment) : Comment\Doc {
|
||||||
if ($docComment instanceof Comment\Doc) {
|
if ($docComment instanceof Comment\Doc) {
|
||||||
return $docComment;
|
return $docComment;
|
||||||
} else if (is_string($docComment)) {
|
} elseif (is_string($docComment)) {
|
||||||
return new Comment\Doc($docComment);
|
return new Comment\Doc($docComment);
|
||||||
} else {
|
} else {
|
||||||
throw new \LogicException('Doc comment must be a string or an instance of PhpParser\Comment\Doc');
|
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,
|
'tokenPos' => $this->tokenPos,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4,4 +4,4 @@ namespace PhpParser\Comment;
|
|||||||
|
|
||||||
class Doc extends \PhpParser\Comment
|
class Doc extends \PhpParser\Comment
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@@ -2,4 +2,5 @@
|
|||||||
|
|
||||||
namespace PhpParser;
|
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 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
|
* The evaluation is dependent on runtime configuration in two respects: Firstly, floating
|
||||||
* 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
|
|
||||||
* point to string conversions are affected by the precision ini setting. Secondly, they are also
|
* point to string conversions are affected by the precision ini setting. Secondly, they are also
|
||||||
* affected by the LC_NUMERIC locale.
|
* affected by the LC_NUMERIC locale.
|
||||||
*/
|
*/
|
||||||
class ConstExprEvaluator {
|
class ConstExprEvaluator
|
||||||
|
{
|
||||||
private $fallbackEvaluator;
|
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
|
* 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
|
* 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
|
* @param Expr $expr Constant expression to evaluate
|
||||||
* @return mixed Result of evaluation
|
* @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
|
* @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
|
if ($expr instanceof Scalar\LNumber
|
||||||
|| $expr instanceof Scalar\DNumber
|
|| $expr instanceof Scalar\DNumber
|
||||||
|| $expr instanceof Scalar\String_
|
|| $expr instanceof Scalar\String_
|
||||||
@@ -183,4 +223,4 @@ class ConstExprEvaluator {
|
|||||||
|
|
||||||
return ($this->fallbackEvaluator)($expr);
|
return ($this->fallbackEvaluator)($expr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -51,7 +51,6 @@ class Error extends \RuntimeException
|
|||||||
return $this->attributes['endLine'] ?? -1;
|
return $this->attributes['endLine'] ?? -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the attributes of the node/token the error occurred at.
|
* Gets the attributes of the node/token the error occurred at.
|
||||||
*
|
*
|
||||||
@@ -99,7 +98,7 @@ class Error extends \RuntimeException
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function hasColumnInfo() : 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
|
* @param Error $error The error that needs to be handled
|
||||||
*/
|
*/
|
||||||
public function handleError(Error $error);
|
public function handleError(Error $error);
|
||||||
}
|
}
|
||||||
|
@@ -43,4 +43,4 @@ class Collecting implements ErrorHandler
|
|||||||
public function clearErrors() {
|
public function clearErrors() {
|
||||||
$this->errors = [];
|
$this->errors = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,4 +15,4 @@ class Throwing implements ErrorHandler
|
|||||||
public function handleError(Error $error) {
|
public function handleError(Error $error) {
|
||||||
throw $error;
|
throw $error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,8 @@ namespace PhpParser\Internal;
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
class DiffElem {
|
class DiffElem
|
||||||
|
{
|
||||||
const TYPE_KEEP = 0;
|
const TYPE_KEEP = 0;
|
||||||
const TYPE_REMOVE = 1;
|
const TYPE_REMOVE = 1;
|
||||||
const TYPE_ADD = 2;
|
const TYPE_ADD = 2;
|
||||||
@@ -23,4 +24,4 @@ class DiffElem {
|
|||||||
$this->old = $old;
|
$this->old = $old;
|
||||||
$this->new = $new;
|
$this->new = $new;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,13 +10,14 @@ namespace PhpParser\Internal;
|
|||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
class Differ {
|
class Differ
|
||||||
|
{
|
||||||
private $isEqual;
|
private $isEqual;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create differ over the given equality relation.
|
* 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) {
|
public function __construct(callable $isEqual) {
|
||||||
$this->isEqual = $isEqual;
|
$this->isEqual = $isEqual;
|
||||||
@@ -160,4 +161,4 @@ class Differ {
|
|||||||
}
|
}
|
||||||
return $newDiff;
|
return $newDiff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,8 @@ use PhpParser\Node\Expr;
|
|||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
class PrintableNewAnonClassNode extends Expr {
|
class PrintableNewAnonClassNode extends Expr
|
||||||
|
{
|
||||||
/** @var Node\Arg[] Arguments */
|
/** @var Node\Arg[] Arguments */
|
||||||
public $args;
|
public $args;
|
||||||
/** @var null|Node\Name Name of extended class */
|
/** @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';
|
return 'Expr_PrintableNewAnonClass';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSubNodeNames() : array {
|
public function getSubNodeNames() : array {
|
||||||
return ['args', 'extends', 'implements', 'stmts'];
|
return ['args', 'extends', 'implements', 'stmts'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,13 +1,14 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
namespace PhpParser;
|
namespace PhpParser\Internal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides operations on token streams, for use by pretty printer.
|
* Provides operations on token streams, for use by pretty printer.
|
||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
class TokenStream {
|
class TokenStream
|
||||||
|
{
|
||||||
/** @var array Tokens (in token_get_all format) */
|
/** @var array Tokens (in token_get_all format) */
|
||||||
private $tokens;
|
private $tokens;
|
||||||
/** @var int[] Map from position to indentation */
|
/** @var int[] Map from position to indentation */
|
||||||
@@ -214,7 +215,7 @@ class TokenStream {
|
|||||||
// TODO Handle non-space indentation
|
// TODO Handle non-space indentation
|
||||||
if ($indent < 0) {
|
if ($indent < 0) {
|
||||||
$result .= str_replace("\n" . str_repeat(" ", -$indent), "\n", $content);
|
$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);
|
$result .= str_replace("\n", "\n" . str_repeat(" ", $indent), $content);
|
||||||
} else {
|
} else {
|
||||||
$result .= $content;
|
$result .= $content;
|
||||||
@@ -252,4 +253,4 @@ class TokenStream {
|
|||||||
|
|
||||||
return $indentMap;
|
return $indentMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
namespace PhpParser;
|
namespace PhpParser;
|
||||||
|
|
||||||
class JsonDecoder {
|
class JsonDecoder
|
||||||
|
{
|
||||||
/** @var \ReflectionClass[] Node type to reflection class map */
|
/** @var \ReflectionClass[] Node type to reflection class map */
|
||||||
private $reflectionClassCache;
|
private $reflectionClassCache;
|
||||||
|
|
||||||
@@ -97,4 +98,4 @@ class JsonDecoder {
|
|||||||
|
|
||||||
throw new \RuntimeException("Unknown node type \"$nodeType\"");
|
throw new \RuntimeException("Unknown node type \"$nodeType\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -153,7 +153,7 @@ class Lexer
|
|||||||
$nextFilePos = strpos($this->code, $tokenValue, $filePos);
|
$nextFilePos = strpos($this->code, $tokenValue, $filePos);
|
||||||
$this->handleInvalidCharacterRange(
|
$this->handleInvalidCharacterRange(
|
||||||
$filePos, $nextFilePos, $line, $errorHandler);
|
$filePos, $nextFilePos, $line, $errorHandler);
|
||||||
$filePos = (int)$nextFilePos;
|
$filePos = (int) $nextFilePos;
|
||||||
}
|
}
|
||||||
|
|
||||||
$filePos += $tokenLen;
|
$filePos += $tokenLen;
|
||||||
@@ -255,7 +255,7 @@ class Lexer
|
|||||||
$id = $this->tokenMap[$token[0]];
|
$id = $this->tokenMap[$token[0]];
|
||||||
if (\T_CLOSE_TAG === $token[0]) {
|
if (\T_CLOSE_TAG === $token[0]) {
|
||||||
$this->prevCloseTagHasNewline = false !== strpos($token[1], "\n");
|
$this->prevCloseTagHasNewline = false !== strpos($token[1], "\n");
|
||||||
} else if (\T_INLINE_HTML === $token[0]) {
|
} elseif (\T_INLINE_HTML === $token[0]) {
|
||||||
$startAttributes['hasLeadingNewline'] = $this->prevCloseTagHasNewline;
|
$startAttributes['hasLeadingNewline'] = $this->prevCloseTagHasNewline;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,7 +357,7 @@ class Lexer
|
|||||||
if ('T_HASHBANG' === $name) {
|
if ('T_HASHBANG' === $name) {
|
||||||
// HHVM uses a special token for #! hashbang lines
|
// HHVM uses a special token for #! hashbang lines
|
||||||
$tokenMap[$i] = Tokens::T_INLINE_HTML;
|
$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
|
// Other tokens can be mapped directly
|
||||||
$tokenMap[$i] = constant($name);
|
$tokenMap[$i] = constant($name);
|
||||||
}
|
}
|
||||||
|
@@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
namespace PhpParser\Lexer;
|
namespace PhpParser\Lexer;
|
||||||
|
|
||||||
|
|
||||||
class Emulative extends \PhpParser\Lexer
|
class Emulative extends \PhpParser\Lexer
|
||||||
{
|
{
|
||||||
/* No features requiring emulation have been added in PHP > 7.0 */
|
/* 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\Name\FullyQualified;
|
||||||
use PhpParser\Node\Stmt;
|
use PhpParser\Node\Stmt;
|
||||||
|
|
||||||
class NameContext {
|
class NameContext
|
||||||
|
{
|
||||||
/** @var null|Name Current namespace */
|
/** @var null|Name Current namespace */
|
||||||
protected $namespace;
|
protected $namespace;
|
||||||
|
|
||||||
@@ -281,4 +282,4 @@ class NameContext {
|
|||||||
$shortName = substr($name, $nsSep + 1);
|
$shortName = substr($name, $nsSep + 1);
|
||||||
return strtolower($ns) . '\\' . $shortName;
|
return strtolower($ns) . '\\' . $shortName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -90,7 +90,7 @@ interface Node
|
|||||||
*
|
*
|
||||||
* @return Comment[]
|
* @return Comment[]
|
||||||
*/
|
*/
|
||||||
public function getComments(): array;
|
public function getComments() : array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the doc comment of the node.
|
* Gets the doc comment of the node.
|
||||||
|
@@ -32,7 +32,7 @@ class Arg extends NodeAbstract
|
|||||||
return ['value', 'byRef', 'unpack'];
|
return ['value', 'byRef', 'unpack'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Arg';
|
return 'Arg';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,7 +31,7 @@ class Const_ extends NodeAbstract
|
|||||||
return ['name', 'value'];
|
return ['name', 'value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Const';
|
return 'Const';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,4 +6,4 @@ use PhpParser\NodeAbstract;
|
|||||||
|
|
||||||
abstract class Expr extends NodeAbstract
|
abstract class Expr extends NodeAbstract
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@ class ArrayDimFetch extends Expr
|
|||||||
return ['var', 'dim'];
|
return ['var', 'dim'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_ArrayDimFetch';
|
return 'Expr_ArrayDimFetch';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,7 @@ class ArrayItem extends Expr
|
|||||||
return ['key', 'value', 'byRef'];
|
return ['key', 'value', 'byRef'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_ArrayItem';
|
return 'Expr_ArrayItem';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@ class Array_ extends Expr
|
|||||||
return ['items'];
|
return ['items'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_Array';
|
return 'Expr_Array';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@ class Assign extends Expr
|
|||||||
return ['var', 'expr'];
|
return ['var', 'expr'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_Assign';
|
return 'Expr_Assign';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
|||||||
|
|
||||||
class BitwiseAnd extends AssignOp
|
class BitwiseAnd extends AssignOp
|
||||||
{
|
{
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_AssignOp_BitwiseAnd';
|
return 'Expr_AssignOp_BitwiseAnd';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
|||||||
|
|
||||||
class BitwiseOr extends AssignOp
|
class BitwiseOr extends AssignOp
|
||||||
{
|
{
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_AssignOp_BitwiseOr';
|
return 'Expr_AssignOp_BitwiseOr';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
|||||||
|
|
||||||
class BitwiseXor extends AssignOp
|
class BitwiseXor extends AssignOp
|
||||||
{
|
{
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_AssignOp_BitwiseXor';
|
return 'Expr_AssignOp_BitwiseXor';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
|||||||
|
|
||||||
class Concat extends AssignOp
|
class Concat extends AssignOp
|
||||||
{
|
{
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_AssignOp_Concat';
|
return 'Expr_AssignOp_Concat';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
|||||||
|
|
||||||
class Div extends AssignOp
|
class Div extends AssignOp
|
||||||
{
|
{
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_AssignOp_Div';
|
return 'Expr_AssignOp_Div';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
|||||||
|
|
||||||
class Minus extends AssignOp
|
class Minus extends AssignOp
|
||||||
{
|
{
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_AssignOp_Minus';
|
return 'Expr_AssignOp_Minus';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
|||||||
|
|
||||||
class Mod extends AssignOp
|
class Mod extends AssignOp
|
||||||
{
|
{
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_AssignOp_Mod';
|
return 'Expr_AssignOp_Mod';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
|||||||
|
|
||||||
class Mul extends AssignOp
|
class Mul extends AssignOp
|
||||||
{
|
{
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_AssignOp_Mul';
|
return 'Expr_AssignOp_Mul';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
|||||||
|
|
||||||
class Plus extends AssignOp
|
class Plus extends AssignOp
|
||||||
{
|
{
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_AssignOp_Plus';
|
return 'Expr_AssignOp_Plus';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
|||||||
|
|
||||||
class Pow extends AssignOp
|
class Pow extends AssignOp
|
||||||
{
|
{
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_AssignOp_Pow';
|
return 'Expr_AssignOp_Pow';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
|||||||
|
|
||||||
class ShiftLeft extends AssignOp
|
class ShiftLeft extends AssignOp
|
||||||
{
|
{
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_AssignOp_ShiftLeft';
|
return 'Expr_AssignOp_ShiftLeft';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use PhpParser\Node\Expr\AssignOp;
|
|||||||
|
|
||||||
class ShiftRight extends AssignOp
|
class ShiftRight extends AssignOp
|
||||||
{
|
{
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_AssignOp_ShiftRight';
|
return 'Expr_AssignOp_ShiftRight';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@ class AssignRef extends Expr
|
|||||||
return ['var', 'expr'];
|
return ['var', 'expr'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_AssignRef';
|
return 'Expr_AssignRef';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class BitwiseAnd extends BinaryOp
|
|||||||
return '&';
|
return '&';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_BitwiseAnd';
|
return 'Expr_BinaryOp_BitwiseAnd';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class BitwiseOr extends BinaryOp
|
|||||||
return '|';
|
return '|';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_BitwiseOr';
|
return 'Expr_BinaryOp_BitwiseOr';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class BitwiseXor extends BinaryOp
|
|||||||
return '^';
|
return '^';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_BitwiseXor';
|
return 'Expr_BinaryOp_BitwiseXor';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class BooleanAnd extends BinaryOp
|
|||||||
return '&&';
|
return '&&';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_BooleanAnd';
|
return 'Expr_BinaryOp_BooleanAnd';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class BooleanOr extends BinaryOp
|
|||||||
return '||';
|
return '||';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_BooleanOr';
|
return 'Expr_BinaryOp_BooleanOr';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class Coalesce extends BinaryOp
|
|||||||
return '??';
|
return '??';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_Coalesce';
|
return 'Expr_BinaryOp_Coalesce';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class Concat extends BinaryOp
|
|||||||
return '.';
|
return '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_Concat';
|
return 'Expr_BinaryOp_Concat';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class Div extends BinaryOp
|
|||||||
return '/';
|
return '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_Div';
|
return 'Expr_BinaryOp_Div';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class Equal extends BinaryOp
|
|||||||
return '==';
|
return '==';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_Equal';
|
return 'Expr_BinaryOp_Equal';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class Greater extends BinaryOp
|
|||||||
return '>';
|
return '>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_Greater';
|
return 'Expr_BinaryOp_Greater';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class GreaterOrEqual extends BinaryOp
|
|||||||
return '>=';
|
return '>=';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_GreaterOrEqual';
|
return 'Expr_BinaryOp_GreaterOrEqual';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class Identical extends BinaryOp
|
|||||||
return '===';
|
return '===';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_Identical';
|
return 'Expr_BinaryOp_Identical';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class LogicalAnd extends BinaryOp
|
|||||||
return 'and';
|
return 'and';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_LogicalAnd';
|
return 'Expr_BinaryOp_LogicalAnd';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class LogicalOr extends BinaryOp
|
|||||||
return 'or';
|
return 'or';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_LogicalOr';
|
return 'Expr_BinaryOp_LogicalOr';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class LogicalXor extends BinaryOp
|
|||||||
return 'xor';
|
return 'xor';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_LogicalXor';
|
return 'Expr_BinaryOp_LogicalXor';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class Minus extends BinaryOp
|
|||||||
return '-';
|
return '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_Minus';
|
return 'Expr_BinaryOp_Minus';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class Mod extends BinaryOp
|
|||||||
return '%';
|
return '%';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_Mod';
|
return 'Expr_BinaryOp_Mod';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class Mul extends BinaryOp
|
|||||||
return '*';
|
return '*';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_Mul';
|
return 'Expr_BinaryOp_Mul';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class NotEqual extends BinaryOp
|
|||||||
return '!=';
|
return '!=';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_NotEqual';
|
return 'Expr_BinaryOp_NotEqual';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class NotIdentical extends BinaryOp
|
|||||||
return '!==';
|
return '!==';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_NotIdentical';
|
return 'Expr_BinaryOp_NotIdentical';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class Plus extends BinaryOp
|
|||||||
return '+';
|
return '+';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_Plus';
|
return 'Expr_BinaryOp_Plus';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class Pow extends BinaryOp
|
|||||||
return '**';
|
return '**';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_Pow';
|
return 'Expr_BinaryOp_Pow';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class ShiftLeft extends BinaryOp
|
|||||||
return '<<';
|
return '<<';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_ShiftLeft';
|
return 'Expr_BinaryOp_ShiftLeft';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class ShiftRight extends BinaryOp
|
|||||||
return '>>';
|
return '>>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_ShiftRight';
|
return 'Expr_BinaryOp_ShiftRight';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class Smaller extends BinaryOp
|
|||||||
return '<';
|
return '<';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_Smaller';
|
return 'Expr_BinaryOp_Smaller';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class SmallerOrEqual extends BinaryOp
|
|||||||
return '<=';
|
return '<=';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_SmallerOrEqual';
|
return 'Expr_BinaryOp_SmallerOrEqual';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ class Spaceship extends BinaryOp
|
|||||||
return '<=>';
|
return '<=>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BinaryOp_Spaceship';
|
return 'Expr_BinaryOp_Spaceship';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ class BitwiseNot extends Expr
|
|||||||
return ['expr'];
|
return ['expr'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BitwiseNot';
|
return 'Expr_BitwiseNot';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ class BooleanNot extends Expr
|
|||||||
return ['expr'];
|
return ['expr'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_BooleanNot';
|
return 'Expr_BooleanNot';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use PhpParser\Node\Expr\Cast;
|
|||||||
|
|
||||||
class Array_ extends Cast
|
class Array_ extends Cast
|
||||||
{
|
{
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_Cast_Array';
|
return 'Expr_Cast_Array';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use PhpParser\Node\Expr\Cast;
|
|||||||
|
|
||||||
class Bool_ extends Cast
|
class Bool_ extends Cast
|
||||||
{
|
{
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_Cast_Bool';
|
return 'Expr_Cast_Bool';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use PhpParser\Node\Expr\Cast;
|
|||||||
|
|
||||||
class Double extends Cast
|
class Double extends Cast
|
||||||
{
|
{
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_Cast_Double';
|
return 'Expr_Cast_Double';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use PhpParser\Node\Expr\Cast;
|
|||||||
|
|
||||||
class Int_ extends Cast
|
class Int_ extends Cast
|
||||||
{
|
{
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_Cast_Int';
|
return 'Expr_Cast_Int';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use PhpParser\Node\Expr\Cast;
|
|||||||
|
|
||||||
class Object_ extends Cast
|
class Object_ extends Cast
|
||||||
{
|
{
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_Cast_Object';
|
return 'Expr_Cast_Object';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use PhpParser\Node\Expr\Cast;
|
|||||||
|
|
||||||
class String_ extends Cast
|
class String_ extends Cast
|
||||||
{
|
{
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_Cast_String';
|
return 'Expr_Cast_String';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use PhpParser\Node\Expr\Cast;
|
|||||||
|
|
||||||
class Unset_ extends Cast
|
class Unset_ extends Cast
|
||||||
{
|
{
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_Cast_Unset';
|
return 'Expr_Cast_Unset';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,7 @@ class ClassConstFetch extends Expr
|
|||||||
return ['class', 'name'];
|
return ['class', 'name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_ClassConstFetch';
|
return 'Expr_ClassConstFetch';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ class Clone_ extends Expr
|
|||||||
return ['expr'];
|
return ['expr'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_Clone';
|
return 'Expr_Clone';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -65,7 +65,7 @@ class Closure extends Expr implements FunctionLike
|
|||||||
return $this->stmts;
|
return $this->stmts;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_Closure';
|
return 'Expr_Closure';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@ class ClosureUse extends Expr
|
|||||||
return ['var', 'byRef'];
|
return ['var', 'byRef'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_ClosureUse';
|
return 'Expr_ClosureUse';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@ class ConstFetch extends Expr
|
|||||||
return ['name'];
|
return ['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_ConstFetch';
|
return 'Expr_ConstFetch';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ class Empty_ extends Expr
|
|||||||
return ['expr'];
|
return ['expr'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_Empty';
|
return 'Expr_Empty';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@ class Error extends Expr
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() : string {
|
public function getType() : string {
|
||||||
return 'Expr_Error';
|
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