adambanaszkiewicz / semver-converter

Converts SemVer version (like Composer packages) into integer version with operators. Helps managing versions: store, compare, sort and retrive by conditions.
MIT License
5 stars 1 forks source link

Add symfony kernel id compatibility (different zero sizes for segments) #1

Open c33s opened 3 years ago

c33s commented 3 years ago

symfonys kernel version and id:

    const VERSION = '5.2.0';
    const VERSION_ID = 50200;

so its 1 zero, 2 zeros, 2 zeros as far as i understand your nice lib.

adambanaszkiewicz commented 3 years ago

Is it really that way? Symfony version is the same Semantic Versioning as the Github provides: https://semver.org/ - and my lib supports that.

Can You provide me some link that describes this another versionins system, used by Symfony? Where did You get this info? Maybe I missed something.

c33s commented 3 years ago

symfony uses this id internally https://github.com/symfony/http-kernel/blob/v5.2.0/Kernel.php#L78

adambanaszkiewicz commented 3 years ago

Look here: https://github.com/symfony/http-kernel/blob/4.4/Kernel.php#L80

Version 5.2.0 is "under the hood" a 050200 version. 5 stands as 05 etc. Like 4.4.18 means 040418, but Symfony skips first zero and in the result we have 40418 :)

c33s commented 3 years ago

still would be cool if your lib can handle the skipped zeros to easiy compare them. the skipped zero maybe is for easier comparision as integer.

i fully understand if you don't add this feature as this is a special case. my solution was to parse the semver 5.2.0 with parseConstraints https://packagist.org/packages/composer/semver and use the comparision functions of it.

adambanaszkiewicz commented 3 years ago

My lib skips the leading zero, please read the tests to find out: https://github.com/requtize/semver-converter/blob/master/tests/unit/SemVerConverterTest.php.

Unfortunetly, as my lib as Composer - both use Semantic Versioning. So You should get the same results of parsing with both cases. But, maybe I'm wrong :) If so, could You please write me later what the results was?

Adding the functionality You ask is not a part of the Semantic Versioning specification, as this lib was made for. Maybe You can create some abstraction for my classess and do the thing?