brianhenryie/phpstan-checkstyle

Reads a checkstyle report and prints it using PHPStan formatter

Maintainers

Package info

github.com/BrianHenryIE/phpstan-checkstyle

pkg:composer/brianhenryie/phpstan-checkstyle

Transparency log

Statistics

Installs: 30

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

0.1.1 2026-08-13 20:16 UTC

This package is auto-updated.

Last update: 2026-08-13 20:17:37 UTC


README

Reads a PHPStan generated checkstyle report and prints it using PHPStan's own output formatters.

Designed to sit at the end of a kamazee/pr-filter pipeline, restoring the familiar PHPStan table format after filtering errors down to only those on changed lines.

git fetch origin; git diff $(git rev-parse origin/master) > tmp.diff; phpstan --error-format=checkstyle | sponge phpstan-checkstyle.xml | vendor/bin/prf filter-checkstyle tmp.diff phpstan-checkstyle.xml phpstan-filtered-checkstyle.xml; vendor/bin/phpstan-checkstyle phpstan-filtered-checkstyle.xml

Installation

composer require brianhenryie/phpstan-checkstyle --dev

Usage

Read from a file:

vendor/bin/phpstan-checkstyle report.xml

Read from stdin:

cat report.xml | vendor/bin/phpstan-checkstyle

Error identifiers

Pass -v to include the PHPStan error identifier (e.g. argument.type) alongside each error message:

vendor/bin/phpstan-checkstyle -v report.xml

The identifier is read from the checkstyle source attribute, which PHPStan populates when generating checkstyle output.

Output format

The default output format is table (PHPStan's standard human-readable output). Use --format to select any format PHPStan supports:

vendor/bin/phpstan-checkstyle --format=json report.xml
vendor/bin/phpstan-checkstyle --format=github report.xml   # GitHub Actions annotations
vendor/bin/phpstan-checkstyle --format=gitlab report.xml
vendor/bin/phpstan-checkstyle --format=teamcity report.xml
vendor/bin/phpstan-checkstyle --format=checkstyle report.xml
vendor/bin/phpstan-checkstyle --format=junit report.xml
vendor/bin/phpstan-checkstyle --format=raw report.xml

Full pipeline example

# Run PHPStan, filter to PR diff, display as table
phpstan analyse --error-format=checkstyle \
  | vendor/bin/prf pr.diff \
  | vendor/bin/phpstan-checkstyle

# Same, but output GitHub Actions annotations
phpstan analyse --error-format=checkstyle \
  | vendor/bin/prf pr.diff \
  | vendor/bin/phpstan-checkstyle --format=github

Limitations

The checkstyle format does not carry PHPStan tip messages. Output will match PHPStan's table format exactly except for those fields.

Development

composer install
vendor/bin/phpunit
vendor/bin/phpstan analyse
vendor/bin/phpcs --standard=PSR12 src bin tests