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

Version expansion for Packagist #230

Closed
oliverchang opened this issue Sep 28, 2021 · 2 comments · Fixed by #675
Closed

Version expansion for Packagist #230

oliverchang opened this issue Sep 28, 2021 · 2 comments · Fixed by #675
Labels
infra infrastructure bugs/FRs

Comments

@oliverchang
Copy link
Collaborator

Packagist recommends, but does not enforce Semver

@oliverchang
Copy link
Collaborator Author

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.

@oliverchang
Copy link
Collaborator Author

oliverchang commented Feb 15, 2022

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

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

Successfully merging a pull request may close this issue.

1 participant