PHP Static Analysis v2.x PHP 8.2+

Understand Your
PHP Codebase.

Architecture, maintainability, structural health — 60+ metrics across files, classes, and methods, for the PHP projects you actually have to maintain long-term.

$ composer require --dev php-code-archeology/php-code-archeology

MIT License  ·  PHP 8.2–8.5  ·  Composer  ·  No extensions required

60+
Metrics
6
Report Formats
14
Problem Detectors
God Class, Dead Code…
8.2–8.5
PHP Versions
What it does

Everything your codebase needs
measured and reported.

60+ Architecture Metrics

Cyclomatic complexity, cognitive complexity, maintainability index, LCOM, Halstead metrics, instability, coupling, type coverage — measured per file, class, method, and function. The HTML report includes a full glossary with formulas, thresholds, and interpretation guidelines.

WMC LCOM CBO DIT +56 more

14 Problem Detectors

God classes, too-complex methods, dead code, circular dependencies, deep inheritance trees — automatically flagged with error/warning/info severity and actionable descriptions.

error warning info

6 Report Formats

One analysis. Six outputs. Interactive HTML dashboard, Markdown for wikis, JSON for CI pipelines, SARIF for GitHub Code Scanning, AI-optimised summary, and Knowledge Graph for graph databases.

HTML Markdown JSON SARIF AI Graph

Test Coverage Integration

Auto-detects PHPUnit, Pest, and Codeception. Maps test files to production classes by namespace and naming convention. Ingests Clover XML for line-level coverage data alongside architecture metrics.

Framework-Aware Analysis

Reads your composer.json to detect Symfony, Laravel, and Doctrine — then adjusts metric thresholds and exclusion rules automatically. No false positives from framework boilerplate.

What Sets It Apart

Not just another linter.

Static analysis tools measure complexity. PhpCodeArcheology understands architecture.

MCP Server

Talk to your codebase.

PhpCodeArcheology ships with a built-in MCP (Model Context Protocol) server. Connect it to Claude, Cursor, or any MCP-compatible client and query your architecture with natural language — hotspots, dependency graphs, health scores, refactoring priorities.

PhpCodeArcheology is the first PHP static analysis tool with native MCP support.

The tool also generates a CLAUDE.md — a structured project overview your AI coding assistant can read before touching the codebase. Because the AI should probably know what it's working with.

MCP Tool Calls
get_hotspots {"limit": 5, "min_complexity": 15}
get_refactoring_priorities {"threshold": "high"}
get_impact_analysis {"class": "OrderService"}
get_dependencies {"depth": 2}
Setup
$ claude mcp add phpcodearcheology \
-- vendor/bin/phpcodearcheology mcp
Knowledge Graph

Your codebase as a graph.

Export your entire codebase as a graph — classes as nodes, dependencies as edges. Import into Neo4j, Obsidian, or your own tooling. Spot architectural clusters, dead zones, and coupling hotspots visually.

Test Intelligence

Find your untested hotspots.

Auto-detects PHPUnit, Pest, and Codeception. Maps test files to production classes by namespace and naming convention. Feed in a Clover XML file and get line-level coverage overlaid on architecture metrics — so you know which complex, high-coupling classes have no test coverage.

ClassCoverageTests
UserService94%12 tests
OrderProcessor67%8 tests
PaymentService0%
InvoiceGenerator51%4 tests
AuthMiddleware88%6 tests
Framework Detection

Knows what it's looking at.

Reads your composer.json to detect Symfony, Laravel, and Doctrine — then adjusts metric thresholds and exclusion rules automatically.

Symfony Laravel Doctrine More planned
composer.json detection
"require": {
"symfony/framework-bundle": "^7.0",
"doctrine/orm": "^3.0"
}
↓ Auto-Detected
Symfony: LCOM threshold relaxed
Doctrine: Entity coupling excluded
Controllers: complexity adjusted
Git Churn Analysis

Find the hot zones.

Classes that change constantly and score high on complexity are your real maintenance risks. Cross-reference commit frequency with architecture metrics to surface the files that demand the most attention — before they become emergencies.

ClassCommitsWMCRisk
OrderService 47 38 HIGH
UserRepository 31 22 MED
PaymentGateway 28 19 MED
EventDispatcher 12 8 LOW
Health Score

One number. The whole picture.

The Health Score distills complexity, coupling, cohesion, test coverage, and churn into a single 0–100 score — so you can answer "how healthy is this codebase?" without a spreadsheet. Track it over time to validate that refactoring efforts are actually working.

74
/ 100
Needs Attention
Complexity
61
Coupling
82
Test Coverage
43
Churn Risk
78
Also included
Baseline Management

Save a snapshot. Compare later.

Track metric drift over time. Save a baseline after a cleanup sprint and run it again in a month to see exactly what changed.

↓ WMC 38 → 31 ↑ CBO 12 → 17
Compare Mode

Two runs. Side by side.

Run the analysis on two branches or two points in time and get a structured diff of every metric that changed.

$ phpcodearcheology --compare=baseline.json src/
Quick Start

Up and running in minutes.

1
Install via Composer
composer require --dev php-code-archeology/php-code-archeology
2
Run the analysis
php vendor/bin/phpcodearcheology src/

Output: tmp/report/html/

3
With test coverage (optional)
$ XDEBUG_MODE=coverage vendor/bin/phpunit \
--coverage-clover clover.xml
$ php vendor/bin/phpcodearcheology \
--coverage-file clover.xml src/
4
Quick terminal output (CI-friendly)
php vendor/bin/phpcodearcheology --quick src/