Skip to content

Commit

Permalink
Fix wrong error when function is rebound.
Browse files Browse the repository at this point in the history
  • Loading branch information
muno92 authored and ondrejmirtes committed Aug 26, 2022
1 parent 1f3b649 commit 431b3d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Rules/Functions/ClosureUsesThisRule.php
Expand Up @@ -27,6 +27,10 @@ public function processNode(Node $node, Scope $scope): array
return [];
}

if ($scope->isInClosureBind()) {
return [];
}

$messages = [];
foreach ($node->uses as $closureUse) {
$varType = $scope->getType($closureUse->var);
Expand Down
5 changes: 4 additions & 1 deletion tests/Rules/Functions/data/closure-uses-this.php
Expand Up @@ -21,6 +21,9 @@ public function doFoo()
$f = static function () use ($that) { // ok

};
}

$f = \Closure::bind(function () use ($that) { // ok

}, null, Foo::class);
}
}

0 comments on commit 431b3d6

Please sign in to comment.