Version expansion for Packagist
Packagist recommends, but does not enforce Semver
Composer's version parsing code appears to be here: https://github.com/composer/semver/blob/main/src/VersionParser.php, and diverges from strict SemVer in a number of ways.
Looks like version comparison eventualy calls PHP's built in version_compare after some normalization:
https://github.com/composer/semver/blob/a951f614bd64dcd26137bc9b7b2637ddcfc57649/src/Constraint/Constraint.php#L226
version_compare has some strange semantics:
The function first replaces _, - and + with a dot . in the version strings and also inserts dots . before and after any non number so that for example '4.3.2RC1' becomes '4.3.2.RC.1'. Then it compares the parts starting from left to right. If a part contains special version strings these are handled in the following order: any string not found in this list < dev < alpha = a < beta = b < RC = rc < # < pl = p. This way not only versions with different levels like '4.1' and '4.1.2' can be compared but also any PHP specific version containing development state.
The C implementation is here: https://github.com/php/php-src/blob/354c52e9b6d8d440144ff412157df80b73cd4cdd/ext/standard/versioning.c#L121