You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add documentation for features present in src/ and rules.neon that
were not listed in the README:
Core features:
- createMockForIntersectionOfInterfaces() / createStubForIntersectionOfInterfaces()
Strict rules:
- @Covers / @coversDefaultClass annotation validation
- Mock method call existence checking
- setUp() / tearDown() parent method call enforcement
- Data provider declaration validation
- Data provider data validation (bleeding edge)
- #[RequiresPhp] attribute format validation
- PHPUnit annotation spacing checks
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@ This extension provides following features:
11
11
12
12
*`createMock()`, `getMockForAbstractClass()` and `getMockFromWsdl()` methods return an intersection type (see the [detailed explanation of intersection types](https://phpstan.org/blog/union-types-vs-intersection-types)) 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.
13
13
*`getMock()` called on `MockBuilder` is also supported.
14
+
*`createMockForIntersectionOfInterfaces()` and `createStubForIntersectionOfInterfaces()` return correct intersection types.
14
15
* Interprets `Foo|MockObject` in phpDoc so that it results in an intersection type instead of a union type.
15
16
* Defines early terminating method calls for the `PHPUnit\Framework\TestCase` class to prevent undefined variable errors.
16
17
* Specifies types of expressions passed to various `assert` methods like `assertInstanceOf`, `assertTrue`, `assertInternalType` etc.
@@ -24,6 +25,13 @@ It also contains this strict framework-specific rules (can be enabled separately
24
25
* Check that you are not using `assertSame()` with `count($variable)` as second parameter. `assertCount($variable)` should be used instead.
25
26
* Check that you are not using `assertEquals()` with same types (`assertSame()` should be used)
26
27
* Check that you are not using `assertNotEquals()` with same types (`assertNotSame()` should be used)
28
+
* Validate `@covers` and `@coversDefaultClass` annotations reference existing classes, methods, and functions.
29
+
* Check that methods called on mock objects via `->method('...')` exist on the mocked class.
30
+
* Check that `setUp()` and `tearDown()` call their parent methods.
31
+
* Validate data provider declarations (method existence, naming, static requirement in PHPUnit 10+).
32
+
* Validate data provider return data matches test method parameters (bleeding edge).
33
+
* Validate `#[RequiresPhp]` attribute format.
34
+
* Check for proper spacing in PHPUnit annotations.
0 commit comments