Skip to content

Inconsistent application of stability flags in parseConstraint #154

@Xerkus

Description

@Xerkus

VersionParser::parseConstraint() does not take into consideration stability flag when parsing constraint with ~ tilde or ^ caret range:
Constraint ~1.2.3@RC is parsed as >=1.2.3.0-dev and <1.3.0.0-dev
However ~1.2.3-RC is parsed as >=1.2.3.0-RC and <1.3.0.0-dev as expected.

I believe this inconsistency is a bug since ~ or ^ returns early from a conditional block but stability flags are considered again much later in the method where it apples to not equal and less/greater operators.

At the same time I see edge case with the way stability flag is handled with pre-release identifiers that are considered stable by composer:
>1.2.3@rc -> 1.2.3.0-rc
>1.2.3-beta@rc -> 1.2.3.0-beta
>1.2.3-stable@RC -> 1.2.3.0-rc
>1.2.3-patch1@RC -> 1.2.3.0-patch1-rc
I believe last constraint is invalid and as such a bug.

Hyphen ranges do not consider stability flags but also do not allow them on either side. No issue here.

Constraint with wildcards 1.2.*@rc does not allow pre-release identifiers but allows stability flags which it then ignores.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions