Skip to content

Commit 43c3d78

Browse files
committed
Use early return
1 parent a9b656b commit 43c3d78

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

ext/simplexml/simplexml.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2621,19 +2621,20 @@ PHP_FUNCTION(simplexml_import_dom)
26212621

26222622
nodep = php_libxml_import_node(node);
26232623

2624-
if (nodep) {
2625-
if (nodep->doc == NULL) {
2626-
php_error_docref(NULL, E_WARNING, "Imported Node must have associated Document");
2627-
RETURN_NULL();
2628-
}
2629-
if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) {
2630-
nodep = xmlDocGetRootElement((xmlDocPtr) nodep);
2631-
}
2632-
} else {
2624+
if (!nodep) {
26332625
zend_argument_type_error(1, "must be of type DOMNode, %s given", zend_zval_type_name(node));
26342626
RETURN_THROWS();
26352627
}
26362628

2629+
if (nodep->doc == NULL) {
2630+
php_error_docref(NULL, E_WARNING, "Imported Node must have associated Document");
2631+
RETURN_NULL();
2632+
}
2633+
2634+
if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) {
2635+
nodep = xmlDocGetRootElement((xmlDocPtr) nodep);
2636+
}
2637+
26372638
if (nodep->type == XML_ELEMENT_NODE) {
26382639
if (!ce) {
26392640
ce = sxe_class_entry;

0 commit comments

Comments
 (0)