phpstan / phpstan-mockery
PHPStan Mockery extension
Installs: 22 547 189
Dependents: 711
Suggesters: 2
Security: 0
Stars: 98
Watchers: 3
Forks: 22
Open Issues: 10
Type:phpstan-extension
pkg:composer/phpstan/phpstan-mockery
Requires
- php: ^7.4 || ^8.0
- phpstan/phpstan: ^2.0
Requires (Dev)
- mockery/mockery: ^1.6.11
- php-parallel-lint/php-parallel-lint: ^1.2
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^9.6
- 2.0.x-dev
- 2.0.0
- 1.1.x-dev
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.0
- 0.12.14
- 0.12.13
- 0.12.12
- 0.12.11
- 0.12.10
- 0.12.9
- 0.12.8
- 0.12.7
- 0.12.6
- 0.12.5
- 0.12.4
- 0.12.3
- 0.12.2
- 0.12.1
- 0.12.0
- 0.11.3
- 0.11.2
- 0.11.1
- 0.11
- 0.10.2
- 0.10.1
- 0.10
- dev-update-readme-features
- dev-react-on-issue-opened
- dev-add-missing-export-ignore-rules
- dev-add-claude-md
- dev-renovate/major-github-actions
- dev-renovate/major-root-composer
This package is auto-updated.
Last update: 2026-02-19 21:30:36 UTC
README
This extension provides the following features:
Mockery::mock(),Mockery::spy(), andMockery::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\MockInterfacein phpDoc so that it results in an intersection type instead of a union type. This can be disabled by setting themockery.convertUnionToIntersectionTypeparameter tofalse. shouldReceive(),shouldNotReceive(),shouldHaveReceived(),shouldNotHaveReceived(),allows(), andexpects()methods are understood on mock objects.makePartial()andshouldAllowMockingProtectedMethods()returnstatic, 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!
Manual installation
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