{"record":{"id":"88b01c5a6a93de17","repo":"phar-io/manifest","slug":"element-s-missing-manifestelement","errorCode":null,"errorMessage":"Element %s missing","messagePattern":"Element (.+?) missing","errorType":"exception","errorClass":"ManifestElementException","httpStatus":null,"severity":"error","filePath":"src/xml/ManifestElement.php","lineNumber":49,"sourceCode":"                    'Attribute %s not set on element %s',\n                    $name,\n                    $this->element->localName\n                )\n            );\n        }\n\n        return $this->element->getAttribute($name);\n    }\n\n    protected function hasAttribute(string $name): bool {\n        return $this->element->hasAttribute($name);\n    }\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    }","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/phar-io/manifest/blob/c581d4941e196459bf76c945a8ca922963a66708/src/xml/ManifestElement.php#L31-L67","documentation":"ManifestElement::getChildByName searches for a single named child element in the phar.io namespace and throws ManifestElementException('Element %s missing') when none is found. It backs getExtensionElement, getLicenseElement and getPHPElement, so the error means a required nested section (extension, license, or php inside <requires>) is absent.","triggerScenarios":"Calling getLicenseElement() on the copyright element, getPHPElement()/getExtensionElement() on the requires element, when the corresponding child element is not present in the manifest XML.","commonSituations":"Requires section lacking a <php> constraint; copyright section without <license>; manifests edited to drop license info; manifests produced by tools predating a required child element.","solutions":["Add the missing child element (e.g. <license type=\"BSD-3-Clause\"/>) inside its parent","Check the parent element in the message is the one you intended to query","Regenerate the manifest with a current build tool","Validate against the phar.io manifest XSD before use"],"exampleFix":"// before\n<copyright><author name=\"A\"/></copyright>\n// after\n<copyright><author name=\"A\"/><license type=\"BSD-3-Clause\"/></copyright>","handlingStrategy":"try-catch","validationCode":"if ($copyright->getElementsByTagNameNS('https://phar.io/manifest', 'license')->length === 0) { throw new RuntimeException('No <license> element'); }","typeGuard":"function hasChild(DOMElement $el, string $name): bool { return $el->getElementsByTagNameNS('https://phar.io/manifest', $name)->length > 0; }","tryCatchPattern":"try { $license = $copyright->getLicenseElement(); } catch (ManifestElementException $e) { log_warning('Manifest lacks license info'); $license = null; }","preventionTips":["Verify the parent element actually contains the expected child (license/php/extension)","Keep manifests generated by current tool versions","Run an XSD validation pass before consuming manifest data"],"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"}