- What is pekral/phpstan-rules used for?
- It is a Composer package that provides custom PHPStan rules for Laravel and PHP projects. It extends static analysis with additional checks beyond PHPStan defaults, helping catch bugs and enforce coding standards. You add it to an existing PHPStan setup rather than replacing PHPStan.
- How do I install pekral/phpstan-rules with Composer?
- Install it as a development dependency with Composer, typically using composer require --dev pekral/phpstan-rules. Then register or include the provided rules in your PHPStan configuration. Check the package README for the exact registration syntax for your PHPStan version.
- Does pekral/phpstan-rules support Laravel projects?
- Yes, the package is intended for Laravel and general PHP projects. Its custom rules extend static analysis so you can add more checks to your existing Laravel PHPStan workflow. It can be used alongside Laravel-focused tooling such as Larastan where appropriate.
- Which PHPStan versions are compatible with pekral/phpstan-rules?
- Compatibility depends on the package release and its PHPStan constraint. Because custom rules rely on PHPStan internals and extension APIs, you should match the package version to your installed PHPStan version. Check composer.json and the README for the supported PHPStan range before upgrading.
- How do I enable the custom rules in phpstan.neon?
- You enable the package by registering its rules or extension in your phpstan.neon configuration. The exact syntax depends on whether the package ships an extension include or expects individual rule classes under the rules key. Follow the README example for your PHPStan version.
- Can I run pekral/phpstan-rules in CI/CD?
- Yes, these are static analysis rules, so they fit naturally into CI/CD pipelines. Run PHPStan with your project configuration in the pipeline and fail the build when new errors are reported. Keep the package as a development dependency because it is not needed at runtime.
- Are pekral/phpstan-rules safe to use in production?
- Yes, they are development-time static analysis rules and do not add runtime code to your application. Install the package with require-dev and run PHPStan locally or in CI. Production deployments do not need the package unless your build process runs PHPStan there.
- How do I ignore or exclude a specific rule from pekral/phpstan-rules?
- Use PHPStan ignoreErrors in phpstan.neon to suppress specific messages, preferably with identifiers or narrow message patterns. You can also exclude paths when a rule is not relevant to generated or legacy code. Prefer targeted ignores over disabling the whole package so you keep the remaining checks.
- Do I need Larastan to use pekral/phpstan-rules?
- No, Larastan is not required just to install this package, because it provides PHPStan rules rather than Laravel runtime analysis. Larastan can still be useful for Laravel-specific type inference and framework understanding. Many Laravel projects use both together, so check the README for recommended configuration.
- How is pekral/phpstan-rules maintained, and what are the alternatives?
- Check Packagist and the repository for release history, open issues, and PHPStan version support before adopting it. Alternatives include PHPStan strict rules, Larastan, and project-specific custom rules. Evaluate the rule set and maintenance activity against your team's static analysis needs.