sanmai/phpstan-rules
Extra PHPStan rules from sanmai that extend static analysis for PHP projects. Helps catch additional issues not covered by core rules, improving code quality and consistency with minimal setup.
composer require --dev sanmai/phpstan-rulesphpstan.neon (or phpstan.dist.neon):
includes:
- vendor/sanmai/phpstan-rules/config/rules.neon
vendor/bin/phpstan analyze – the new rules will apply alongside core PHPStan checks.die/exit in library code or detect missing @return annotations on public methods — both now flagged with high severity.phpstan as a step in your CI pipeline; this package’s rules are tuned to fail builds on real anti-patterns (e.g., unhandled __destruct() exceptions, dynamic property access), not style.level: 5), then gradually increase to 7 or 8 as issues are fixed — the package provides fine-grained rule control via config overrides.services:
-
class: Sanmai\PHPStan\Rules\NoExitRule
tags: [phpstan.rules.rule]
laravel-phpstan); this package focuses on PHP semantics, not framework conventions.NoDirectOutputRule) may conflict with Laravel’s dump() usage in development — exclude specific paths via parameters.ignoreErrors.parameters.phpVersion matches your runtime; rules like NoNamedArgumentReorderingRule rely on accurate version info.--debug flag to see which rule triggered the error — check source comments for exceptions (e.g., some rules allow exit in CLI entrypoints).paths in phpstan.neon — the package itself adds near-zero overhead.phpstan/phpstan-src, making it easy to copy and adapt patterns.How can I help you explore Laravel packages today?