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

PHPStan Mockery extension

Build Latest Stable Version License

This extension provides the following features:

  • Mockery::mock(), Mockery::spy(), and Mockery::namedMock() return an intersection type (e.g. Foo&MockInterface) so that the mock can be used as both the mocked class and a mock object. See the detailed explanation of intersection types.
  • Interprets Foo|\Mockery\MockInterface in phpDoc so that it results in an intersection type instead of a union type. This can be disabled by setting the mockery.convertUnionToIntersectionType parameter to false.
  • shouldReceive(), shouldNotReceive(), shouldHaveReceived(), shouldNotHaveReceived(), allows(), and expects() methods are understood on mock objects.
  • makePartial() and shouldAllowMockingProtectedMethods() return static, preserving the intersection type for chained calls.
  • Alias (alias:) and overload (overload:) mock prefixes are handled.
  • Partial mock syntax (ClassName[methodName]) is supported.
  • Multiple interfaces passed as comma-separated strings or as separate arguments are resolved.
  • Constructor argument arrays passed to mock() are handled correctly.

Installation

To use this extension, require it in Composer:

composer require --dev phpstan/phpstan-mockery

If you also install phpstan/extension-installer then you're all set!

If you don't want to use phpstan/extension-installer, include extension.neon in your project's PHPStan config:

includes:
    - vendor/phpstan/phpstan-mockery/extension.neon
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