Phan – static analyzer for PHP

Phan is a static analyzer for PHP designed to find problems in code without executing it.

It focuses on minimizing false positives, using inferred and declared type information to check whether classes, functions, variables, properties, constants, and method calls are valid and type safe. The tool is aimed at PHP projects that want configurable analysis, editor integration, and support for gradually increasing strictness as code quality improves.

This is free and open source software.

Key Features

  • Verifies that methods, functions, classes, traits, interfaces, constants, properties, and variables are defined and accessible.
  • Checks type safety and argument counts for method, function, and closure calls.
  • Reports PHP backward compatibility issues across supported PHP 8.x releases.
  • Detects array access problems, invalid return values, dead code, unused variables, redundant conditions, and unused use statements.
  • Understands PHPDoc annotations, union types, generic types, array shapes, inherited annotations, deprecated elements, internal elements, suppressions, magic properties, and magic methods.
  • Supports output formats including text, Checkstyle, JSON, Pylint, CSV, CodeClimate, HTML, and GitHub.
  • Offers optional plugins for project-specific checks, printf format validation, PCRE validation, unreachable code detection, duplicate array keys, and coding style conventions.
  • Can be used with editors and IDEs via the Language Server Protocol and daemon mode.

Website: github.com/phan/phan
Support:
Developer: Tyson Andre, Rasmus Lerdorf, and Andrew S. Morrison
License: MIT License

Phan is written in PHP. Learn PHP with our recommended free books and free tutorials.


Related Software

PHP Linters
PHPStanPHP static analysis tool
PHP Coding Standards FixerFixes your code to follow the standards
MagoExtremely fast PHP linter, formatter, and static analyzer
PsalmStatic analysis tool
PhanStatic analyzer for PHP
PHP_CodeSnifferTokenizes PHP files and detects violations
DeptracStatic code analysis tool for PHP projects
PHP Parallel LintChecks the syntax of PHP files in parallel
PHPLintSpeed up linting PHP files
PHPCompatibilityCoding standard for PHP_CodeSniffer
PHPArkitectDefine architectural rules as executable PHP code

Read our verdict in the software roundup.


Best Free and Open Source Software LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.

We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more.

Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion.

Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README.
Subscribe

Please read our Comment Policy before commenting.

Notify of
guest
0 Comments
Oldest
Newest Most Voted