Skip to content

Commit

Permalink
[Performance] Using findFirst() for cast to (bool) so no need search …
Browse files Browse the repository at this point in the history
…all found nodes (#3642)

* [Performance] Using findFirst() for cast to (bool) so no need search all found node

* rollback negation

* findFirst should be ok for negation, since it can return true on found
  • Loading branch information
samsonasik committed May 8, 2023
1 parent 49e79bd commit 814aa5b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private function findPreviousAssignToArrayKeys(FuncCall $funcCall, Expr $expr):
}

if (! $node instanceof Assign) {
return ! (bool) $this->betterNodeFinder->find(
return ! (bool) $this->betterNodeFinder->findFirst(
$node,
fn (Node $subNode): bool => $this->nodeComparator->areNodesEqual($expr, $subNode)
);
Expand Down
2 changes: 1 addition & 1 deletion src/NodeManipulator/ClassConstManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function hasClassConstFetch(ClassConst $classConst, ClassReflection $clas
}

// has in class?
$isClassConstFetchFound = (bool) $this->betterNodeFinder->find($ancestorClass, function (Node $node) use (
$isClassConstFetchFound = (bool) $this->betterNodeFinder->findFirst($ancestorClass, function (Node $node) use (
$classConst,
$className
): bool {
Expand Down

0 comments on commit 814aa5b

Please sign in to comment.