Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phpstan/phpstan-mockery
PHPStan extension for Mockery
https://github.com/phpstan/phpstan-mockery
mockery php php7 phpstan static-analysis static-code-analysis
Last synced: 4 days ago
JSON representation
PHPStan extension for Mockery
- Host: GitHub
- URL: https://github.com/phpstan/phpstan-mockery
- Owner: phpstan
- Created: 2018-07-26T18:19:30.000Z (over 6 years ago)
- Default Branch: 1.1.x
- Last Pushed: 2024-03-28T15:44:10.000Z (10 months ago)
- Last Synced: 2024-04-14T05:41:30.791Z (9 months ago)
- Topics: mockery, php, php7, phpstan, static-analysis, static-code-analysis
- Language: PHP
- Size: 129 KB
- Stars: 77
- Watchers: 5
- Forks: 19
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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://poser.pugx.org/phpstan/phpstan-mockery/v/stable)](https://packagist.org/packages/phpstan/phpstan-mockery)
[![License](https://poser.pugx.org/phpstan/phpstan-mockery/license)](https://packagist.org/packages/phpstan/phpstan-mockery)* [PHPStan](https://phpstan.org/)
* [Mockery](https://github.com/mockery/mockery)This extension provides the following features:
* Interprets `Foo|\Mockery\MockInterface` in phpDoc so that it results in an intersection type instead of a union type.
* `Mockery::mock()` and `Mockery::spy()` return an intersection type (see the [detailed explanation of intersection types](https://phpstan.org/blog/union-types-vs-intersection-types)) so that the returned object can be used as both the mock object and the mocked class object.
* `shouldReceive()`, `allows()` and `expects()` methods can be called on the mock object and they work as expected.## 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 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
```