Skip to content

Commit 8313c32

Browse files
committed
register ReplaceAtMethodWithDesiredMatcherRector to code-quality
1 parent 0c028c6 commit 8313c32

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

config/sets/phpunit-code-quality.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\UseSpecificWillMethodRector;
4747
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\UseSpecificWithMethodRector;
4848
use Rector\PHPUnit\PHPUnit60\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector;
49+
use Rector\PHPUnit\PHPUnit90\Rector\MethodCall\ReplaceAtMethodWithDesiredMatcherRector;
4950

5051
return static function (RectorConfig $rectorConfig): void {
5152
$rectorConfig->rules([
@@ -119,5 +120,6 @@
119120
// prefer simple mocking
120121
GetMockBuilderGetMockToCreateMockRector::class,
121122
EntityDocumentCreateMockToDirectNewRector::class,
123+
ReplaceAtMethodWithDesiredMatcherRector::class,
122124
]);
123125
};

rules/PHPUnit90/Rector/MethodCall/ReplaceAtMethodWithDesiredMatcherRector.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PhpParser\Node;
88
use PhpParser\Node\Arg;
99
use PhpParser\Node\Expr\MethodCall;
10-
use PhpParser\Node\Identifier;
1110
use PhpParser\Node\Scalar\Int_;
1211
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
1312
use Rector\Rector\AbstractRector;
@@ -21,8 +20,7 @@ final class ReplaceAtMethodWithDesiredMatcherRector extends AbstractRector
2120
{
2221
public function __construct(
2322
private readonly TestsNodeAnalyzer $testsNodeAnalyzer
24-
)
25-
{
23+
) {
2624
}
2725

2826
public function getRuleDefinition(): RuleDefinition
@@ -60,11 +58,11 @@ public function getNodeTypes(): array
6058
*/
6159
public function refactor(Node $node): null|MethodCall
6260
{
63-
if (!$this->testsNodeAnalyzer->isInTestClass($node)) {
61+
if (! $this->testsNodeAnalyzer->isInTestClass($node)) {
6462
return null;
6563
}
6664

67-
if (!$node->var instanceof MethodCall) {
65+
if (! $node->var instanceof MethodCall) {
6866
return null;
6967
}
7068

@@ -73,7 +71,7 @@ public function refactor(Node $node): null|MethodCall
7371
return null;
7472
}
7573

76-
if (!$arg->value instanceof MethodCall) {
74+
if (! $arg->value instanceof MethodCall) {
7775
return null;
7876
}
7977

@@ -84,7 +82,7 @@ public function refactor(Node $node): null|MethodCall
8482
}
8583
}
8684

87-
if (!isset($count)) {
85+
if (! isset($count)) {
8886
return null;
8987
}
9088

0 commit comments

Comments
 (0)