Name | Modified | Size | Downloads / Week |
---|---|---|---|
Parent folder | |||
Cast | 2017-07-31 | ||
BinaryOp | 2017-07-31 | ||
AssignOp | 2017-07-31 | ||
Yield_.php | 2017-07-31 | 736 Bytes | |
YieldFrom.php | 2017-07-31 | 552 Bytes | |
UnaryPlus.php | 2017-07-31 | 548 Bytes | |
Variable.php | 2017-07-31 | 549 Bytes | |
Ternary.php | 2017-07-31 | 880 Bytes | |
UnaryMinus.php | 2017-07-31 | 537 Bytes | |
StaticCall.php | 2017-07-31 | 913 Bytes | |
StaticPropertyFetch.php | 2017-07-31 | 754 Bytes | |
PropertyFetch.php | 2017-07-31 | 731 Bytes | |
ShellExec.php | 2017-07-31 | 575 Bytes | |
PreInc.php | 2017-07-31 | 526 Bytes | |
Print_.php | 2017-07-31 | 530 Bytes | |
PostInc.php | 2017-07-31 | 528 Bytes | |
PreDec.php | 2017-07-31 | 526 Bytes | |
New_.php | 2017-07-31 | 853 Bytes | |
PostDec.php | 2017-07-31 | 528 Bytes | |
MethodCall.php | 2017-07-31 | 906 Bytes | |
List_.php | 2017-07-31 | 598 Bytes | |
Instanceof_.php | 2017-07-31 | 728 Bytes | |
Isset_.php | 2017-07-31 | 531 Bytes | |
FuncCall.php | 2017-07-31 | 792 Bytes | |
Include_.php | 2017-07-31 | 811 Bytes | |
Eval_.php | 2017-07-31 | 528 Bytes | |
Exit_.php | 2017-07-31 | 651 Bytes | |
Error.php | 2017-07-31 | 645 Bytes | |
ErrorSuppress.php | 2017-07-31 | 544 Bytes | |
ConstFetch.php | 2017-07-31 | 568 Bytes | |
Empty_.php | 2017-07-31 | 530 Bytes | |
Closure.php | 2017-07-31 | 2.3 kB | |
ClosureUse.php | 2017-07-31 | 743 Bytes | |
ClassConstFetch.php | 2017-07-31 | 750 Bytes | |
Clone_.php | 2017-07-31 | 527 Bytes | |
BooleanNot.php | 2017-07-31 | 550 Bytes | |
Cast.php | 2017-07-31 | 533 Bytes | |
BinaryOp.php | 2017-07-31 | 769 Bytes | |
BitwiseNot.php | 2017-07-31 | 537 Bytes | |
AssignOp.php | 2017-07-31 | 695 Bytes | |
AssignRef.php | 2017-07-31 | 712 Bytes | |
Array_.php | 2017-07-31 | 685 Bytes | |
Assign.php | 2017-07-31 | 666 Bytes | |
ArrayDimFetch.php | 2017-07-31 | 713 Bytes | |
ArrayItem.php | 2017-07-31 | 872 Bytes | |
Totals: 45 Items | 29.1 kB | 0 |
PHP Parser
This is a PHP 5.2 to PHP 7.1 parser written in PHP. Its purpose is to simplify static code analysis and manipulation.
Documentation for version 3.x (stable; for running on PHP >= 5.5; for parsing PHP 5.2 to PHP 7.1).
Documentation for version 2.x (stable; for running on PHP >= 5.4; for parsing PHP 5.2 to PHP 7.0).
Documentation for version 1.x (unsupported; for running on PHP >= 5.3; for parsing PHP 5.2 to PHP 5.6).
In a Nutshell
The parser turns PHP source code into an abstract syntax tree. For example, if you pass the following code into the parser:
<?php
echo 'Hi', 'World';
hello\world('foo', 'bar' . 'baz');
You'll get a syntax tree looking roughly like this:
array(
0: Stmt_Echo(
exprs: array(
0: Scalar_String(
value: Hi
)
1: Scalar_String(
value: World
)
)
)
1: Expr_FuncCall(
name: Name(
parts: array(
0: hello
1: world
)
)
args: array(
0: Arg(
value: Scalar_String(
value: foo
)
byRef: false
)
1: Arg(
value: Expr_Concat(
left: Scalar_String(
value: bar
)
right: Scalar_String(
value: baz
)
)
byRef: false
)
)
)
)
You can then work with this syntax tree, for example to statically analyze the code (e.g. to find programming errors or security issues).
Additionally, you can convert a syntax tree back to PHP code. This allows you to do code preprocessing (like automatedly porting code to older PHP versions).
Installation
The preferred installation method is composer:
php composer.phar require nikic/php-parser
Documentation
Component documentation: