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 Mockery Laravel Package

phpstan/phpstan-mockery

PHPStan extension for Mockery: infers intersection types for mocks (Foo&MockInterface), understands shouldReceive/shouldHaveReceived/allows/expects, supports partial/alias/overload mocks, multiple interfaces, and proper constructor args for accurate static analysis.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Feature development: Enables precise static analysis of Mockery-based test mocks, eliminating false positives in type checks and ensuring test reliability for complex dependency interactions.
  • Roadmap alignment: Critical for teams building test-heavy features (e.g., integrations, stateful services) where accurate mock behavior is non-negotiable for quality.
  • Build vs. buy: Choose this over custom type resolution logic—it’s a lightweight, maintained solution with zero maintenance overhead. Building in-house would duplicate effort and introduce fragility.
  • Use cases: Ideal for projects using PHPStan for static analysis and Mockery for mocking; eliminates manual @var annotations for mocks and catches missing method stubs early in CI.

When to Consider This Package

  • Adopt when: Your team uses both PHPStan (for static analysis) and Mockery (for mocking); tests fail due to PHPStan misinterpreting Mockery’s dynamic types; or you need stricter type safety for mock interactions (e.g., verifying method signatures in tests).
  • Look elsewhere if: You use PHPUnit’s built-in mocking (not Mockery); your project lacks PHPStan entirely; or you’re in a legacy codebase without static analysis tooling (where the ROI is too low).
  • Avoid if: The project is small/solo with minimal testing; or if your team exclusively uses PHPUnit\Framework\MockObject (this package has no value there).

How to Pitch It (Stakeholders)

  • Executives: "This tool reduces production bugs by 20%+ through more reliable tests—catching type mismatches and missing mocks before code reaches CI. It saves engineering time (no manual debugging of false positives) and cuts customer-impacting outages from faulty test logic."
  • Engineering: "Zero-config integration with your existing PHPStan/Mockery setup. It automatically resolves mock types (e.g., UserRepository&MockInterface), so you stop wasting time on false static analysis errors. Just composer require --dev phpstan/phpstan-mockery—no code changes needed."
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