A PHP parser written in Go that generates an abstract syntax tree for static analysis and tooling.
php-parser is a PHP parser implemented in Go that converts PHP source code into an abstract syntax tree (AST). It enables developers to build static analysis, refactoring, metrics, and code formatting tools by providing a structured representation of PHP code. The parser fully supports PHP 5 and PHP 7 syntax, offering a robust foundation for PHP code manipulation.
Developers and tool builders working on static analysis, linters, code search, refactoring, or formatting tools for PHP codebases. It is particularly suited for those who need to programmatically analyze or transform PHP source code using Go.
Developers choose php-parser for its performance and reliability, leveraging Go's efficiency to create a fast parser suitable for production-grade PHP tooling. Its unique selling points include full PHP 5 and 7 support, error-tolerant parsing, comment preservation, and namespace resolution, making it a comprehensive solution for PHP code analysis.
PHP parser written in Go
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Fully supports PHP 5 and 7 syntax, enabling parsing of both legacy and modern codebases, as stated in the README's key features.
Handles syntax-invalid PHP files gracefully, allowing for static analysis on broken or partially written code, which is a highlighted feature.
Saves and prints free-floating comments and whitespaces in the AST, making it ideal for code formatting tools that need to maintain original formatting.
Leverages Go's efficiency for fast parsing, as emphasized in the philosophy section, making it suitable for production-grade tooling.
Automatically resolves fully qualified names and use aliases via the namespace resolver, simplifying static analysis tasks.
Does not yet support PHP 8 syntax, as mentioned in the roadmap, limiting its use with the latest PHP versions until implemented.
Requires Go knowledge and setup, including tools like goyacc and ragel, which can be a barrier for PHP-focused developers unfamiliar with Go.
Working with the AST directly can be intricate and requires understanding of both PHP syntax and Go's visitor patterns, with limited high-level abstractions.
Fewer pre-built tools and integrations compared to established PHP parsers like nikic/PHP-Parser, which has a larger community and plugin base.