Skip to content

Commit f3d3bea

Browse files
authored
Refactor to stop using AbstractScopeAwareRector (#195)
1 parent af92469 commit f3d3bea

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

Diff for: src/Rector/FuncCall/RemoveRedundantValueCallsRector.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
use PhpParser\Node;
66
use PhpParser\Node\Expr\FuncCall;
77
use PhpParser\Node\Name;
8-
use PHPStan\Analyser\Scope;
98
use PHPStan\Type\ClosureType;
109
use PHPStan\Type\MixedType;
11-
use Rector\Rector\AbstractScopeAwareRector;
10+
use Rector\Rector\AbstractRector;
1211
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
1312
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
1413

1514
/**
1615
* @see \RectorLaravel\Tests\Rector\FuncCall\RemoveRedundantValueCallsRector\RemoveRedundantValueCallsRectorTest
1716
*/
18-
class RemoveRedundantValueCallsRector extends AbstractScopeAwareRector
17+
class RemoveRedundantValueCallsRector extends AbstractRector
1918
{
2019
public function getRuleDefinition(): RuleDefinition
2120
{
@@ -32,7 +31,7 @@ public function getNodeTypes(): array
3231
return [FuncCall::class];
3332
}
3433

35-
public function refactorWithScope(Node $node, Scope $scope): ?Node
34+
public function refactor(Node $node): ?Node
3635
{
3736
if (! $node instanceof FuncCall) {
3837
return null;
@@ -52,7 +51,7 @@ public function refactorWithScope(Node $node, Scope $scope): ?Node
5251
return null;
5352
}
5453

55-
if ($scope->getType($args[0]->value)->isSuperTypeOf(new ClosureType([], new MixedType, true))->no() === false) {
54+
if ($this->getType($args[0]->value)->isSuperTypeOf(new ClosureType([], new MixedType, true))->no() === false) {
5655
return null;
5756
}
5857

Diff for: src/Rector/FuncCall/RemoveRedundantWithCallsRector.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
use PhpParser\Node;
66
use PhpParser\Node\Expr\FuncCall;
77
use PhpParser\Node\Name;
8-
use PHPStan\Analyser\Scope;
9-
use Rector\Rector\AbstractScopeAwareRector;
8+
use Rector\Rector\AbstractRector;
109
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
1110
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
1211

1312
/**
1413
* @see \RectorLaravel\Tests\Rector\FuncCall\RemoveRedundantWithCallsRector\RemoveRedundantWithCallsRectorTest
1514
*/
16-
class RemoveRedundantWithCallsRector extends AbstractScopeAwareRector
15+
class RemoveRedundantWithCallsRector extends AbstractRector
1716
{
1817
public function getRuleDefinition(): RuleDefinition
1918
{
@@ -30,7 +29,7 @@ public function getNodeTypes(): array
3029
return [FuncCall::class];
3130
}
3231

33-
public function refactorWithScope(Node $node, Scope $scope): ?Node
32+
public function refactor(Node $node): ?Node
3433
{
3534
if (! $node instanceof FuncCall) {
3635
return null;
@@ -51,7 +50,7 @@ public function refactorWithScope(Node $node, Scope $scope): ?Node
5150
}
5251

5352
if (count($args) === 2) {
54-
$secondArgumentType = $scope->getType($args[1]->value);
53+
$secondArgumentType = $this->getType($args[1]->value);
5554

5655
if ($secondArgumentType->isCallable()->no() === false) {
5756
return null;

0 commit comments

Comments
 (0)