grifart/phpstan-oneline
A PHPStan extension that formats each reported error on a single line, making analysis output easier to read, search, and parse in CI logs or terminals. Useful for grep-friendly error reports and cleaner build output.
Install as a dev dependency (never in production):
composer require --dev grifart/phpstan-oneline
Then point PHPStan at the formatter. The package ships a single formatter class, Grifart\PHPStan\OnelineErrorFormatter, which PHPStan accepts anywhere an errorFormat is valid:
# phpstan.neon
parameters:
errorFormat: Grifart\PHPStan\OnelineErrorFormatter
or ad-hoc from the CLI:
vendor/bin/phpstan analyse --error-format=Grifart\PHPStan\OnelineErrorFormatter
First use case: run it on any project with a handful of known errors and compare against the default table output. You get one line per error of the shape path/to/File.php:42:message, which terminal emulators and most IDEs recognize as a clickable file:line reference. That is the whole point of the package — compact, greppable, jumpable output.
Look at: composer.json to confirm the PHPStan constraint, and your phpstan.neon to see where to drop the errorFormat line. There is nothing else to configure.
Persistent config (recommended). Put errorFormat in the parameters block of the phpstan.neon you actually ship (or a shared phpstan-baseline.neon-adjacent file), so every developer and CI run gets the same output without remembering a flag.
CI logs. This is where the formatter earns its keep. Table output wraps badly in CI log viewers; oneline output is one record per error, trivially greppable and countable:
vendor/bin/phpstan analyse --no-progress --error-format=Grifart\PHPStan\OnelineErrorFormatter > phpstan.log
grep -c '\.php:' phpstan.log # quick error count
Editor problem matchers. GitHub Actions, GitLab, and VS Code's task system can map ^(.*\.php):(\d+):(.*)$ to clickable diagnostics. Wire a matcher or annotation step that consumes the oneline output rather than the table.
Pre-commit / pre-push hooks. Short output makes failures readable in a terminal that just ran a hook:
vendor/bin/phpstan analyse --no-progress --error-format=Grifart\PHPStan\OnelineErrorFormatter || exit 1
Diff-scoped analysis. Combine with PHPStan's path arguments or a changed-files list to get a tight, clickable error list for a PR — the one-line-per-error shape is what makes this comfortable to scan.
Wrapper script. If teams want different formats locally vs. CI, wrap PHPStan in a shell script that sets --error-format per environment; keep phpstan.neon format-agnostic so overrides are explicit.
table or raw, or just open the file and line.file:line:message pattern. iTerm2, VS Code's terminal, and most JetBrains terminals do; bare less, some CI web log viewers, and plain SSH sessions won't make it clickable. That's a limitation of the environment, not the package.oneline registered for you. You must use the fully-qualified Grifart\PHPStan\OnelineErrorFormatter, and the class must be autoloadable (it is, via the package's composer autoload) — a typo yields a confusing "formatter not found" style failure.ErrorFormatter contract, verify this still loads before relying on it in CI. Lock both together.--error-format overrides config. CLI flags win over phpstan.neon; don't be surprised when a local flag silently replaces the configured formatter.|| exit 1 and pipeline gates behave exactly as with the table formatter.OnelineErrorFormatter and register your subclass as the errorFormat. Keep the parent's line construction so clickability and downstream matchers keep working.ignoreErrors, baseline, and --generate-baseline all behave identically — the formatter only touches presentation, so existing suppressions carry over unchanged.How can I help you explore Laravel packages today?