PHPackages                             phpstan/phpstan-mockery - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. phpstan/phpstan-mockery

ActivePhpstan-extension[Testing &amp; Quality](/categories/testing)

phpstan/phpstan-mockery
=======================

PHPStan Mockery extension

2.0.0(1y ago)10326.9M↓39.3%24[9 issues](https://github.com/phpstan/phpstan-mockery/issues)[2 PRs](https://github.com/phpstan/phpstan-mockery/pulls)20MITPHPPHP ^7.4 || ^8.0CI passing

Since Aug 12Pushed 3d ago3 watchersCompare

[ Source](https://github.com/phpstan/phpstan-mockery)[ Packagist](https://packagist.org/packages/phpstan/phpstan-mockery)[ RSS](/packages/phpstan-phpstan-mockery/feed)WikiDiscussions 2.0.x Synced 2d ago

READMEChangelog (10)Dependencies (6)Versions (38)Used By (20)

PHPStan Mockery extension
=========================

[](#phpstan-mockery-extension)

[![Build](https://github.com/phpstan/phpstan-mockery/workflows/Build/badge.svg)](https://github.com/phpstan/phpstan-mockery/actions)[![Latest Stable Version](https://camo.githubusercontent.com/34c7909fa1f71ec2bfd6f1db485bc0b58a338dd6ecfb33903a92c6fc0da56e88/68747470733a2f2f706f7365722e707567782e6f72672f7068707374616e2f7068707374616e2d6d6f636b6572792f762f737461626c65)](https://packagist.org/packages/phpstan/phpstan-mockery)[![License](https://camo.githubusercontent.com/a8a5c5443f5b44810f1e1fa564e6c807d5835970b087a59e5d3b9f5e169bad44/68747470733a2f2f706f7365722e707567782e6f72672f7068707374616e2f7068707374616e2d6d6f636b6572792f6c6963656e7365)](https://packagist.org/packages/phpstan/phpstan-mockery)

- [PHPStan](https://phpstan.org/)
- [Mockery](https://github.com/mockery/mockery)

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](https://phpstan.org/blog/union-types-vs-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
------------

[](#installation)

To use this extension, require it in [Composer](https://getcomposer.org/):

```
composer require --dev phpstan/phpstan-mockery

```

If you also install [phpstan/extension-installer](https://github.com/phpstan/extension-installer) then you're all set!

 Manual installationIf 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

```

###  Health Score

68

—

FairBetter than 99% of packages

Maintenance69

Regular maintenance activity

Popularity65

Solid adoption and visibility

Community50

Growing community involvement

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 59.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~99 days

Recently: every ~224 days

Total

30

Last Release

9d ago

Major Versions

0.12.14 → 1.0.02021-09-20

1.1.x-dev → 2.0.02024-10-14

PHP version history (4 changes)0.10PHP ~7.1

0.12.7PHP ^7.1 || ^8.0

1.1.0PHP ^7.2 || ^8.0

2.0.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/104888?v=4)[Ondřej Mirtes](/maintainers/ondrejmirtes)[@ondrejmirtes](https://github.com/ondrejmirtes)

---

Top Contributors

[![ondrejmirtes](https://avatars.githubusercontent.com/u/104888?v=4)](https://github.com/ondrejmirtes "ondrejmirtes (95 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (23 commits)")[![renovate-bot](https://avatars.githubusercontent.com/u/25180681?v=4)](https://github.com/renovate-bot "renovate-bot (10 commits)")[![ruudk](https://avatars.githubusercontent.com/u/104180?v=4)](https://github.com/ruudk "ruudk (5 commits)")[![staabm](https://avatars.githubusercontent.com/u/120441?v=4)](https://github.com/staabm "staabm (3 commits)")[![Kocal](https://avatars.githubusercontent.com/u/2103975?v=4)](https://github.com/Kocal "Kocal (3 commits)")[![localheinz](https://avatars.githubusercontent.com/u/605483?v=4)](https://github.com/localheinz "localheinz (3 commits)")[![bbatsche](https://avatars.githubusercontent.com/u/500909?v=4)](https://github.com/bbatsche "bbatsche (2 commits)")[![msvrtan](https://avatars.githubusercontent.com/u/1780572?v=4)](https://github.com/msvrtan "msvrtan (2 commits)")[![simPod](https://avatars.githubusercontent.com/u/327717?v=4)](https://github.com/simPod "simPod (1 commits)")[![step-security-bot](https://avatars.githubusercontent.com/u/89328645?v=4)](https://github.com/step-security-bot "step-security-bot (1 commits)")[![TomasVotruba](https://avatars.githubusercontent.com/u/924196?v=4)](https://github.com/TomasVotruba "TomasVotruba (1 commits)")[![villfa](https://avatars.githubusercontent.com/u/2891564?v=4)](https://github.com/villfa "villfa (1 commits)")[![adaamz](https://avatars.githubusercontent.com/u/4347332?v=4)](https://github.com/adaamz "adaamz (1 commits)")[![wimski](https://avatars.githubusercontent.com/u/12373573?v=4)](https://github.com/wimski "wimski (1 commits)")[![barryvdh](https://avatars.githubusercontent.com/u/973269?v=4)](https://github.com/barryvdh "barryvdh (1 commits)")[![Chris53897](https://avatars.githubusercontent.com/u/7104259?v=4)](https://github.com/Chris53897 "Chris53897 (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![fancyweb](https://avatars.githubusercontent.com/u/3658119?v=4)](https://github.com/fancyweb "fancyweb (1 commits)")[![herndlm](https://avatars.githubusercontent.com/u/5738896?v=4)](https://github.com/herndlm "herndlm (1 commits)")

---

Tags

mockeryphpphp7phpstanstatic-analysisstatic-code-analysis

###  Code Quality

TestsPHPUnit

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phpstan-phpstan-mockery/health.svg)

```
[![Health](https://phpackages.com/badges/phpstan-phpstan-mockery/health.svg)](https://phpackages.com/packages/phpstan-phpstan-mockery)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.5k55.4M8.4k](/packages/larastan-larastan)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

79475.7M2.2k](/packages/phpstan-phpstan-symfony)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

67272.8M1.4k](/packages/phpstan-phpstan-doctrine)[shipmonk/dead-code-detector

Dead code detector to find unused PHP code via PHPStan extension. Can automatically remove dead PHP code. Supports libraries like Symfony, Doctrine, PHPUnit etc. Detects dead cycles. Can detect dead code that is tested.

4853.5M91](/packages/shipmonk-dead-code-detector)[spaze/phpstan-disallowed-calls

PHPStan rules to detect disallowed method &amp; function calls, constant, namespace, attribute, property &amp; superglobal usages, with powerful rules to re-allow a call or a usage in places where it should be allowed.

33422.6M550](/packages/spaze-phpstan-disallowed-calls)[tomasvotruba/cognitive-complexity

PHPStan rules to measure cognitive complexity of your classes and methods

1635.6M288](/packages/tomasvotruba-cognitive-complexity)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
