Skip to content

Commit 91e3be0

Browse files
committed
fixes
1 parent a1789e8 commit 91e3be0

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

rules/CodingStyle/Rector/Closure/StaticClosureRector.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use PhpParser\Node\Expr\Closure;
99
use Rector\CodingStyle\Guard\StaticGuard;
1010
use Rector\NodeTypeResolver\Node\AttributeKey;
11-
use Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor\CallLikeThisBoundClosureArgsNodeVisitor;
1211
use Rector\Rector\AbstractRector;
1312
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
1413
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -66,7 +65,7 @@ public function getNodeTypes(): array
6665
*/
6766
public function refactor(Node $node): ?Node
6867
{
69-
if ($node->hasAttribute(AttributeKey::CLOSURE_USES_THIS)) {
68+
if ($node->hasAttribute(AttributeKey::IS_CLOSURE_USES_THIS)) {
7069
return null;
7170
}
7271

src/NodeAnalyzer/CallLikeExpectsThisBindedClosureArgsAnalyzer.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use PhpParser\Node\Expr\CallLike;
99
use PhpParser\Node\Expr\Closure;
1010
use PHPStan\Reflection\ExtendedParameterReflection;
11-
use Rector\NodeTypeResolver\Node\AttributeKey;
1211
use Rector\NodeTypeResolver\PHPStan\ParametersAcceptorSelectorVariantsWrapper;
1312
use Rector\PHPStan\ScopeFetcher;
1413
use Rector\Reflection\ReflectionResolver;
@@ -36,8 +35,7 @@ public function getArgsUsingThisBindedClosure(CallLike $callLike): array
3635
return [];
3736
}
3837

39-
$scope = $callLike->getAttribute(AttributeKey::SCOPE);
40-
38+
$scope = ScopeFetcher::fetch($callLike);
4139
$parametersAcceptor = ParametersAcceptorSelectorVariantsWrapper::select($reflection, $callLike, $scope);
4240
$parameters = $parametersAcceptor->getParameters();
4341

src/NodeTypeResolver/Node/AttributeKey.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,5 +289,5 @@ final class AttributeKey
289289

290290
public const PHP_VERSION_CONDITIONED = 'php_version_conditioned';
291291

292-
public const CLOSURE_USES_THIS = 'has_this_closure';
292+
public const IS_CLOSURE_USES_THIS = 'has_this_closure';
293293
}

src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/CallLikeThisBoundClosureArgsNodeVisitor.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor;
46

57
use PhpParser\Node;
@@ -8,7 +10,6 @@
810
use PhpParser\Node\Expr\MethodCall;
911
use PhpParser\Node\Expr\StaticCall;
1012
use PhpParser\NodeVisitorAbstract;
11-
use PHPStan\Type\Type;
1213
use Rector\Contract\PhpParser\DecoratingNodeVisitorInterface;
1314
use Rector\NodeAnalyzer\CallLikeExpectsThisBindedClosureArgsAnalyzer;
1415
use Rector\NodeTypeResolver\Node\AttributeKey;
@@ -17,8 +18,7 @@ class CallLikeThisBoundClosureArgsNodeVisitor extends NodeVisitorAbstract implem
1718
{
1819
public function __construct(
1920
private readonly CallLikeExpectsThisBindedClosureArgsAnalyzer $callLikeExpectsThisBindedClosureArgsAnalyzer
20-
)
21-
{
21+
) {
2222
}
2323

2424
public function enterNode(Node $node): ?Node
@@ -42,8 +42,8 @@ public function enterNode(Node $node): ?Node
4242
}
4343

4444
foreach ($args as $arg) {
45-
if ($arg->value instanceof Closure && ! $arg->hasAttribute(AttributeKey::CLOSURE_USES_THIS)) {
46-
$arg->value->setAttribute(AttributeKey::CLOSURE_USES_THIS, true);
45+
if ($arg->value instanceof Closure && ! $arg->hasAttribute(AttributeKey::IS_CLOSURE_USES_THIS)) {
46+
$arg->value->setAttribute(AttributeKey::IS_CLOSURE_USES_THIS, true);
4747
}
4848
}
4949

0 commit comments

Comments
 (0)