Skip to content

Commit

Permalink
Div returns only DivisionByZeroError
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Dec 23, 2020
1 parent e62cf84 commit 7b09276
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/Rules/ThrowsPhpDocRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down

0 comments on commit 7b09276

Please sign in to comment.