Skip to content

sascha-egerer/phpstan-phpunit

 
 

Repository files navigation

PHPStan PHPUnit extensions and rules

Build Status Latest Stable Version License

This extension provides following features:

  • createMock(), getMockForAbstractClass() and getMockFromWsdl() methods return an intersection type of the mock object and the mocked class so that both methods from the mock object (like expects) and from the mocked class are available on the object.
  • getMock() called on MockBuilder is also supported.
  • 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.

Usage

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

About

PHPUnit extensions and rules for PHPStan

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%