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

Other Useful Business Software
Passwordless Authentication and Passwordless Security Icon
Passwordless Authentication and Passwordless Security

Identity is everything. Protect it with Duo.

It’s no secret — passwords can be a real headache, both for the people who use them and the people who manage them. Over time, we’ve created hundreds of passwords, it’s easy to lose track of them and they’re easily compromised. Fortunately, passwordless authentication is becoming a feasible reality for many businesses. Duo can help you get there.
Get a Free Trial
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