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
PHP_CodeSnifferTokenizes PHP files and detects violations
PHP Parallel LintChecks the syntax of PHP files in parallel
PHPLintSpeed up linting PHP files

Read our verdict in the software roundup.


Best Free and Open Source Software Explore our comprehensive directory of recommended free and open source software. Our carefully curated collection spans every major software category.

This directory is part of our ongoing series of informative articles for Linux enthusiasts. It features hundreds of detailed reviews, along with open source alternatives to proprietary solutions from major corporations such as Google, Microsoft, Apple, Adobe, IBM, Cisco, Oracle, and Autodesk.

You’ll also find interesting projects to try, hardware coverage, free programming books and tutorials, and much more.

Discovered a useful open source Linux program that we haven’t covered yet? Let us know by completing this form.
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted