|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +PHPStan Friendly Formatter is a PHPStan extension that provides enhanced error output with syntax-highlighted code context around errors. It transforms standard PHPStan output into a visually clear format showing actual problematic code with line numbers. |
| 8 | + |
| 9 | +## Commands |
| 10 | + |
| 11 | +```bash |
| 12 | +composer test # Run PHPUnit tests |
| 13 | +composer cs-fix-dry # Check code style (dry run) |
| 14 | +composer cs-fix # Fix code style issues |
| 15 | +composer analyze # Run PHPStan with friendly formatter |
| 16 | +composer tests # Run all: cs-fix-dry → analyze → test |
| 17 | +``` |
| 18 | + |
| 19 | +## Architecture |
| 20 | + |
| 21 | +``` |
| 22 | +src/ |
| 23 | +├── FriendlyErrorFormatter.php # Main entry point, implements PHPStan ErrorFormatter |
| 24 | +├── CodeHighlight/ |
| 25 | +│ ├── CodeHighlighter.php # Syntax highlighting with version fallback |
| 26 | +│ └── FallbackHighlighter.php # Non-highlighted fallback |
| 27 | +├── Config/ |
| 28 | +│ └── FriendlyFormatterConfig.php # Formatter configuration (lineBefore, lineAfter, editorUrl) |
| 29 | +└── ErrorFormat/ |
| 30 | + ├── ErrorWriter.php # Formats individual errors with code context |
| 31 | + └── SummaryWriter.php # Error identifier summary statistics |
| 32 | +``` |
| 33 | + |
| 34 | +**Data Flow:** PHPStan AnalysisResult → FriendlyErrorFormatter → ErrorWriter (with CodeHighlighter) → SummaryWriter → Console output |
| 35 | + |
| 36 | +## Key Configuration Files |
| 37 | + |
| 38 | +- `phpstan.neon.dist` - PHPStan config (level 10, paths, formatter settings) |
| 39 | +- `extension.neon` - PHPStan extension registration and parameter schema |
| 40 | +- `.php-cs-fixer.dist.php` - Code style rules |
| 41 | +- `phpunit.xml` - PHPUnit 10/11 compatible config |
| 42 | +- `.tool-versions` - PHP version for local dev and CI (used by `php-version-file` in GitHub Actions) |
| 43 | + |
| 44 | +## Compatibility |
| 45 | + |
| 46 | +- PHP: ^8.1 (tested on 8.1, 8.2, 8.3, 8.4, 8.5) |
| 47 | +- PHPStan: ^1.0 || ^2.0 |
| 48 | +- PHPUnit: ^10.0 || ^11.0 (tests use PHP 8 attributes) |
| 49 | +- php-console-highlighter: ^0.3 || ^0.4 || ^0.5 || ^1.0 (with graceful fallback) |
| 50 | + |
| 51 | +The codebase handles multiple dependency versions through class existence checks and fallback implementations. |
0 commit comments