This extension provides following features:
createMock(),getMockForAbstractClass()andgetMockFromWsdl()methods return an intersection type of the mock object and the mocked class so that both methods from the mock object (likeexpects) and from the mocked class are available on the object.getMock()called onMockBuilderis also supported.- Interprets
Foo|PHPUnit_Framework_MockObject_MockObjectin phpDoc so that it results in an intersection type instead of a union type. - Defines early terminating method calls for the
PHPUnit\Framework\TestCaseclass to prevent undefined variable errors.
It also contains this framework-specific rule (can be enabled separately):
- Check that both values passed to
assertSame()method are of the same type.
To use this extension, require it in Composer:
composer require --dev phpstan/phpstan-phpunitAnd include extension.neon in your project's PHPStan config:
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
To perform framework-specific checks, include also this file:
- vendor/phpstan/phpstan-phpunit/rules.neon