Skip to content

Commit

Permalink
More verbose messages for IntegerRangeType
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed May 20, 2021
1 parent fc9191a commit d23b4b7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Type/VerbosityLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public static function getRecommendedLevelByType(Type $acceptingType, ?Type $acc
$moreVerbose = true;
return $type;
}
if ($type instanceof IntegerRangeType) {
$moreVerbose = true;
return $type;
}
return $traverse($type);
};

Expand Down
4 changes: 4 additions & 0 deletions tests/PHPStan/Rules/Methods/ReturnTypeRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ public function testBug3997(): void
'Method Bug3997\Lorem::count() should return int but returns string.',
48,
],
[
'Method Bug3997\Dolor::count() should return int<0, max> but returns -1.',
72,
],
]);
}

Expand Down
11 changes: 11 additions & 0 deletions tests/PHPStan/Rules/Methods/data/bug-3997.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,14 @@ public function count()
}

}

class Dolor implements Countable
{

/** @return positive-int|0 */
public function count(): int
{
return -1;
}

}

0 comments on commit d23b4b7

Please sign in to comment.