Skip to content

Commit 431b3d6

Browse files
muno92ondrejmirtes
authored andcommitted
Fix wrong error when function is rebound.
1 parent 1f3b649 commit 431b3d6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Rules/Functions/ClosureUsesThisRule.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ public function processNode(Node $node, Scope $scope): array
2727
return [];
2828
}
2929

30+
if ($scope->isInClosureBind()) {
31+
return [];
32+
}
33+
3034
$messages = [];
3135
foreach ($node->uses as $closureUse) {
3236
$varType = $scope->getType($closureUse->var);

tests/Rules/Functions/data/closure-uses-this.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public function doFoo()
2121
$f = static function () use ($that) { // ok
2222

2323
};
24-
}
2524

25+
$f = \Closure::bind(function () use ($that) { // ok
26+
27+
}, null, Foo::class);
28+
}
2629
}

0 commit comments

Comments
 (0)