Tool category

PHP libraries and building blocks

Parsers, reflection libraries, and control-flow components for developers building custom analysis rules or tools.

Tools in this category

6 tools. Editor picks appear first; review the requirements and trade-offs of each tool.

Libraries and building blocks

PHP Parser

Active

A PHP parser written in PHP

  • PHP
  • Static Analysis
Type
Library
PHP
>=7.4
License
BSD-3-Clause
Install
composer require nikic/php-parser
Stars
17,478
Latest
v5.9.0
Last commit
Last release
Quick pros & cons for PHP Parser

ProProvides a mature PHP AST and traversal API.

ConIt produces syntax structures, not high-level findings.

Editorially reviewed

Libraries and building blocks

PHPStan PHPDoc Parser

Active

Analyzer and documentation-tool authors who need a maintained PHPDoc AST.

  • PHP
  • PHPStan
  • Static Analysis
Type
Library
PHP
PHP 7.4 or PHP 8.x
License
MIT
Pricing
Free and open source
Install
composer require phpstan/phpdoc-parser
Stars
1,545
Latest
2.4.1
Last commit
Last release
Quick pros & cons for PHPStan PHPDoc Parser

ProProvides a maintained PHPDoc AST with generics and advanced type syntax.

ConIt is a parser library, not a ready-to-run analyzer.

Editorially reviewed

Libraries and building blocks

Better Reflection

Active

:crystal_ball: Better Reflection is a reflection API that aims to improve and provide more features than PHP's built-in reflection API.

Type
Library
PHP
~8.4.1 || ~8.5.0
License
MIT
Install
composer require roave/better-reflection
Stars
1,248
Latest
6.75.0
Last commit
Last release
Quick pros & cons for Better Reflection

ProInspects source without loading the reflected classes.

ConIt is a building block, not a ready-made analyzer.

Editorially reviewed

Libraries and building blocks

php-ast

Active

Analyzer authors who need the engine AST; Phan is a prominent consumer.

  • Ast
  • PHP
  • Static Analysis
Type
Library
PHP
>= 7.2.0
License
BSD-3-Clause
Pricing
Free and open source
Install
pecl install ast
Stars
984
Latest
v1.1.4
Last commit
Last release
Quick pros & cons for php-ast

ProExposes the PHP engine's native AST with low parsing overhead.

ConIt is a native extension and consumers must build the actual analysis.

Editorially reviewed

Libraries and building blocks

PHP-cfg

Active

A Control Flow Graph implementation in PHP

Type
Library
PHP
>=7.4
License
MIT
Install
composer require ircmaxell/php-cfg
Stars
247
Latest
V0.8.1
Last commit
Last release
Quick pros & cons for PHP-cfg

ProBuilds control-flow graphs for custom PHP analysis.

ConConsumers must build the actual analysis on top.

Editorially reviewed

Libraries and building blocks

Reflection

Active

Reflection library to do Static Analysis for PHP Projects

Type
Library
PHP
8.2.*|8.3.*|8.4.*|8.5.*
License
MIT
Install
composer require phpdocumentor/reflection
Stars
124
Latest
7.0.0
Last commit
Last release
Quick pros & cons for Reflection

ProResolves code and DocBlock types without executing source.

ConIt is a library rather than a standalone checker.

Editorially reviewed