ast

pecl install 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.

Maintainer

  • Nikita Popov (lead )
  • Tyson Andre (lead )

Details

Stars: 899
Issue openned: 11
Downloads: 2200021
0.1.5
7 years ago
Download DLL for processor with 64 bits architecture (x64)
PHP 7.1
Loading...
PHP 7.0
Loading...
Download DLL for processor with 32 bits architecture (x86)
PHP 7.1
Loading...
PHP 7.0
Loading...
Request a build
Request to the website owner's team the built this extension with this parameters. The result is not guaranteed and can be impossible for many reasons. The extension source code is frequently not upto date with the most recent PHP version.
If you have another code source for this extension, provide it in comment.
Please (or register) to request a build.
Version 0.1.5 change log


- Fix issue #51: Make nullable array/callable have a flag of 0 in inner element, in version 40.
- Added a constructor for the ast\Node class.
- Added ast\flags\FUNC_GENERATOR constant, which is used since PHP 7.1.
- Added ast\flags\FUNC_RETURNS_REF constant, intended to supersede ast\flags\RETURNS_REF.
- Added ast\flags\CLOSURE_USE_REF constant, used by AST_CLOSURE_VAR nodes. Previously "1" was used.
- Added version 45 with the following changes (PHP 7.2 support):
- An `object` type annotation now returns an `AST_TYPE` with `TYPE_OBJECT` flag, rather than
treating `object` as a class name.
- Added version 50 with the following changes:
- `ast\Node\Decl` nodes are no longer generated. AST kinds `AST_FUNCTION`, `AST_METHOD`,
`AST_CLOSURE` and `AST_CLASS` now also use the normal `ast\Node` class. The `name` and
`docComment` properties are now represented as children. The `endLineno` is still represented as
an (undeclared) property.
- An integer `__declId` has been added to declaration nodes of kind `AST_FUNCTION`, `AST_METHOD`,
`AST_CLOSURE` and `AST_CLASS`. The `__declId` uniquely identifies a declaration within the
parsed code and will remain the same if the code is parsed again. This is useful to distinguish
closures declared on the same line, or multiple conditional declarations using the same name.
The ID is not unique across different codes/files.
- `\ast\parse_file` will now consistently return an empty statement list (similar to
`\ast\parse_code`) if it is was passed a zero-byte file. Previously, it would return `null`.

requires:

  • php >=7.0.0
  • pearinstaller >=1.10.0