Custom PHPStan Error Formatters

January 25, 2026 ยท View on GitHub

Installation

  1. Run composer require --dev nicksdot/phpstan-phpstorm-error-identifiers
  2. Then add the formatter(s) you want to the services section in your phpstan.neon

PHPStan error identifiers in PhpStorm inspection output

Usage

  1. Add the service to phpstan.neon:
services:
	errorFormatter.checkstyle:
		class:  NickSdot\PhpStanPhpStormErrorIdentifiers\CheckstyleErrorFormatterPhpStorm

That's it, PHPStorm will automatically use it. And here is how it looks like:

PHPStan error identifiers in PhpStorm inspection output

LLM Error Formatter

The output of the PHPStan LLM error formatter is optimised for LLMs, resulting in 40โ€“60% less token usage compared to the default RawErrorFormatter output.

Real-life Example (210 errors):

FormatterTokenCharacters
TableErrorFormatter11,693132,882
RawErrorFormatter9,26535,794
LlmErrorFormatter4,31618,245

Usage

  1. Add the service to phpstan.neon:
services:
	errorFormatter.llm:
		class: NickSdot\PhpStanPhpStormErrorIdentifiers\LlmErrorFormatter
  1. Run PHPStan with the --error-format=llm flag.