Skip to content

Commit 7e97b9e

Browse files
authored
Iterate in getBooleanExpressionDepth() (#6091)
1 parent f08b63f commit 7e97b9e

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

‎src/Analyser/ExprHandler/BooleanAndHandler.php‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,18 @@ public function specifyTypes(TypeSpecifier $typeSpecifier, Scope $scope, Expr $e
162162
return $types;
163163
}
164164

165-
public static function getBooleanExpressionDepth(Expr $expr, int $depth = 0): int
165+
public static function getBooleanExpressionDepth(Expr $expr): int
166166
{
167+
$depth = 0;
167168
while (
168-
$expr instanceof BooleanOr
169-
|| $expr instanceof LogicalOr
170-
|| $expr instanceof BooleanAnd
171-
|| $expr instanceof LogicalAnd
169+
$expr instanceof BooleanOr ||
170+
$expr instanceof LogicalOr ||
171+
$expr instanceof BooleanAnd ||
172+
$expr instanceof LogicalAnd
172173
) {
173-
return self::getBooleanExpressionDepth($expr->left, $depth + 1);
174+
$depth++;
175+
$expr = $expr->left;
174176
}
175-
176177
return $depth;
177178
}
178179

0 commit comments

Comments
 (0)