sidz/phpstan-rules
Custom PHPStan rules aimed at Laravel projects, helping catch common mistakes and enforce best practices. Adds extra static analysis checks tailored to typical framework patterns, improving code quality, consistency, and confidence during refactors.
composer require --dev sidz/phpstan-rules
phpstan.neon config by including the ruleset:
includes:
- vendor/sidz/phpstan-rules/rules.neon
vendor/bin/phpstan analyse src
Expect actionable messages for style/architecture violations (e.g., forbidden method calls, inconsistent type hints, or non-PSR-12 naming) without needing custom rule implementations.disallow doctrine queries in domain layer) by combining with parameters > phpstan.rules overrides.errorMessages to selectively exclude legacy issues while enforcing rules only on new code (via paths + ignore blocks).phpstan.ci.neon layer that strictly enables all rules without ignoring errors—ideal for failing builds when standards regress.phpstan-team-rules.neon that extends sidz/phpstan-rules and adds custom project rules.Sidz\PHPStan\Rules\NoPublicPropertyRule) to avoid confusion.rm -rf phpstan/cache after upgrading to avoid stale errors.NoDefaultArgumentsRule) may break BC in libraries. Use ignore in phpstan.neon for vendor code or legacy projects.services: block in phpstan.neon to tweak severity (errorLevel: 2 → warning, 1 → error).--debug to see which rule class triggered an error—this helps triage misfired warnings orfalse positives.How can I help you explore Laravel packages today?