Skip to content

Commit

Permalink
[CodeQuality] Reduce parent lookup for inside Closure BindTo on Local…
Browse files Browse the repository at this point in the history
…PropertyAnalyzer (#4231)

* [CodeQuality] Reduce parent lookup for inside Closure BindTo on LocalPropertyAnalyzer

* [ci-review] Rector Rectify

---------

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
samsonasik and actions-user committed Jun 14, 2023
1 parent e55d6b3 commit dfa6e77
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions rules/CodeQuality/NodeAnalyzer/LocalPropertyAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,7 @@ private function shouldSkipPropertyFetch(PropertyFetch $propertyFetch): bool
return true;
}

if ($propertyFetch->name instanceof Variable) {
return true;
}

return $this->isPartOfClosureBindTo($propertyFetch);
return $propertyFetch->name instanceof Variable;
}

/**
Expand Down Expand Up @@ -184,18 +180,4 @@ private function isPartOfClosureBind(PropertyFetch $propertyFetch): bool

return $scope->isInClosureBind();
}

private function isPartOfClosureBindTo(PropertyFetch $propertyFetch): bool
{
$parentMethodCall = $this->betterNodeFinder->findParentType($propertyFetch, MethodCall::class);
if (! $parentMethodCall instanceof MethodCall) {
return false;
}

if (! $parentMethodCall->var instanceof Closure) {
return false;
}

return $this->nodeNameResolver->isName($parentMethodCall->name, 'bindTo');
}
}

0 comments on commit dfa6e77

Please sign in to comment.