phar-io/manifest · error · ManifestDocumentMapperException

Unsupported version constraint

Error message

Unsupported version constraint - %s

What it means

When the <php version="..."> value in the requirements section cannot be parsed as a version constraint by PharIo\Version\VersionConstraintParser, the VersionException is re-thrown as ManifestDocumentMapperException with 'Unsupported version constraint - ...'. The library requires constraint syntax it understands (e.g. ^7.4, ~1.2, >=5.6).

Solutions

  1. Use a supported constraint expression, e.g. version="^7.4" or version=">=7.4 <8.0"
  2. Check the exact sub-message for what the parser rejected and the constraint syntax docs for phar-io/version
  3. Upgrade phar-io/version to the latest release to get full constraint support

Example fix

// before
<php version="7.4" />
// after
<php version="^7.4" />
Defensive patterns

Strategy: validation

Validate before calling

$version = $phpElement->getVersion();
if ($version === '' || !preg_match('/[<>=~^]/', $version)) {
    throw new InvalidArgumentException("php version must be a constraint, e.g. ^8.0, got: $version");
}

Try / catch

try {
    $manifest = ManifestLoader::fromFile($path);
} catch (ManifestLoaderException $e) {
    if (str_contains($e->getMessage(), 'Unsupported version constraint')) {
        // inspect previous VersionException message
    }
}

Prevention

When it happens

Trigger: A manifest with <php version="7.4"> (no operator means invalid in this parser context), arbitrary text like 'any', an empty version attribute, or operator syntax the installed phar-io/version release does not support.

Common situations: Authors writing Composer-style or plain-numeric versions that the manifest parser rejects; manifests generated for older phar-io/version without newer constraint operators.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of phar-io/manifest@c581d4941e (2026-09-14). Data as JSON: /api/errors/1ab0b644ef9258ff. Report an issue: GitHub.

Appendix: source

Thrown at src/ManifestDocumentMapper.php:88

            $licenseElement->getType(),
            new Url($licenseElement->getUrl())
        );

        return new CopyrightInformation(
            $authors,
            $license
        );
    }

    private function mapRequirements(RequiresElement $requires): RequirementCollection {
        $collection = new RequirementCollection();
        $phpElement = $requires->getPHPElement();
        $parser     = new VersionConstraintParser;

        try {
            $versionConstraint = $parser->parse($phpElement->getVersion());
        } catch (VersionException $e) {
            throw new ManifestDocumentMapperException(
                sprintf('Unsupported version constraint - %s', $e->getMessage()),
                (int)$e->getCode(),
                $e
            );
        }

        $collection->add(
            new PhpVersionRequirement(
                $versionConstraint
            )
        );

        if (!$phpElement->hasExtElements()) {
            return $collection;
        }

        foreach ($phpElement->getExtElements() as $extElement) {
            $collection->add(

View on GitHub (pinned to c581d4941e)