pestphp/pest-plugin-phpstan
A Pest plugin that brings PHPStan static analysis into your Pest test suite, letting you run and assert PHPStan results directly from tests. Integrate type and error checks into your workflow without leaving Pest.
Architecture fit
Pest is a testing framework layered over PHPUnit that exposes a plugin contract for registering console options and commands. This package is a thin adapter: it surfaces PHPStan as an additional entrypoint inside the Pest binary (e.g. pest --phpstan), delegating the actual analysis to PHPStan's own application. It does not reimplement rules, config discovery, or reporting — PHPStan remains the source of truth. That is the correct separation of concerns, and it fits teams that have standardized on a single ./vendor/bin/pest quality-gate command.
Integration feasibility
High. It is a require-dev Composer package, autodiscovered by Pest's plugin mechanism, requiring no application code changes. PHPStan must be installed separately — the plugin is glue, not a bundle. Realistic effort is hours, not days: install, confirm the flag runs, wire CI.
Technical risk Code-surface risk is low (single-purpose adapter). The material risks are coupling and maturity signals:
pestphp vendor namespace. Repository metadata is reported as unknown, which blocks basic due diligence (commit recency, issue responsiveness, CI status).vendor/bin/phpstan invocation, so blast radius is bounded.Key questions
phpstan.neon / .dist discovery and --configuration, --level, --baseline, --memory-limit, --error-format?Stack fit Native for any Composer-based PHP or Laravel codebase already on Pest. Zero runtime footprint — dev-only, never shipped. Pairs naturally with Larastan (Laravel rules) and with Pest's architecture testing to form a combined static + structural + behavioral gate.
Migration path
Additive, not a migration. Existing vendor/bin/phpstan analyse CI steps keep working unchanged; the plugin adds an alternate entrypoint. Adoption can be staged: individual developer, then CI job, then team convention.
Compatibility Pin explicitly and validate the Pest major + PHPStan major + PHP version triple in a throwaway branch before merging. Confirm the plugin's Composer constraints do not conflict with locked PHPUnit/Pest versions.
Sequencing
pest invocation — developer friction is the primary adoption killer.Maintenance Three things to keep aligned: Pest, PHPStan, and the glue. Budget a dependency-review pass whenever either major bumps. Because the package is thin, the fallback (direct CLI, or vendoring an equivalent adapter) should be documented up front.
Support MIT, community-maintained under an official-org namespace, no commercial backing. Low star count means few eyes on regressions — treat it as convenience, not critical path. Keep a direct PHPStan CI job as a safety net so a plugin regression cannot silently disable static analysis.
Scaling
Analysis cost belongs to PHPStan, not the plugin. It grows with codebase size and rule level. Mitigate with PHPStan's result cache, tuned --memory-limit, path-scoped analysis on PRs, and full-repo analysis nightly.
Failure modes
Ramp-up Near zero for developers already fluent in Pest and PHPStan — the only new surface is one flag. For the TPM: a half-day spike to validate the version matrix and exit-code behavior, then a one-line CI addition.
How can I help you explore Laravel packages today?