mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Replace always-false attribute type check with assertion
The type will always be XML_ATTRIBUTE_NODE by construction via php_dom_create_object, no need to check the type. Use an assertion instead. This simplifies code and reasoning about error conditions.
This commit is contained in:
@@ -520,10 +520,7 @@ PHP_METHOD(DOMElement, setAttributeNode)
|
||||
|
||||
DOM_GET_OBJ(attrp, node, xmlAttrPtr, attrobj);
|
||||
|
||||
if (attrp->type != XML_ATTRIBUTE_NODE) {
|
||||
zend_argument_value_error(1, "must have the node attribute");
|
||||
RETURN_THROWS();
|
||||
}
|
||||
ZEND_ASSERT(attrp->type == XML_ATTRIBUTE_NODE);
|
||||
|
||||
if (!(attrp->doc == NULL || attrp->doc == nodep->doc)) {
|
||||
php_dom_throw_error(WRONG_DOCUMENT_ERR, dom_get_strict_error(intern->document));
|
||||
@@ -581,7 +578,9 @@ PHP_METHOD(DOMElement, removeAttributeNode)
|
||||
|
||||
DOM_GET_OBJ(attrp, node, xmlAttrPtr, attrobj);
|
||||
|
||||
if (attrp->type != XML_ATTRIBUTE_NODE || attrp->parent != nodep) {
|
||||
ZEND_ASSERT(attrp->type == XML_ATTRIBUTE_NODE);
|
||||
|
||||
if (attrp->parent != nodep) {
|
||||
php_dom_throw_error(NOT_FOUND_ERR, dom_get_strict_error(intern->document));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user