Skip to content

Commit db6631d

Browse files
committed
[rector] Rector fixes
1 parent 660eece commit db6631d

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

rules-tests/PHPUnit120/Rector/MethodCall/ExplicitMockExpectsCallRector/config/configured_rule.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
declare(strict_types=1);
44

5+
use Rector\PHPUnit\PHPUnit120\Rector\MethodCall\ExplicitMockExpectsCallRector;
56
use Rector\Config\RectorConfig;
67

78
return RectorConfig::configure()
8-
->withRules([\Rector\PHPUnit\PHPUnit120\Rector\MethodCall\ExplicitMockExpectsCallRector::class]);
9+
->withRules([ExplicitMockExpectsCallRector::class]);

rules/PHPUnit120/Rector/MethodCall/ExplicitMockExpectsCallRector.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
namespace Rector\PHPUnit\PHPUnit120\Rector\MethodCall;
66

7+
use PhpParser\Node\Expr\MethodCall;
8+
use PhpParser\Node\Expr\Variable;
9+
use PhpParser\Node\Expr\PropertyFetch;
10+
use PhpParser\Node\Arg;
711
use PhpParser\Node;
812
use PHPStan\Type\ObjectType;
913
use Rector\PHPUnit\Enum\PHPUnitClassName;
@@ -64,19 +68,19 @@ public function testMe()
6468
*/
6569
public function getNodeTypes(): array
6670
{
67-
return [Node\Expr\MethodCall::class];
71+
return [MethodCall::class];
6872
}
6973

7074
/**
71-
* @param Node\Expr\MethodCall $node
75+
* @param MethodCall $node
7276
*/
7377
public function refactor(Node $node): Node|null
7478
{
7579
if (! $this->testsNodeAnalyzer->isInTestClass($node)) {
7680
return null;
7781
}
7882

79-
if (! $node->var instanceof Node\Expr\Variable && ! $node->var instanceof Node\Expr\PropertyFetch) {
83+
if (! $node->var instanceof Variable && ! $node->var instanceof PropertyFetch) {
8084
return null;
8185
}
8286

@@ -88,8 +92,8 @@ public function refactor(Node $node): Node|null
8892
return null;
8993
}
9094

91-
$node->var = new Node\Expr\MethodCall($node->var, 'expects', [
92-
new Node\Arg(new Node\Expr\MethodCall(new Node\Expr\Variable('this'), 'atLeastOnce')),
95+
$node->var = new MethodCall($node->var, 'expects', [
96+
new Arg(new MethodCall(new Variable('this'), 'atLeastOnce')),
9397
]);
9498

9599
return $node;

0 commit comments

Comments
 (0)