ast

Extension exposing PHP 7 abstract syntax tree


php-ast exports the AST internally used by PHP 7.
php-ast is significantly faster than PHP-Parser, because the AST construction is implemented in C.
However, php-ast may only parse code that is syntactically valid on the version of PHP it runs on.

License: BSD-3-Clause

Latest releases

Version Release Download
1.0.10 2020-09-12 ast-1.0.10.tgz
1.0.9 2020-09-04 ast-1.0.9.tgz
1.0.8 2020-08-05 ast-1.0.8.tgz
1.0.7 2020-07-11 ast-1.0.7.tgz
1.0.6 2020-02-22 ast-1.0.6.tgz
Show all releases

Changelog

Version Message
1.0.10 - Support attributes syntax change (`#[...]`) in php 8.0.0RC1.
- Change the current AST version from 70 to 80. AST version 80 is no longer experimental.
- Add `ReflectionParameter` defaults for `ast\parse_code` and `ast\get_supported_versions` in php 8.
- Add parameter types and return types to reflection for various global functions.
php-ast was already throwing a `TypeError` when invalid parameter types were received.
- Always throw instead of warning when invalid parameters are passed to the ast\Node constructor.
1.0.9 - Support API change in php 8.0.0beta3.
1.0.8 - Recommend using the new constant `ast\flags\PARAM_MODIFIER_*` when checking if parameters use constructor property promotion.
The values of `ast\flags\MODIFIER_*` and `ast\flags\PARAM_VARIADIC` had some overlap in some php 7 versions.
The new constants will have the same values as `ast\flags\MODIFIER_*` in PHP 8.0+, but different values in PHP 7
(and these flags will never be set in php 7).
- Support PHP 8.0's named arguments.
- Support PHP 8.0's nullsafe operator (`?->`).
1.0.7 - Add the experimental AST version 80
- In AST version 80, support returning `mixed` types as an `AST_TYPE` with type `TYPE_MIXED` instead of an `AST_NAME`.
- In AST version 80, support PHP 8.0 attributes for declarations.
- Support PHP 8.0's Match expressions.
- Support PHP 8.0 constructor property promotion, and allow indicating visibility on AST nodes.
Note that `MODIFIER_PUBLIC` and `ast\AST_PARAM` modifiers had overlap in php 7.4,
so the `MODIFIER_*` modifiers are only included in the provided metadata for php 8.0+
1.0.6 - Support TYPE_STATIC for the php 8.0 static return type.
Show complete changelog