@@ -611,12 +611,14 @@ of consequences:
611
611
retrieving it from a package manager, on Windows by loading a DLL. PHP-Parser is installed as a
612
612
Composer dependency.
613
613
* php-ast only runs on PHP >= 7.0, as prior versions did not use an internal AST. PHP-Parser
614
- supports PHP >= 5.4 .
614
+ supports PHP >= 5.5 .
615
615
* php-ast may only parse code that is syntactically valid on the version of PHP it runs on. This
616
616
means that it's not possible to parse code using features of newer versions (e.g. PHP 7.1 code
617
617
while running on PHP 7.0). Similarly, it is not possible to parse code that is no longer
618
618
syntactically valid on the used version (e.g. some PHP 5 code may no longer be parsed -- however
619
619
most code will work). PHP-Parser supports parsing both newer and older (up to PHP 5.2) versions.
620
+ * php-ast can only parse code which is syntactically valid, while PHP-Parser can provide a partial
621
+ AST for code that contains errors (e.g., because it is currently being edited).
620
622
* php-ast only provides the starting line number (and for declarations the ending line number) of
621
623
nodes, because this is the only part that PHP itself stores. PHP-Parser provides precise file
622
624
offsets.
@@ -641,8 +643,14 @@ There are a number of differences in the AST representation and available suppor
641
643
* AST traversation / visitation: There is currently no standalone package for this either, but
642
644
implementing a recursive AST walk is easy.
643
645
646
+ The [ php-parser-to-php-ast] [ php-parser-to-php-ast ] project can convert the AST produced by
647
+ PHP-Parser into the format used by the php-ast extension. This can be used as a slow fallback in
648
+ case the php-ast extension is not available. It may also be used to produce a partial php-ast output
649
+ for code with syntax errors.
650
+
644
651
[ parser ] : http://lxr.php.net/xref/PHP_TRUNK/Zend/zend_language_parser.y
645
652
[ util ] : https://github.com/nikic/php-ast/blob/master/util.php
646
653
[ test_dump ] : https://github.com/nikic/php-ast/blob/master/tests/001.phpt
647
654
[ php-parser ] : https://github.com/nikic/PHP-Parser
648
655
[ php-ast-reverter ] : https://github.com/tpunt/php-ast-reverter
656
+ [ php-parser-to-php-ast ] : https://github.com/tysonandre/php-parser-to-php-ast
0 commit comments