This is a PHP 5.2 to PHP 8.0 parser written in PHP. Its purpose is to simplify static code analysis and manipulation. A parser is useful for static analysis, manipulation of code and basically any other application dealing with code programmatically. A parser constructs an Abstract Syntax Tree (AST) of the code and thus allows dealing with it in an abstract and robust way. As the parser is based on the tokens returned by token_get_all (which is only able to lex the PHP version it runs on), additionally a wrapper for emulating tokens from newer versions is provided. This allows to parse PHP 7.4 source code running on PHP 7.0, for example. This emulation is somewhat hacky and not perfect, but it should work well on any sane code. Support for pretty printing, which is the act of converting an AST into PHP code. Please note that "pretty printing" does not imply that the output is especially pretty.

Features

  • Parsing PHP 5, PHP 7, and PHP 8 code into an abstract syntax tree (AST)
  • Dumping the AST in human-readable form
  • Converting an AST back to PHP code
  • Infrastructure to traverse and modify ASTs
  • Resolution of namespaced names
  • Evaluation of constant expressions
  • Builders to simplify AST construction for code generation
  • Converting an AST into JSON and back

Project Samples

Project Activity

See All Activity >

License

BSD License

Follow PHP Parser

PHP Parser Web Site

You Might Also Like
Our Free Plans just got better! | Auth0 Icon
Our Free Plans just got better! | Auth0

With up to 25k MAUs and unlimited Okta connections, our Free Plan lets you focus on what you do best—building great apps.

You asked, we delivered! Auth0 is excited to expand our Free and Paid plans to include more options so you can focus on building, deploying, and scaling applications without having to worry about your security. Auth0 now, thank yourself later.
Try free now
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of PHP Parser!

Additional Project Details

Programming Language

PHP

Related Categories

PHP Source Code Analysis Tool, PHP Static Code Analysis Tool

Registered

2021-04-09