[php-src] master: Merge branch 'PHP-8.0'

From: Date: Mon, 26 Apr 2021 09:13:54 +0000
Subject: [php-src] master: Merge branch 'PHP-8.0'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-115807@lists.php.net to get a copy of this message
Author: Máté Kocsis (kocsismate) Date: 2021-04-26T11:12:12+02:00 Commit: https://github.com/php/php-src/commit/0cd06d1d1933080ae177728c24416a60885b837b Raw diff: https://github.com/php/php-src/commit/0cd06d1d1933080ae177728c24416a60885b837b.diff Merge branch 'PHP-8.0' * Fix arginfo/ZPP mismatch for simplexml_import_dom Changed paths: M ext/simplexml/simplexml.c M ext/simplexml/simplexml.stub.php M ext/simplexml/simplexml_arginfo.h Diff: diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index f2cbfd7da00e..483421e1931e 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -2619,27 +2619,32 @@ PHP_FUNCTION(simplexml_import_dom) RETURN_THROWS(); } - object = Z_LIBXML_NODE_P(node); - nodep = php_libxml_import_node(node); - if (nodep) { - if (nodep->doc == NULL) { - php_error_docref(NULL, E_WARNING, "Imported Node must have associated Document"); - RETURN_NULL(); - } - if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) { - nodep = xmlDocGetRootElement((xmlDocPtr) nodep); - } + if (!nodep) { + zend_argument_type_error(1, "must be of type SimpleXMLElement|DOMNode, %s given", zend_zval_type_name(node)); + RETURN_THROWS(); + } + + if (nodep->doc == NULL) { + php_error_docref(NULL, E_WARNING, "Imported Node must have associated Document"); + RETURN_NULL(); + } + + if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) { + nodep = xmlDocGetRootElement((xmlDocPtr) nodep); } - if (nodep && nodep->type == XML_ELEMENT_NODE) { + if (nodep->type == XML_ELEMENT_NODE) { if (!ce) { ce = sxe_class_entry; fptr_count = NULL; } else { fptr_count = php_sxe_find_fptr_count(ce); } + + object = Z_LIBXML_NODE_P(node); + sxe = php_sxe_object_new(ce, fptr_count); sxe->document = object->document; php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, nodep->doc); diff --git a/ext/simplexml/simplexml.stub.php b/ext/simplexml/simplexml.stub.php index ec4f1a61df7e..a2e66e3703f7 100644 --- a/ext/simplexml/simplexml.stub.php +++ b/ext/simplexml/simplexml.stub.php @@ -6,7 +6,7 @@ function simplexml_load_file(string $filename, ?string $class_name = SimpleXMLEl function simplexml_load_string(string $data, ?string $class_name = SimpleXMLElement::class, int $options = 0, string $namespace_or_prefix = "", bool $is_prefix = false): SimpleXMLElement|false {} -function simplexml_import_dom(DOMNode $node, ?string $class_name = SimpleXMLElement::class): ?SimpleXMLElement {} +function simplexml_import_dom(SimpleXMLElement|DOMNode $node, ?string $class_name = SimpleXMLElement::class): ?SimpleXMLElement {} class SimpleXMLElement implements Stringable, Countable, RecursiveIterator { diff --git a/ext/simplexml/simplexml_arginfo.h b/ext/simplexml/simplexml_arginfo.h index 92788bbc6cf5..98bfa6c0596f 100644 --- a/ext/simplexml/simplexml_arginfo.h +++ b/ext/simplexml/simplexml_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 4e4844b9cbac53c3fff061192f7e1ff703ac2f8c */ + * Stub hash: 6f71b9fa3dd098b1401be8c659d03041f7d361c1 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_simplexml_load_file, 0, 1, SimpleXMLElement, MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) @@ -18,7 +18,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_simplexml_load_string, 0, 1, ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_simplexml_import_dom, 0, 1, SimpleXMLElement, 1) - ZEND_ARG_OBJ_INFO(0, node, DOMNode, 0) + ZEND_ARG_OBJ_TYPE_MASK(0, node, SimpleXMLElement|DOMNode, 0, NULL) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, class_name, IS_STRING, 1, "SimpleXMLElement::class") ZEND_END_ARG_INFO()

« previous php.cvs (#115807) next »