yamadashy/phpstan-friendly-formatter
A PHPStan error formatter that shows the problematic code right where each error occurs, plus a summary of error identifiers and frequencies. Install via Composer, include extension.neon, and set errorFormat to friendly for faster debugging.
Install the package via Composer:
composer require --dev yamadashy/phpstan-friendly-formatter
Then run PHPStan with the formatter using the --formatter option:
vendor/bin/phpstan --formatter=friendly
If you use phpstan.neon (e.g., phpstan.neon.dist), you can configure it permanently:
parameters:
formatting:
formatter: friendly
This is the fastest way to see immediate improvements in output readability—no code changes required. Start with local development, then adopt it in CI for consistent feedback. With v1.4.0+, CI-specific annotations (e.g., GitHub PR diff annotations or TeamCity build log entries) appear automatically when detected—no configuration needed. In v1.5.0, type mismatch errors get expected/actual type highlighting (green = declared, red = found) out of the box, so your first run against a codebase with type errors is noticeably easier to scan.
--formatter=friendly to your composer.json scripts (e.g., "phpstan": "phpstan analyse src --formatter=friendly") for quick, actionable feedback. Since v1.5.0, type mismatches render with expected types in green and actual types in red, making fixes faster to spot.phpstan.neon include in your root, enabling formatter adoption across repos and developers without per-command boilerplate.--debug or --xdebug flags—the formatter renders verbose stack traces cleanly while preserving structured data for CI tools.--formatter=friendly. Benefits from CI-adjacent output locally (e.g., rich summaries and type highlighting) and ensures local logs match CI verbosity levels.friendly, not yamadashy/phpstan-friendly-formatter—no namespace in --formatter= argument.phpstan.neon rules and level settings remain unchanged. If you see fewer errors, double-check it’s not being suppressed by log redirection.Return type int of Child::m() is not covariant with return type string of Parent::m(), the parent's type is green even when it appears later in the sentence. Read green as "declared/expected" and red as "found/actual" regardless of ordering.expects X, Y given, should return X but returns Y, (X) does not accept Y, PHPDoc/native incompatibilities, covariance/contravariance mismatches, invoked with N parameters, M required). Unrecognized messages are printed unchanged, and no configuration is needed.--no-ansi or set PHPSTAN_FORMATTER_COLOR=0.phpstan-to-baseline—error counts and paths are preserved even when annotations are active. Type highlighting is purely decorative and does not alter message text used by downstream parsers.AnalysisResult constructor changes in PHPStan 2.2.x. If you hit unexpected constructor or DI errors on recent PHPStan versions, upgrade.relativePathHelper—make sure you're on 1.4.0+ if you hit cryptic PHPStan startup errors.phpstan --memory-limit=2G for large repos.How can I help you explore Laravel packages today?