tysonandre/php-parser-to-php-ast 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tysonandre/php-parser-to-php-ast

Composer 安装命令:

composer require 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.

README 文档

README

Build Status Build status (Windows)

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.

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

Supported php-ast AST versions: 40, 45, 50

Current Status

No tests are failing

  • Need to normalize namespaces (Mostly done)

Current Issues

  • The test suite this is based off of covers common cases for Phan, but edge cases still remain. See #4
  • See nikic/php-ast#78

Remaining work:

  • Translate PhpParser exception to a \ParseError instance

Usage

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. __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)

  • Then run vendor/bin/phpunit

Possible Future Enhancements

统计信息

  • 总下载量: 24
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 3
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固