Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Phpstan Rules

Phpstan Rules Laravel Package

ergebnis/phpstan-rules

A Composer package of PHPStan rules from ergebnis, bundled in rules.neon and auto-included via phpstan/extension-installer. Adds stricter checks such as final classes, forbidden extends, and no named arguments to complement PHPStan core and strict rules.

View on GitHub
Deep Wiki
Context7

Provides rules for phpstan/phpstan.

Frequently asked questions about Phpstan Rules
How do I install and enable ergebnis/phpstan-rules in a Laravel project?
Run composer require --dev ergebnis/phpstan-rules, then either let phpstan/extension-installer auto-include rules.neon or add vendor/ergebnis/phpstan-rules/rules.neon to the includes section of your phpstan.neon. No application code changes are required because the package only registers PHPStan rules. After enabling it, run PHPStan at your current level and expect additional findings from the new checks.
What rules does ergebnis/phpstan-rules provide out of the box?
The package bundles rules such as CallLikes\NoNamedArgumentRule, Classes\FinalRule, Classes\NoExtendsRule, and Closures\NoParameterWithNullDefaultValueRule in a single rules.neon file. Including that file activates the whole set, which is why adoption is close to zero-config. If you only want part of the ruleset, register individual rule services instead of including the bundled file.
Can I enable or disable individual rules from ergebnis/phpstan-rules?
Yes. You can skip the bundled rules.neon and register only the rule services you want in your own phpstan.neon, or keep the full set and suppress specific error identifiers through ignoreErrors. Excluding paths is another common way to keep a rule active for most of the codebase while relaxing it for one directory. The README documents the available parameters and per-rule configuration.
Is ergebnis/phpstan-rules a dev dependency, and does it affect production?
It is a static analysis tool and should be installed with composer require --dev. It adds PHPStan rules only and has no runtime footprint, so nothing ships to production and application behaviour is unchanged. It runs during local analysis or as a CI quality gate alongside your existing PHPStan setup.
Which PHP and Laravel versions are supported by ergebnis/phpstan-rules?
The package is framework-agnostic and works with any Laravel version because it plugs into PHPStan rather than into Laravel itself. Real compatibility is bounded by the PHP versions supported by the PHPStan release you have installed, and the README does not publish a separate Laravel or PHP version matrix. Check composer.json on Packagist and run analysis on your project's PHP version before upgrading.
What changed in ergebnis/phpstan-rules 2.14.2, and why are new errors reported?
Release 2.14.2 registers Closures\NoParameterWithNullDefaultValueRule in rules.neon; the rule already existed in the codebase but was never active for users who include the bundled ruleset. As a result an upgrade can surface violations that were previously silent, which makes it a behaviour change rather than a pure patch. Run analysis before and after the bump, then fix, baseline, or suppress the new findings by identifier instead of rolling the patch back.
How does ergebnis/phpstan-rules compare to phpstan/phpstan-strict-rules?
They are complementary, and the package README recommends running it on top of phpstan/phpstan, phpstan-deprecation-rules, and phpstan-strict-rules. Strict rules focus on language-level strictness and type safety, while ergebnis/phpstan-rules adds opinionated architectural checks such as final classes, forbidden inheritance, and no named arguments. Some checks can overlap, so enabling both blindly may produce duplicate or unexpected findings.
Why is FinalRule or NoExtendsRule flagging my Laravel Eloquent models?
FinalRule requires classes to be final and NoExtendsRule flags any extends clause, which conflicts with common Laravel patterns where models extend Model or base classes are extended by design. Treat these as architectural opinions rather than bugs. Exclude framework-bound directories such as app/Models, or suppress the specific error identifiers with ignoreErrors, and apply the rules strictly to domain and service code instead.
How do I baseline or ignore ergebnis/phpstan-rules errors in CI?
Generate a PHPStan baseline with --generate-baseline before enabling the ruleset so pre-existing issues are separated from newly introduced ones. For targeted exclusions, use ignoreErrors with the rule's error identifier or excludePaths for directories that should not be analysed. Commit the baseline, review it periodically, and avoid ignoring everything, since that defeats the purpose of adding the rules.
Is ergebnis/phpstan-rules actively maintained and safe to adopt?
The repository ships regular releases and has CI workflows, code coverage, and external contributor pull requests, which are positive maintenance signals. Packagist adoption is modest, so expect less community testing than phpstan-strict-rules receives. Pin a version in CI, verify that rules are actually registered in rules.neon on each release, and review the changelog before upgrading.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
vento/laravel-airbrake
wfeller/laravel-batch
maco-studios/mage-os-installer
busarm/armie
siberfx/laravel-logger
kfteam1991/dcat-admin
dashed/dashed-laposta
dashed/dashed-ecommerce-montaportal
dashed/dashed-ecommerce-etsy
neohq/string-blade-compiler
log1x/acf-composer
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager