Skip to content

Wrong ordering for minor version constraints in composer file #1003

@sstok

Description

@sstok

Steps required to reproduce the problem

  1. I have the following composer.json file :
Details
{
    "name": "rollerworks/pdb-symfony-bridge",
    "description": "PHP domain-parser Bridge for Symfony Cache, HTTP Client and FrameworkBundle (optional)",
    "license": "MIT",
    "type": "library",
    "keywords": [
        "php-domain-parser",
        "pdb",
        "symfony"
    ],
    "authors": [
        {
            "name": "Sebastiaan Stok",
            "email": "s.stok@rollerscapes.net"
        }
    ],
    "require": {
        "php": "^8.1",
        "jeremykendall/php-domain-parser": "^6.3",
        "psr/simple-cache": "^1.0 || ^3.0",
        "symfony/cache": "^v6.3 || ^7.0",
        "symfony/http-client": "^v6.3 || ^7.0"
    },
    "require-dev": {
        "phpunit/phpunit": "^9.6.13",
        "rollerscapes/standards": "^1.0",
        "symfony/framework-bundle": "^v6.3 || ^7.0",
        "symfony/phpunit-bridge": "^v6.3 || ^7.0"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "autoload": {
        "psr-4": {
            "Rollerworks\\Component\\PdbSfBridge\\": "src/"
        },
        "exclude-from-classmap": [
            "tests/"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Rollerworks\\Component\\PdbSfBridge\\Tests\\": "tests/"
        }
    },
    "config": {
        "sort-packages": true
    }
}

Expected Result

  • Kept as-is, as it's already normalized.

Actual Result

  • The minor version constraints are sorted in reverse
        "symfony/cache": "^7.0 || ^v6.3",
        "symfony/http-client": "^7.0 || ^v6.3"

This is properly due to https://www.php.net/strnatcmp sorting in "natural order", for correct ordering the Semver comparator should be used.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions