Debian Codegraph @

vendor/mck89/peast/README.md

raw
1 Peast
2 ==========
3
4 [![Latest Stable Version](https://poser.pugx.org/mck89/peast/v/stable)](https://packagist.org/packages/mck89/peast)
5 [![Total Downloads](https://poser.pugx.org/mck89/peast/downloads)](https://packagist.org/packages/mck89/peast)
6 [![License](https://poser.pugx.org/mck89/peast/license)](https://packagist.org/packages/mck89/peast)
7 [![Build Status](https://github.com/mck89/peast/actions/workflows/test.yml/badge.svg)](https://github.com/mck89/peast/actions/workflows/test.yml)
8
9
10 **Peast** _(PHP ECMAScript Abstract Syntax Tree)_ is a PHP 5.4+ library that parses JavaScript code, according to [ECMAScript specification](http://www.ecma-international.org/publications/standards/Ecma-262.htm), and generates an abstract syntax tree following the [ESTree standard](https://github.com/estree/estree).
11
12 Installation
13 -------------
14 Include the following requirement to your composer.json:
15 ```json
16 {
17 "require": {
18 "mck89/peast": "dev-master"
19 }
20 }
21 ```
22
23 Run `composer install` to install the package.
24
25 Then in your script include the autoloader and you can start using Peast:
26
27 ```php
28 require_once "vendor/autoload.php";
29
30 $source = "var a = 1"; // Your JavaScript code
31 $ast = Peast\Peast::latest($source, $options)->parse(); // Parse it!
32 ```
33
34 Known issues
35 -------------
36 When Xdebug is enabled and Peast is used to scan code that contains deeply nested functions, this fatal error can appear:
37 ```
38 PHP Fatal error: Maximum function nesting level of '512' reached, aborting!
39 ```
40 or
41 ```
42 PHP Warning: Uncaught Error: Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '256' frames
43 ```
44 To prevent this you can set `xdebug.max_nesting_level` to a higher value, such as 512.
45
46 Documentation
47 -------------
48 Read the documentation for more examples and explanations:
49
50 1. [AST generation and tokenization](doc/ast-and-tokenization.md)
51 2. [Tree Traversing](doc/tree-traversing.md)
52 3. [Querying By Selector](doc/querying-by-selector.md)
53 4. [Rendering](doc/rendering.md)
54
55 [Changelog](doc/changelog.md)