composer / semver

Semantic versioning utilities with the addition of version constraints parsing and checking.
MIT License
3.15k stars 76 forks source link

Invalid config.platform.php not noticed by diagnose #52

Closed caiquecastro closed 7 years ago

caiquecastro commented 7 years ago

If a composer.json contains an invalid php version constraint:

{
    ...
    "config": {
        "platform": {
            "php": "^7.0"
        }
    },
    ...
}

It's not alerted by the diagnose command, but when i give another command, like composer update, it throwns an UnexpectedValueException with the message: Invalid version string "^7.0"

alcohol commented 7 years ago

Not sure if this is really a bug. Diagnose is not designed to validate everything to the letter. The schema used to describe most attributes can only go so far. It expects a string value, which it has. We cannot always account for users being unable to read or understand how certain properties are supposed to work. The exception being thrown at runtime (which is when we are able to detect more specific errors) is sufficient I think. If someone can think of a better way to validate the platform value during diagnose, contributions are welcome.

alcohol commented 7 years ago

Also, this is the wrong repository for this issue. Please head over to composer/composer.