- What is soyhuce/phpstan-extension used for?
- It is a PHPStan extension that adds custom rules and type extensions for Laravel and PHP projects. It helps PHPStan understand Laravel-specific patterns such as container resolution, facades and Eloquent magic. The goal is to catch bugs earlier in CI and local development.
- How do I install soyhuce/phpstan-extension in a Laravel app?
- Install it as a dev dependency with Composer, for example composer require --dev soyhuce/phpstan-extension. Then add the extension's config to the includes section of your phpstan.neon. No service provider or config publishing is required because it has no runtime footprint.
- Does soyhuce/phpstan-extension support Laravel 12?
- Version 2.1.0 adds test coverage for Laravel 12, which is the release to standardise on if you are on or planning a Laravel 12 upgrade. That is test coverage rather than a formal compatibility guarantee, so check the declared Laravel constraints in composer.json. For Laravel 10 and 11 the release is effectively a no-op.
- Can I use soyhuce/phpstan-extension together with Larastan?
- Both extend PHPStan's understanding of Laravel, so running them together without a ruleset review risks duplicated or conflicting diagnostics. Choose one as your primary Laravel-aware layer and treat the other as complementary only if it adds specific rules you need. Review the combined output and suppress rules deliberately rather than by accident.
- Does soyhuce/phpstan-extension affect production code?
- No. It installs as a require-dev dependency and is wired in only through phpstan.neon, so it has zero production footprint. It does not register service providers, publish config or bootstrap anything at runtime. It only affects static analysis runs in local development and CI.
- Which PHPStan versions does this extension support?
- The supported PHPStan major version is declared in the package's composer.json constraints, so verify that before upgrading. Version 2.1.0 is described as a maintenance and minor bump rather than a new rules release. Compatibility drift between the extension, PHPStan and Laravel is the main technical risk to watch.
- How do I configure soyhuce/phpstan-extension in phpstan.neon?
- Add the extension's config file to the includes list in your phpstan.neon, following the package documentation for the exact path. There is no service provider, config publishing or runtime bootstrapping to set up. Once included, run PHPStan as usual to see the additional diagnostics.
- Will upgrading to 2.1.0 break my existing PHPStan setup?
- Release notes for 2.1.0 indicate a Dependabot CI action update and added Laravel 12 test coverage, with no breaking changes, deprecations or new rules advertised. Upgrading from 2.0.1 is described as safe and cheap, especially for Laravel 10 and 11 projects. Confirm via the diff if you need certainty about rule behaviour changes.
- How do I deal with false positives from these PHPStan rules?
- Generate a baseline with phpstan --generate-baseline and triage the newly surfaced errors before enforcing the rules in CI. A very large baseline signals the ruleset is too aggressive for the current codebase, so start at a lower analysis level. Make sure CI runs PHPStan without silently regenerating the baseline.
- Is soyhuce/phpstan-extension actively maintained?
- The project runs Dependabot on its own CI, evidenced by the 2.1.0 dependency update, which is a reasonable signal of maintenance hygiene. Check the repository's release cadence and issue-response track record for breaking PHPStan releases before relying on it long term. Pin to ^2.1 and let Dependabot handle patch and minor drift with CI as the gate.