Weave Code
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 Wrapper Laravel Package

wyrihaximus/phpstan-rules-wrapper

Meta-package that bundles popular PHPStan rule sets and extensions for stricter static analysis. Install via Composer and it works automatically with phpstan/extension-installer, pulling in deprecation, PHPUnit/Mockery, strict rules, dead-code detection, and more.

View on GitHub
Deep Wiki
Context7

Getting Started

Install the package via Composer — it automatically enables included PHPStan extensions using phpstan/extension-installer. No extra configuration needed to start analyzing code:

composer require --dev wyrihaximus/phpstan-rules-wrapper

Then run PHPStan as usual:

vendor/bin/phpstan analyse src tests  

The wrapper bundles popular rulesets (e.g., phpstan-strict-rules, dead-code-detector, phpunit, mockery), so critical checks like type safety, dead code, deprecations, and test correctness run out of the box.

Implementation Patterns

  • Zero-Config Adoption: Ideal for teams adopting PHPStan gradually — no need to manually configure each ruleset or extension.
  • Consistent Tooling Across Projects: Use the same wrapper version across repos to enforce uniform analysis standards.
  • Layered Analysis: Combine with custom rules in phpstan.neon — the wrapper’s extensions load first, then your custom rules apply. Example:
    includes:
        - vendor/wyrihaximus/phpstan-rules-wrapper/extension.neon
        # Your overrides or additional rules below
    parameters:
        deadCode:
            reportMembersUsedOnlyInTests: true  # Overrides wrapper’s default for dead-code-detector
    
  • CI Integration: Add to GitHub Actions/GitLab CI as a pre-commit or CI step — minimal setup, fast feedback.

Gotchas and Tips

  • Overrides via phpstan.neon: The wrapper may enable strict rules (e.g., ergebnis.noNamedArgument) that break existing code. Check its default config and override selectively in phpstan.neon (e.g., disable specific rules for legacy code). Releases show explicit disables — e.g., v12.1.0 disabled ergebnis.noPhpstanIgnore to prevent conflict with project-specific @phpstan-ignore annotations.
  • Update Caution: This package updates all bundled dependencies together. A minor version bump (e.g., 10.x → 11.x) may introduce breaking changes in underlying rulesets — always run tests and review release notes before upgrading.
  • PHP Version Lockstep: Since v12.0.0+, the wrapper requires PHP 8.4+. Ensure your environment matches — legacy projects may need to pin versions (e.g., ^11.0).
  • Dead Code Detection Nuances: The shipmonk/dead-code-detector included here reports class members used only in tests as dead. Enable it via config if you want stricter coverage — but verify test coverage is robust first.
  • Troubleshooting: If rules seem inactive:
    • Confirm phpstan/extension-installer is installed (it’s auto-required by this package).
    • Run vendor/bin/phpstan clear-result-cache — stale cache may hide new errors.
    • Check extension loading order via vendor/bin/phpstan --debug.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport