Skip to content

Commit 3f2b7a0

Browse files
author
Stephan Wentz
committed
docs: Document new attribute behaviour and new rules
1 parent 4c3a07a commit 3f2b7a0

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,16 @@ includes:
3636
## Rules
3737
3838
This package provides the following rules for use with [`phpstan/phpstan`](https://github.com/phpstan/phpstan):
39-
- [`Brainbits\PHPStan\Rules\CoversAnnotationRule`](#coversannotationrule)
39+
- [`Brainbits\PHPStan\Rules\CoversClassExistsRule`](#CoversClassExistsRule)
40+
- [`Brainbits\PHPStan\Rules\CoversClassPresentRule`](#CoversClassPresentRule)
4041

41-
### `CoversAnnotationRule`
42+
### `CoversClassExistsRule`
4243

43-
This rule forces you to specify a @covers or @coversDefaultClass annotation in unit tests (default: `PHPUnit\Framework\TestCase`).
44+
This rule checks that classes that are covered by `@covers` annotation or `#[CoversClass]` attribute exist.
45+
46+
### `CoversClassPresentRule`
47+
48+
This rule forces you to specify either a `@covers` annotation or `#[CoversClass]`, `#[CoversFunction]` or `#[CoversNothing]` attributes in unit tests (default: `PHPUnit\Framework\TestCase`).
4449

4550
**Why:**
4651
1. It prevents code coverage sums to show higher values than expected.
@@ -60,9 +65,8 @@ final class MyInvalidClassTest extends \PHPUnit\Framework\TestCase {}
6065
```php
6166
// tests/ExampleTestCase/Unit/MyClassTest.php
6267
namespace ExampleTestCase\Unit;
63-
/**
64-
* @covers MyClass
65-
*/
68+
69+
#[\PHPUnit\Framework\Attributes\CoversClass(MyClass::class)
6670
final class MyClassTest extends \PHPUnit\Framework\TestCase {}
6771
```
6872

0 commit comments

Comments
 (0)