soyhuce/phpstan-extension
A PHPStan extension from Soyhuce that adds custom rules and type extensions for Laravel and PHP projects, helping teams catch bugs earlier and improve static analysis accuracy in CI and local development.
Architecture fit. soyhuce/phpstan-extension is a static-analysis add-on for Laravel projects, not a runtime library. It ships PHPStan rules/type extensions that teach PHPStan about Laravel-specific patterns (container resolution, facades, Eloquent magic, etc.). Because it installs as a require-dev dependency and is wired in only through phpstan.neon, it has zero production footprint and no bearing on application architecture. That makes it a low-blast-radius addition to any Laravel codebase already running PHPStan.
Integration feasibility. Very high. Adoption is a Composer dev dependency plus an includes: entry in the PHPStan config. No service provider, no config publishing, no runtime bootstrapping. The main prerequisite is an existing or newly introduced PHPStan setup; teams without one should treat PHPStan adoption and this extension as a single, sequenced initiative rather than two.
Technical risk. Low overall, but concentrated in version-coupling. This release (2.1.0) is a maintenance/minor bump: a Dependabot CI action update and, more relevantly, test coverage added for Laravel 12. There are no breaking changes, deprecations, or new rules advertised. The residual risks are (a) compatibility drift between the extension, the supported PHPStan major version, and the Laravel major version; and (b) false positives from Laravel-aware rules blocking merges if introduced without a baseline. Laravel 12 test coverage materially reduces risk (a) for teams on or planning Laravel 12, but it is test coverage, not a compatibility guarantee — verify the declared composer.json constraints before assuming support.
Key questions.
Stack fit. Targets standard Laravel applications and packages on Composer with PHPStan in the dev toolchain. Works alongside — but should be evaluated against — Larastan, since both extend PHPStan's understanding of Laravel; running both without a deliberate ruleset review risks duplicated or conflicting diagnostics. Choose one as the primary Laravel-aware layer and treat the other as complementary only if it adds specific rules you need.
Migration path. Add as require-dev, include the extension's config in phpstan.neon, generate a baseline (--generate-baseline) against the current codebase, then ratchet the level up over time. No code changes to application logic are required; the only "migration" is the one-time triage of newly surfaced errors.
Compatibility. 2.1.0's headline item is Laravel 12 test coverage, which makes this the version to standardise on for teams on Laravel 12 or planning the upgrade. For teams on Laravel 10/11 the release is effectively a no-op; upgrading from 2.0.1 is safe and cheap. Pin to ^2.1 and let Dependabot handle patch/minor drift, with CI as the gate.
Sequencing. (1) Confirm PHPStan/Laravel constraint alignment. (2) Add dependency and config on a branch. (3) Generate baseline and review the error volume — a very large baseline signals the ruleset is too aggressive for the current codebase and should start at a lower level. (4) Add a CI job that runs PHPStan without the baseline being silently regenerated. (5) Only then consider raising the analysis level or removing baseline entries.
Maintenance. Minimal and largely automatable. The project already runs Dependabot on its own CI (evidenced by this release), which is a reasonable proxy for maintenance hygiene. Your side of the maintenance burden is the version pin plus the occasional baseline refresh when PHPStan or Laravel majors move.
Support. Upstream support is community/agency-driven via GitHub issues; there is no commercial SLA. For a dev-only tooling dependency this is acceptable, but it argues against making it a hard CI gate without a fallback plan (e.g. ability to drop to a bare PHPStan config if the extension stalls on a future PHPStan major).
Scaling. Analysis time scales with codebase size, not with this extension specifically, but Laravel-aware rules do add per-file overhead. Mitigate with PHPStan's result cache in CI and parallel analysis for larger repos. Cost is bounded and predictable; no production scaling concerns by definition.
Failure modes. (a) CI breakage on a new PHPStan major before the extension ships support — pin PHPStan and upgrade deliberately. (b) False positives blocking unrelated PRs — addressed by baseline discipline and per-rule suppression rather than disabling the extension. (c) Silent baseline regeneration masking new violations — enforce --no-progress with a non-writable baseline in CI. (d) Divergence from a fast-moving Laravel codebase producing stale or incorrect type inferences — watch the issue tracker around Laravel minor releases.
Ramp-up. Low for anyone with PHPStan experience; the extension is configuration, not an API to learn. Teams new to static analysis need roughly a sprint of baseline triage and CI wiring, plus a short team norm on when to suppress versus fix. Budget that for the first adoption; incremental upgrades like 2.1.0 require essentially none.
How can I help you explore Laravel packages today?