- What is esfahanahan/phpstan-rules used for?
- It is a collection of custom PHPStan rules and extensions for Laravel and PHP projects, maintained for EsfahanAhan. The package adds extra static-analysis diagnostics that help teams catch architectural and coding issues early. Version 1.1.0 adds a rule that flags load() calls which reload a constrained parent relation. It is developer tooling, not a runtime library, so it does not change application behavior.
- How do I install esfahanahan/phpstan-rules in a Laravel project?
- Install it as a development dependency with composer require --dev esfahanahan/phpstan-rules. Confirm that your PHP and Laravel versions fall within the package's supported range before upgrading. After installation, register the rules or extension in your phpstan.neon configuration. No database, queue, or deployment migration is required.
- How do I enable the custom rules in phpstan.neon?
- Follow the package README to include its rules file or register the rule services in your phpstan.neon setup. Because this is a PHPStan extension, it runs wherever your existing analyzer runs, such as local pre-commit hooks or CI. Start in report-only mode so you can review findings before making the check blocking. The release note does not describe a separate runtime activation step.
- Does this package work with Larastan and my existing PHPStan setup?
- The package is designed to complement existing static-analysis tooling such as PHPStan and Larastan rather than replace it. It adds diagnostics on top of your current rules, so your existing configuration and baselines should continue to work. Check for overlapping rule identifiers or duplicated checks if you already enforce custom Eloquent rules. Run it once against a representative service to confirm signal quality.
- Which PHP and Laravel versions are supported?
- The release note for v1.1.0 does not state an exact compatibility matrix, so check the package's composer.json require constraints and README before upgrading. The change is a new diagnostic rule and does not indicate breaking changes or required migrations. If your repository spans multiple Laravel versions, run the rule in each CI matrix leg. Compatibility risk is likely limited to the package's own supported versions.
- What does the load() rule flag and why does it matter?
- It flags load() calls that reload a constrained parent relation, which can introduce avoidable queries or redundant eager loading. Catching this early helps keep relationship loading predictable and avoids subtle performance issues in larger codebases. Some findings may be technically correct but contextually acceptable, such as intentional constrained loads for readability or cache warming. Treat the rule as advisory until you have reviewed real findings.
- Is the new rule enabled by default or opt-in?
- The release note does not specify whether the new rule is enabled by default, so confirm this in the package configuration before rolling it out. If it is opt-in, enable it explicitly and test against a representative service. Either way, run it in report-only mode for one sprint before promoting it to blocking. That gives your team time to classify findings and tune ignores.
- How do I suppress false positives or baseline existing violations?
- Use standard PHPStan mechanisms such as ignoreErrors entries, inline @phpstan-ignore comments, and generated baselines for accepted existing patterns. The package's release note does not document a custom suppression syntax, so rely on the analyzer's native features. Generate a baseline for legacy violations, then keep new code clean. Review suppressions periodically so they do not hide real issues.
- Will this package affect production code or runtime performance?
- No. It is development and CI tooling with no production runtime footprint, so application requests, service contracts, and data flows are unaffected. The only performance consideration is the time the analyzer takes to run in your pipeline. Keep it in require-dev and run it through your existing PHPStan workflow. That keeps production deployments unchanged.
- How much CI time does adding this rule cost on a large Laravel codebase?
- Runtime depends on codebase size, whether you scan the full repository or only changed files, and whether PHPStan result caching is enabled. On large monoliths or monorepos, full scans on every commit can become noticeable. Use PHPStan's result cache, parallel analysis, and changed-file checks where supported. Pilot the rule in report-only mode to measure the actual cost before making it blocking.