VersionParser->normalize() returns invalid versions
I find that running $version_parser->normalize('1.30.1'); will return 1.30.1.0. That's not valid SemVer. It stems from this:
https://github.com/composer/semver/blob/3953f23262f2bff1919fc82183ad9acb13ff62c9/src/VersionParser.php#L138
I suspect that I'm missing something, because this seems like too much of a bug for me to have been the first one to have noticed it. Am I missing something?
Well, composer supports 4 segments in the version since day one. Reducing that to 3 segments only would be a huge risk for the ecosystem.
The goal of normalizing versions to always have the same number of segments is because PHP's version_compare does not handle properly comparing versions with different number of segments.
Ok. That makes sense, though it's interesting that it does not in fact conform to the SemVer standard. Is that documented?
Probably not. Normalize output is used as an internal representation and almost never shown to users.