Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. DevSecOps
  3. phan

phan

NOASSERTIONPHP6.0.7

A static analyzer for PHP that minimizes false positives by attempting to prove incorrectness rather than correctness.

Visit WebsiteGitHubGitHub
5.6k stars366 forks0 contributors

What is phan?

Phan is a static analyzer for PHP that detects bugs, type errors, and potential issues in code without executing it. It analyzes PHP source files to catch common mistakes like undefined variables, type mismatches, dead code, and PHP version incompatibilities, helping developers improve code reliability and maintainability.

Target Audience

PHP developers and teams working on medium to large codebases who want to catch bugs early, enforce type safety, and gradually improve code quality through static analysis.

Value Proposition

Developers choose Phan for its low false-positive rate, practical approach to analyzing sloppy legacy code, and extensive support for modern PHP features like union types and generics. Its plugin system and editor integration make it highly adaptable to specific project needs.

Overview

Phan is a static analyzer for PHP. Phan prefers to avoid false-positives and attempts to prove incorrectness rather than correctness.

Use Cases

Best For

  • Finding type mismatches and undefined symbols in PHP applications
  • Detecting dead code and unused variables to clean up codebases
  • Ensuring PHP version compatibility when upgrading or maintaining projects
  • Enforcing code quality standards through customizable plugins
  • Integrating static analysis into CI/CD pipelines for PHP projects
  • Analyzing large, existing PHP codebases with minimal configuration

Not Ideal For

  • Projects relying heavily on eval() or dynamic code generation that bypasses static analysis
  • Teams needing zero-configuration, real-time linting for small, single-file scripts
  • Environments where installing PHP extensions like php-ast is restricted or not feasible
  • Codebases that extensively use magic methods or framework-specific autoloading without PHPDoc annotations

Pros & Cons

Pros

Minimized False Positives

Phan focuses on proving incorrectness rather than correctness, leading to fewer false alarms and making it practical for large, sloppy codebases, as stated in its philosophy.

Advanced Type Support

Supports modern PHP features like union types, generics, and array shapes, along with comprehensive PHPDoc annotation parsing, as detailed in the features list.

Extensible Plugin System

Allows custom checks via plugins for regex validation, printf formatting, and coding style, with several bundled plugins available for immediate use.

Incremental Adoption Friendly

Designed to be configured with varying strictness levels, enabling teams to gradually strengthen analysis as code quality improves, per the wiki guidance.

Cons

Requires php-ast Extension

Phan depends on the php-ast extension for optimal parsing, which must be installed separately and may not be available in all hosting or CI environments.

Configuration Overhead

Setting up involves creating a detailed config.php file and managing directory lists, which can be complex for projects with intricate structures or legacy code.

Limited Flow Control Analysis

The README admits Phan has a good but not comprehensive understanding of flow control, potentially missing issues in complex conditional logic or dynamic value tracking.

Frequently Asked Questions

Quick Stats

Stars5,623
Forks366
Contributors0
Open Issues784
Last commit2 days ago
CreatedSince 2015

Tags

#developer-tools#analyzer#linter#static-code-analysis#code-quality#language-server-protocol#type-checking#analysis#phpdoc#php#static-analysis#dead-code-detection

Built With

C
Composer
P
PHP

Links & Resources

Website

Included in

PHP32.5kDevSecOps1.7k
Auto-fetched 5 hours ago

Related Projects

PHPStanPHPStan

PHP Static Analysis Tool - discover bugs in your code without running it!

Stars14,100
Forks961
Last commit11 hours ago
LarastanLarastan

⚗️ Adds code analysis to Laravel improving developer productivity and code quality.

Stars6,499
Forks505
Last commit15 hours ago
PsalmPsalm

A PHP static analysis tool for finding errors and security vulnerabilities in PHP applications

Stars5,889
Forks709
Last commit1 month ago
MagoMago

Mago is a toolchain for PHP that aims to provide a set of tools to help developers write better code.

Stars3,427
Forks183
Last commit8 hours ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub