2017 © Pedro Peláez
 

library php-parser-to-php-ast

A pure PHP substitute for nikic/php-ast, using nikic/php-parser. Can also be used to generate php-ast trees, even for files with some types of syntax errors.

image

tysonandre/php-parser-to-php-ast

A pure PHP substitute for nikic/php-ast, using nikic/php-parser. Can also be used to generate php-ast trees, even for files with some types of syntax errors.

  • Saturday, November 11, 2017
  • by TysonAndre
  • Repository
  • 3 Watchers
  • 1 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 5 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

PHP-Parser to php-ast

Build Status Build status (Windows), (*1)

This converts ASTs(Abstract Syntax Trees) from PHP-Parser to php-ast. It can be used as a PHP-only implementation of php-ast. It can alternatively be used as a best-effort parser for syntactically valid PHP code., (*2)

Also see https://github.com/TysonAndre/tolerant-php-parser-to-php-ast (in progress, may have better results), (*3)

Supported php-ast AST versions: 40, 45, 50, (*4)

Current Status

No tests are failing, (*5)

  • Need to normalize namespaces (Mostly done)

Current Issues, (*6)

  • The test suite this is based off of covers common cases for Phan, but edge cases still remain. See https://github.com/TysonAndre/php-parser-to-php-ast/issues/4
  • See https://github.com/nikic/php-ast/issues/78

Remaining work:, (*7)

  • Translate PhpParser exception to a \ParseError instance

Usage

Using it as a slow substitute for php-ast, (*8)

Using it as an error-tolerant substitute for php-ast: (e.g. for use in IDEs), (*9)

  • There are currently two modes: omitting errors and adding placeholders (e.g. __INCOMPLETE_VARIABLE__).
  • Omitting errors only handles some common cases that come up while editing a file.
  • Placeholders may change in the future.
  • tests/ASTConverter/ErrorTolerantConversionTest.php
  • If performance is an issue, cache previous results for a file's contents (in combination with the version used to generate the file ASTConversion::ASTCONVERTER_VERSION)

Running unit tests

To run unit tests, you must install nikic/php-ast. A version supporting AST versions 40 and/or 50 should be installed (~0.1.5 is preferred), (*10)

  • Then run vendor/bin/phpunit

Possible Future Enhancements

  • https://github.com/Microsoft/tolerant-php-parser/issues/113 See https://github.com/tysonandre/tolerant-php-parser-to-php-ast (The library to convert between AST formats is broken(not finished implementing) and inefficient, waiting for stable API for tolerant-php-parser)

The Versions

11/11 2017

dev-support-phpparser-4

dev-support-phpparser-4

A pure PHP substitute for nikic/php-ast, using nikic/php-parser. Can also be used to generate php-ast trees, even for files with some types of syntax errors.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tyson Andre

parser php ast

10/10 2017

dev-master

9999999-dev

A pure PHP substitute for nikic/php-ast, using nikic/php-parser. Can also be used to generate php-ast trees, even for files with some types of syntax errors.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tyson Andre

parser php ast

18/09 2017

0.2.0

0.2.0.0

A pure PHP substitute for nikic/php-ast, using nikic/php-parser. Can also be used to generate php-ast trees, even for files with some types of syntax errors.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tyson Andre

parser php ast

18/09 2017

0.1.0

0.1.0.0

A php-parser to php-ast converter written in php. Can be used to test out projects using php-ast without compiling php-ast.

  Sources   Download

The Requires

 

The Development Requires

17/09 2017

0.0.2

0.0.2.0

A php-parser to php-ast converter written in php. Can be used to test out projects using php-ast without compiling php-ast.

  Sources   Download

The Requires

 

The Development Requires

02/09 2017

dev-support-50

dev-support-50

A php-parser to php-ast converter written in php. Can be used to test out projects using php-ast without compiling php-ast.

  Sources   Download

The Requires

 

The Development Requires

02/09 2017

0.0.1

0.0.1.0

A php-parser to php-ast converter written in php. Can be used to test out projects using php-ast without compiling php-ast.

  Sources   Download

The Requires

 

The Development Requires