Skip to content

Commit

Permalink
Fix normalizeStability return type to enforce valid stabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek authored Jul 12, 2024
1 parent a40ea7e commit 106a346
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/VersionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,16 @@ public static function parseStability($version)
* @param string $stability
*
* @return string
* @phpstan-return 'stable'|'RC'|'beta'|'alpha'|'dev'
*/
public static function normalizeStability($stability)
{
$stability = strtolower((string) $stability);

if (!in_array($stability, ['stable', 'rc', 'beta', 'alpha', 'dev'], true)) {
throw new \InvalidArgumentException('Invalid stability string "'.$stability.'", expected one of stable, RC, beta, alpha or dev');
}

return $stability === 'rc' ? 'RC' : $stability;
}

Expand Down

0 comments on commit 106a346

Please sign in to comment.