From 7b0927662058ea8c680f5bfa698c9dad7f444537 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Mon, 14 Dec 2020 00:09:25 +0100 Subject: [PATCH] Div returns only DivisionByZeroError --- src/Rules/ThrowsPhpDocRule.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Rules/ThrowsPhpDocRule.php b/src/Rules/ThrowsPhpDocRule.php index 077a298..cb4b388 100644 --- a/src/Rules/ThrowsPhpDocRule.php +++ b/src/Rules/ThrowsPhpDocRule.php @@ -698,21 +698,16 @@ private function processFuncCall(FuncCall $node, Scope $scope): array */ private function processDiv(Expr $divisor, Scope $scope): array { - $divisionByZero = false; $divisorType = $scope->getType($divisor); foreach (TypeUtils::getConstantScalars($divisorType) as $constantScalarType) { if ($constantScalarType->getValue() === 0) { - $divisionByZero = true; + return $this->processThrowsTypes(new ObjectType(DivisionByZeroError::class)); } $divisorType = TypeCombinator::remove($divisorType, $constantScalarType); } if (!$divisorType instanceof NeverType) { - return $this->processThrowsTypes(new ObjectType(ArithmeticError::class)); - } - - if ($divisionByZero) { return $this->processThrowsTypes(new ObjectType(DivisionByZeroError::class)); }