This extension provides following features:
createMock()
method returns 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.- Interprets
Foo|PHPUnit_Framework_MockObject_MockObject
in phpDoc so that it results in an intersection type instead of a union type. - Defines early terminating method calls for the
PHPUnit\Framework\TestCase
class 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-phpunit
And 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