{"record":{"id":"2e92fd1dec3c2d44","repo":"phar-io/manifest","slug":"element-s-missing","errorCode":null,"errorMessage":"Element %s missing","messagePattern":"Element (.+?) missing","errorType":"exception","errorClass":"ManifestDocumentException","httpStatus":null,"severity":"error","filePath":"src/xml/ManifestDocument.php","lineNumber":108,"sourceCode":"    public function getBundlesElement(): BundlesElement {\n        return new BundlesElement(\n            $this->fetchElementByName('bundles')\n        );\n    }\n\n    private function ensureCorrectDocumentType(DOMDocument $dom): void {\n        $root = $dom->documentElement;\n\n        if ($root->localName !== 'phar' || $root->namespaceURI !== self::XMLNS) {\n            throw new ManifestDocumentException('Not a phar.io manifest document');\n        }\n    }\n\n    private function fetchElementByName(string $elementName): DOMElement {\n        $element = $this->dom->getElementsByTagNameNS(self::XMLNS, $elementName)->item(0);\n\n        if (!$element instanceof DOMElement) {\n            throw new ManifestDocumentException(\n                sprintf('Element %s missing', $elementName)\n            );\n        }\n\n        return $element;\n    }\n}\n","sourceCodeStart":90,"sourceCodeEnd":116,"githubUrl":"https://github.com/phar-io/manifest/blob/c581d4941e196459bf76c945a8ca922963a66708/src/xml/ManifestDocument.php#L90-L116","documentation":"ManifestDocument::fetchElementByName looks up a direct child element by name in the phar.io namespace via getElementsByTagNameNS and throws ManifestDocumentException('Element %s missing') when no DOMElement is found. It backs getContainsElement, getCopyrightElement, getRequiresElement and getBundlesElement, so a top-level required section (contains, copyright, requires, bundles) is absent from the manifest.","triggerScenarios":"Accessing e.g. $doc->getRequiresElement() (or contains/copyright/bundles) on a ManifestDocument whose XML lacks that element under the phar.io namespace.","commonSituations":"Minimal/incomplete manifests generated by older tool versions missing newer required sections; manifests with elements in the wrong namespace so getElementsByTagNameNS finds nothing; hand-trimmed manifests.","solutions":["Add the missing required element (e.g. <requires>) to the manifest XML","Ensure all elements use the phar.io namespace xmlns=\"https://phar.io/manifest\"","Regenerate the manifest with a current version of the build tool","Check which element name appears in the exception message and verify its spelling"],"exampleFix":"// before\n<phar xmlns=\"https://phar.io/manifest\"><contains>...</contains></phar>\n// after\n<phar xmlns=\"https://phar.io/manifest\"><contains>...</contains><requires><php version=\"8.1\"/></requires></phar>","handlingStrategy":"try-catch","validationCode":"$dom->loadXML($xml); if ($dom->getElementsByTagNameNS('https://phar.io/manifest', 'requires')->length === 0) { throw new RuntimeException('Manifest lacks <requires> element'); }","typeGuard":"function hasElement(DOMDocument $dom, string $name): bool { return $dom->getElementsByTagNameNS('https://phar.io/manifest', $name)->length > 0; }","tryCatchPattern":"try { $requires = $doc->getRequiresElement(); } catch (ManifestDocumentException $e) { log_warning('Manifest section missing: ' . $e->getMessage()); $requires = null; }","preventionTips":["Use full manifests containing contains/copyright/requires/bundles sections","Ensure every element carries the phar.io namespace","Validate against the official manifest XSD before loading"],"tags":["xml","manifest","missing-element"],"backgroundTag":"schema-validation-failed","analyzedSha":"c581d4941e196459bf76c945a8ca922963a66708","analyzedAt":"2026-09-14T11:08:47.165Z","contentChangedAt":"2026-09-14T11:08:47.165Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}