phar-io/manifest · error · ManifestDocumentMapperException

Unsupported type

Error message

Unsupported type %s

What it means

mapType() only accepts 'application', 'library', and 'extension' as the <contains type="..."> value; anything else throws ManifestDocumentMapperException with the unsupported type name. The manifest type attribute is effectively a closed enum.

Solutions

  1. Set the type attribute to one of exactly: application, library, or extension
  2. Check for typos and casing — the comparison is case-sensitive lowercase
  3. If representing a custom component kind, use 'library' or 'extension' instead

Example fix

// before
<contains type="phar-plugin" name="acme/tool" version="1.0.0" />
// after
<contains type="application" name="acme/tool" version="1.0.0" />
Defensive patterns

Strategy: validation

Validate before calling

$allowed = ['application','library','extension'];
if (!in_array($type, $allowed, true)) {
    throw new InvalidArgumentException("type must be one of: " . implode(', ', $allowed));
}

Type guard

function isSupportedManifestType(string $type): bool {
    return in_array($type, ['application','library','extension'], true);
}

Try / catch

try {
    $manifest = ManifestLoader::fromFile($path);
} catch (ManifestLoaderException $e) {
    if (str_contains($e->getPrevious()?->getMessage() ?? '', 'Unsupported type')) {
        // fix the <contains type> attribute
    }
}

Prevention

When it happens

Trigger: A manifest.xml containing <contains type="plugin">, an empty type attribute, or a capitalized/mispelled type like 'Application' or 'libary'.

Common situations: Copying a manifest template and editing the type to a project-specific value; typos when hand-editing; older manifests written for a different schema version.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at src/ManifestDocumentMapper.php:51

                $requirements,
                $bundledComponents
            );
        } catch (Throwable $e) {
            throw new ManifestDocumentMapperException($e->getMessage(), (int)$e->getCode(), $e);
        }
    }

    private function mapType(ContainsElement $contains): Type {
        switch ($contains->getType()) {
            case 'application':
                return Type::application();
            case 'library':
                return Type::library();
            case 'extension':
                return $this->mapExtension($contains->getExtensionElement());
        }

        throw new ManifestDocumentMapperException(
            sprintf('Unsupported type %s', $contains->getType())
        );
    }

    private function mapCopyright(CopyrightElement $copyright): CopyrightInformation {
        $authors = new AuthorCollection();

        foreach ($copyright->getAuthorElements() as $authorElement) {
            $authors->add(
                new Author(
                    $authorElement->getName(),
                    $authorElement->hasEMail() ? new Email($authorElement->getEmail()) : null
                )
            );
        }

        $licenseElement = $copyright->getLicenseElement();
        $license        = new License(

View on GitHub (pinned to c581d4941e)