thecodingmachine/phpstan-strict-rules
Extra-strict PHPStan ruleset that flags risky or inconsistent PHP patterns beyond the default checks. Helps enforce cleaner, safer code by catching edge cases and enforcing best practices, with easy opt-in configuration for existing PHPStan setups.
Install the package via Composer to add strict PHPStan rules to your project:
composer require --dev thecodingmachine/phpstan-strict-rules
Then include the ruleset in your phpstan.neon:
includes:
- vendor/thecodingmachine/phpstan-strict-rules/extension.neon
The primary use case is catching common anti-patterns early — e.g., strict equality checks (=== vs ==), enforcing @phpstan-template where generic types are used, or requiring type declarations in docblocks for arrays/iterables.
level: 5 (recommended for most projects), then incrementally increase strictness (level: 6, level: 7) over time.phpstan-exceptional-rules for enhanced error handling enforcement.ignoreErrors selectively in phpstan.neon for legacy code where full compliance is infeasible — but track them via whitelist or ignore-by-regexp for future cleanup.--clear-cache after config changes to avoid stale analysis.phpstan.phpStanVersion match.phpstan/phpstan-strict-rules (the official fork), which supersedes this and is actively maintained.vendor/bin/phpstan analyse -vvv and check the rule class name in the output (e.g., Thematic\StrictComparisonRule) for precise troubleshooting.How can I help you explore Laravel packages today?