Skip to content

Commit 086649a

Browse files
marmichalskiclaude
andauthored
docs: document Rector rule in README (#166)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent b1077fd commit 086649a

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,22 @@ lendable_phpunit:
5050
pardoned:
5151
- Foo\Bar\MyTest
5252
```
53+
54+
## Rector
55+
56+
A [Rector](https://getrector.com/) rule is provided to automate adopting strict mocking across a test suite.
57+
58+
`Lendable\PHPUnitExtensions\Rector\EnforceDisableReturnValueGenerationForTestDoublesRector` adds PHPUnit's `#[DisableReturnValueGenerationForTestDoubles]` attribute to test classes that do not already have it. Abstract classes are skipped, since the attribute only has an effect when placed on the concrete test class.
59+
60+
Register the rule in your Rector configuration:
61+
62+
```php
63+
use Lendable\PHPUnitExtensions\Rector\EnforceDisableReturnValueGenerationForTestDoublesRector;
64+
use Rector\Config\RectorConfig;
65+
66+
return RectorConfig::configure()
67+
// ...
68+
->withRules([EnforceDisableReturnValueGenerationForTestDoublesRector::class]);
69+
```
70+
71+
With the closure-style configuration, register it via `$rectorConfig->rule(EnforceDisableReturnValueGenerationForTestDoublesRector::class)`.

0 commit comments

Comments
 (0)