{"record":{"id":"2fa8109a330ba10f","repo":"phar-io/manifest","slug":"element-s-s-missing","errorCode":null,"errorMessage":"Element(s) %s missing","messagePattern":"Element\\(s\\) (.+?) missing","errorType":"exception","errorClass":"ManifestElementException","httpStatus":null,"severity":"error","filePath":"src/xml/ManifestElement.php","lineNumber":61,"sourceCode":"    }\n\n    protected function getChildByName(string $elementName): DOMElement {\n        $element = $this->element->getElementsByTagNameNS(self::XMLNS, $elementName)->item(0);\n\n        if (!$element instanceof DOMElement) {\n            throw new ManifestElementException(\n                sprintf('Element %s missing', $elementName)\n            );\n        }\n\n        return $element;\n    }\n\n    protected function getChildrenByName(string $elementName): DOMNodeList {\n        $elementList = $this->element->getElementsByTagNameNS(self::XMLNS, $elementName);\n\n        if ($elementList->length === 0) {\n            throw new ManifestElementException(\n                sprintf('Element(s) %s missing', $elementName)\n            );\n        }\n\n        return $elementList;\n    }\n\n    protected function hasChild(string $elementName): bool {\n        return $this->element->getElementsByTagNameNS(self::XMLNS, $elementName)->length !== 0;\n    }\n}\n","sourceCodeStart":43,"sourceCodeEnd":73,"githubUrl":"https://github.com/phar-io/manifest/blob/c581d4941e196459bf76c945a8ca922963a66708/src/xml/ManifestElement.php#L43-L73","documentation":"ManifestElement::getChildrenByName retrieves a list of child elements by name in the phar.io namespace and throws ManifestElementException('Element(s) %s missing') when the resulting DOMNodeList has length 0. It backs getComponentElements, getAuthorElements and getExtElements, meaning at least one such child is mandatory by the library's contract.","triggerScenarios":"Calling getAuthorElements() on the copyright element, getComponentElements() on the bundles element, or getExtElements() on an extension element when no matching child elements exist in the manifest.","commonSituations":"Bundles section with no <component> entries; extension element declaring no <ext> requirements; copyright element without any <author>; manifests pruned by hand or by an incomplete generator.","solutions":["Add at least one child element of the named kind (e.g. an <author>) to the parent element","Regenerate the manifest with a current build tool so required collections are emitted","Validate the manifest against the phar.io XSD before loading","Guard the call site with try-catch on ManifestElementException if the section may legitimately be absent in your data"],"exampleFix":"// before\n<bundles></bundles>\n// after\n<bundles><component name=\"acme/lib\" version=\"1.2.0\" url=\"https://example.com/acme.phar\"/></bundles>","handlingStrategy":"validation","validationCode":"if ($bundles->getElementsByTagNameNS('https://phar.io/manifest', 'component')->length === 0) { throw new RuntimeException('Bundles section has no components'); }","typeGuard":"function childCount(DOMElement $el, string $name): int { return $el->getElementsByTagNameNS('https://phar.io/manifest', $name)->length; }","tryCatchPattern":"try { $authors = $copyright->getAuthorElements(); } catch (ManifestElementException $e) { $authors = []; log_warning($e->getMessage()); }","preventionTips":["Ensure generator tools always emit at least one author/component/ext entry","Do not strip required sections when post-processing manifests","Validate manifests against the phar.io 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"}