korbeil/phpstan-generic-rules
PHPStan extension that enforces and improves the use of PHP generics. Adds custom rules to catch missing or incorrect template types, invalid generic usages, and helps keep docblocks and type hints consistent for safer, more accurate static analysis.
korbeil/phpstan-generic-rules package extends PHPStan’s static analysis capabilities, introducing custom rules for generic type hints, collections, and other PHP patterns. This aligns well with Laravel’s PHP-centric architecture, where type safety and maintainability are critical.nunomaduro/phpstan-laravel) for static analysis. This package can enhance Laravel’s existing tooling by adding domain-specific rules (e.g., for collections, generics, or Laravel-specific patterns like Eloquent relationships).enabledRules in phpstan.neon.nunomaduro/phpstan-laravel) or custom in-house rules. Test for false positives/negatives early.phpstan/phpstan:^1.10)?phpstan.neon to avoid noise?phpstan/extension-installer, vimeo/psalm) achieve similar goals with less risk?nunomaduro/phpstan-laravel). No additional stack changes are needed.phpstan CLI) or CI pipelines (GitHub Actions, GitLab CI) to enforce rules early.composer require --dev korbeil/phpstan-generic-rules
phpstan.neon):
includes:
- vendor/korbeil/phpstan-generic-rules/extension.neon
services:
phpstan.genericRules:
enabled: true
GenericCollectionRule) to avoid overwhelming the team.level: 5 (or custom levels) to prioritize critical rules../vendor/bin/phpstan analyse appphpstan/phpstan:^1.10).$model->{$relation}).__call, __get).phpstan.neon:
rules:
GenericCollectionRule:
ignorePaths:
- app/Helpers/legacy-helpers.php
phpstan.neon.composer require with --update-with-dependencies cautiously.CONTRIBUTING.md section on rule expectations.@phpstan-ignore-next-line).--parallel).actions/cache).phpstan analyse --profile.--error-format=json for programmatic handling.psalm/plugin-laravel.GenericCollectionRule errors").How can I help you explore Laravel packages today?