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

Invalid version string for some default PHP version naming scheme #125

Closed
lcharette opened this issue Mar 14, 2021 · 3 comments
Closed

Invalid version string for some default PHP version naming scheme #125

lcharette opened this issue Mar 14, 2021 · 3 comments

Comments

@lcharette
Copy link

We're currently using the equivalent of this line of code :

$satisfies = Semver::satisfies(phpversion(), '^7.2');

Issue is, our CI returns this php version (which is technically invalid I know) : 7.2.34-18+ubuntu20.04.1+deb.sury.org+1. So when running Unit/Feature Tests CI fails with this error :

Invalid version string "7.2.34-18+ubuntu20.04.1+deb.sury.org+1"  

VersionParser::normalize basically ends as 7.2.34-18 instead of 7.2.34.

I know technically it's the PHP version that is at fault here, but this is a common naming scheme from packaged provided PHP on some distro. Even if we were to change our test to go around, the issue would still arise for some users when using this code on their server with this kind of version scheme (and somehow Composer itself doesn't complain about it...?)

@stof
Copy link
Contributor

stof commented Mar 14, 2021

the reason why composer does not complain is because it has a special handling for such weird php versions: https://github.com/composer/composer/blob/b6826f352390b4c952be8fd75d60cfd4f6f39f11/src/Composer/Repository/PlatformRepository.php#L97-L103

This is not something implemented in the composer/semver package, because that would allow such weird versioning scheme for all packages out there (thus, that's not semver anymore)

@stof
Copy link
Contributor

stof commented Mar 14, 2021

bote that for your use case about checking only for being higher than a given PHP version, you could do a check on PHP_VERSION_ID instead of matching a semver constraint against phpversion() and having to deal with cleaning it.

@lcharette
Copy link
Author

Thanks for the quick reply and pointing me in the right direction. I'll probably got the PHP_VERSION_ID or Composer like route.

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

2 participants