phar-io/version

major version only not supported, e.g. ^6

tacman opened this issue · 1 comments

tacman commented

https://packagist.org/packages/braunstetter/choosy-type

not sure why symfony/form: ^6 is different than the rest, but composer thinks it's valid, can you change the library to support this format as well?

symfony/form ^6
https://packagist.org/packages/braunstetter/choosy-type
Version string '6' does not follow SemVer semantics

The code I'm using for this is

$version = '^6';
                                try {
                                    $constraint = $parser->parse($version);
                                } catch (\Exception $exception) {
                                    $this->logger->error(sprintf("%s %s\n%s\n%s",
                                        $dependency, $version,
                                        $this->getPackagistUrl($name),
                                        $exception->getMessage()));
                                    break;
                                }

Technically, a "major version only" string like 6 is not valid according to the semver specification.
According to the specs, a valid version string must take the format X.Y.Z (https://semver.org/#spec-item-2) and it would fail the suggested regular expression made available in the specification (https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string).

As we already relaxed the rules (for parsing ^1.0-types of strings) and thus already support technically invalid strings, I decided to add support for it anyway.