Skip to content

Commit db11aa5

Browse files
authored
[Performance] [TypeDeclaration] Reduce double traverse on SilentVoidResolver::hasExclusiveVoid() (#6255)
* [TypeDeclaration] Reduce double traverse on SilentVoidResolver::hasExclusiveVoid() * clean up
1 parent 1884cdd commit db11aa5

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

rules/TypeDeclaration/TypeInferer/SilentVoidResolver.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,16 @@ public function hasExclusiveVoid(ClassMethod | Closure | Function_ $functionLike
5656
return false;
5757
}
5858

59-
if ($this->betterNodeFinder->hasInstancesOfInFunctionLikeScoped(
59+
return ! (bool) $this->betterNodeFinder->findFirstInFunctionLikeScoped(
6060
$functionLike,
61-
[Yield_::class, YieldFrom::class]
62-
)) {
63-
return false;
64-
}
61+
function (Node $subNode): bool {
62+
if ($subNode instanceof Yield_ || $subNode instanceof YieldFrom) {
63+
return true;
64+
}
6565

66-
$return = $this->betterNodeFinder->findFirstInFunctionLikeScoped(
67-
$functionLike,
68-
static fn (Node $node): bool => $node instanceof Return_ && $node->expr instanceof Expr
66+
return $subNode instanceof Return_ && $subNode->expr instanceof Expr;
67+
}
6968
);
70-
return ! $return instanceof Return_;
7169
}
7270

7371
public function hasSilentVoid(FunctionLike $functionLike): bool

0 commit comments

Comments
 (0)