comparison vendor/nikic/php-parser/README.md @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 5fb285c0d0e3
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 PHP Parser
2 ==========
3
4 [![Build Status](https://travis-ci.org/nikic/PHP-Parser.svg?branch=master)](https://travis-ci.org/nikic/PHP-Parser) [![Coverage Status](https://coveralls.io/repos/github/nikic/PHP-Parser/badge.svg?branch=master)](https://coveralls.io/github/nikic/PHP-Parser?branch=master)
5
6 This is a PHP 5.2 to PHP 7.1 parser written in PHP. Its purpose is to simplify static code analysis and
7 manipulation.
8
9 [**Documentation for version 3.x**][doc_master] (stable; for running on PHP >= 5.5; for parsing PHP 5.2 to PHP 7.1).
10
11 [Documentation for version 2.x][doc_2_x] (stable; for running on PHP >= 5.4; for parsing PHP 5.2 to PHP 7.0).
12
13 [Documentation for version 1.x][doc_1_x] (unsupported; for running on PHP >= 5.3; for parsing PHP 5.2 to PHP 5.6).
14
15 In a Nutshell
16 -------------
17
18 The parser turns PHP source code into an abstract syntax tree. For example, if you pass the following code into the
19 parser:
20
21 ```php
22 <?php
23 echo 'Hi', 'World';
24 hello\world('foo', 'bar' . 'baz');
25 ```
26
27 You'll get a syntax tree looking roughly like this:
28
29 ```php
30 array(
31 0: Stmt_Echo(
32 exprs: array(
33 0: Scalar_String(
34 value: Hi
35 )
36 1: Scalar_String(
37 value: World
38 )
39 )
40 )
41 1: Expr_FuncCall(
42 name: Name(
43 parts: array(
44 0: hello
45 1: world
46 )
47 )
48 args: array(
49 0: Arg(
50 value: Scalar_String(
51 value: foo
52 )
53 byRef: false
54 )
55 1: Arg(
56 value: Expr_Concat(
57 left: Scalar_String(
58 value: bar
59 )
60 right: Scalar_String(
61 value: baz
62 )
63 )
64 byRef: false
65 )
66 )
67 )
68 )
69 ```
70
71 You can then work with this syntax tree, for example to statically analyze the code (e.g. to find
72 programming errors or security issues).
73
74 Additionally, you can convert a syntax tree back to PHP code. This allows you to do code preprocessing
75 (like automatedly porting code to older PHP versions).
76
77 Installation
78 ------------
79
80 The preferred installation method is [composer](https://getcomposer.org):
81
82 php composer.phar require nikic/php-parser
83
84 Documentation
85 -------------
86
87 1. [Introduction](doc/0_Introduction.markdown)
88 2. [Usage of basic components](doc/2_Usage_of_basic_components.markdown)
89 3. [Other node tree representations](doc/3_Other_node_tree_representations.markdown)
90 4. [Code generation](doc/4_Code_generation.markdown)
91
92 Component documentation:
93
94 1. [Error handling](doc/component/Error_handling.markdown)
95 2. [Lexer](doc/component/Lexer.markdown)
96
97 [doc_1_x]: https://github.com/nikic/PHP-Parser/tree/1.x/doc
98 [doc_2_x]: https://github.com/nikic/PHP-Parser/tree/2.x/doc
99 [doc_master]: https://github.com/nikic/PHP-Parser/tree/master/doc