Share a PHPStan report
Raising a PHPStan level is a project, not a commit. Level 6 on a codebase that has been at level 5 for two years produces a few hundred findings, most of them one-line fixes, none of them assignable from a terminal dump.
PHPStan won't write HTML. It will write JUnit, and JUnit converts.
JUnit → HTML
composer require --dev phpstan/phpstan
pip install junit2html
./vendor/bin/phpstan analyse --error-format=junit > phpstan.xml || true
junit2html phpstan.xml phpstan.html
Or Checkstyle, if the pipeline already speaks it
./vendor/bin/phpstan analyse --error-format=checkstyle > phpstan-checkstyle.xml || true
Then feed it to whatever renders Checkstyle in your stack. Same destination, one fewer new dependency — see sharing a Checkstyle report.
Either way, || true is load-bearing: phpstan analyse exits non-zero on any
finding, and the run with findings is the one worth publishing.
Publish it
Drag phpstan.html into the app, or from CI:
curl -fsS -X PATCH "https://commareports.com/api/v1/reports/$REPORT_ID" \
-H "Authorization: Bearer $COMMA_API_TOKEN" \
-H "Content-Type: application/json" \
-d "$(jq -n --rawfile html phpstan.html \
--arg title "PHPStan L$LEVEL — $GITHUB_REF_NAME" '{title: $title, html: $html}')"
Raising the level, visibly
Keep one report id per repo and PATCH it weekly. The revision history becomes the record of a level bump: the run before, the runs in between, the run where the count hit zero and the baseline got deleted.
- Anchored threads on a cluster of findings, so "these are all the same missing generic annotation on the repository interface" is written once, next to them. See commenting on HTML.
- A routine re-running the analysis on a schedule so nobody has to remember.
Limits
- Entry HTML: 5 MB. Assets: 25 MB per file, 250 MB and 500 files total. A first run at a higher level is the one that gets close — analyse one directory for the shareable view.
- 60 requests/minute per token.
Try it
Comma is free — unlimited reports, unlimited commenters, unlimited revision history.
Publish a static analysis report →