A pure PHP substitute for nikic/php-ast, using Microsoft/tolerant-php-parser. Can also be used to generate php-ast trees, even for files with some types of syntax errors.
This project uses Microsoft/tolerant-php-parser to generate a tree with error tolerance, then converts from that tree to ast\Node from php-ast
This release supports AST version 70.
Using it as a slow substitute for php-ast
Using it as an error-tolerant substitute for php-ast (e.g. for use in IDEs)
- There are currently two modes: omitting errors and adding placeholders (e.g.
- Omitting errors only handles some common cases that come up while editing a file.
- Placeholders may change in the future.
- Phan's Language Server uses this code to do that.
To run unit tests, you must install nikic/php-ast 1.0.1+ (for the expected results to be created).
You must also run
composer install if you haven't already done so.
- For php 7.4, php-ast 1.0.3+ must be installed.
- Then run
- Adding a mode to never accept invalid PHP (for completeness)