Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VersionParser->normalize() returns invalid versions #135

Open
grasmash opened this issue May 6, 2022 · 3 comments
Open

VersionParser->normalize() returns invalid versions #135

grasmash opened this issue May 6, 2022 · 3 comments

Comments

@grasmash
Copy link

grasmash commented May 6, 2022

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:

$version = $matches[1]

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?

@stof
Copy link
Contributor

stof commented May 6, 2022

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.

@grasmash
Copy link
Author

grasmash commented May 6, 2022

Ok. That makes sense, though it's interesting that it does not in fact conform to the SemVer standard. Is that documented?

@Seldaek
Copy link
Member

Seldaek commented May 6, 2022

Probably not. Normalize output is used as an internal representation and almost never shown to users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants