Download the PHP package brainbits/phpstan-rules without Composer
On this page you can find all versions of the php package brainbits/phpstan-rules. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download brainbits/phpstan-rules
More information about brainbits/phpstan-rules
Files in brainbits/phpstan-rules
Package phpstan-rules
Short Description PHPStan extension with opinionated strict rules for better code in tests.
License MIT
Homepage https://github.com/brainbits/phpstan-rules
Informations about the package phpstan-rules
PHPStan Clean Test rules
This extension provides highly opinionated and strict rules for test cases for the PHPStan static analysis tool.
Installation
Run
Usage
All of the rules provided by this library are included in rules.neon
.
When you are using phpstan/extension-installer
, rules.neon
will be automatically included.
Otherwise you need to include rules.neon
in your phpstan.neon
:
Rules
This package provides the following rules for use with phpstan/phpstan
:
Brainbits\PHPStan\Rules\CoversClassExistsRule
Brainbits\PHPStan\Rules\CoversClassPresentRule
CoversClassExistsRule
This rule checks that classes that are covered by @covers
annotation or #[CoversClass]
attribute exist.
CoversClassPresentRule
This rule forces you to specify either a @covers
annotation or #[CoversClass]
, #[CoversFunction]
or #[CoversNothing]
attributes in unit tests (default: PHPUnit\Framework\TestCase
).
Why:
- It prevents code coverage sums to show higher values than expected.
:x:
:white_check_mark:
Defaults
- By default, this rule detects unit tests by checking the namespace (it must contain the string
Unit
) and the class name ending (it must end with the stringTest
).
Detecting unit tests namespace
If you want to change the namespace string check described above, you can set your own string to be checked in the unitTestNamespaceContainsString
parameter.
All versions of phpstan-rules with dependencies
nette/utils Version ^4.0
nikic/php-parser Version ^4.3|^5.0
phpstan/phpstan Version ^1.0