Update ext/dom names after policy change (#14171)

This commit is contained in:
Niels Dossche 2024-05-09 10:40:53 +02:00 committed by GitHub
parent 0dfd2a93ab
commit 6e7adb3c48
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
251 changed files with 1501 additions and 1501 deletions

View file

@ -184,7 +184,7 @@ PHP_METHOD(DOMCharacterData, appendData)
dom_character_data_append_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); dom_character_data_append_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, true);
} }
PHP_METHOD(DOM_CharacterData, appendData) PHP_METHOD(Dom_CharacterData, appendData)
{ {
dom_character_data_append_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); dom_character_data_append_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, false);
} }
@ -255,7 +255,7 @@ PHP_METHOD(DOMCharacterData, insertData)
dom_character_data_insert_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); dom_character_data_insert_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, true);
} }
PHP_METHOD(DOM_CharacterData, insertData) PHP_METHOD(Dom_CharacterData, insertData)
{ {
dom_character_data_insert_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); dom_character_data_insert_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, false);
} }
@ -327,7 +327,7 @@ PHP_METHOD(DOMCharacterData, deleteData)
dom_character_data_delete_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); dom_character_data_delete_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, true);
} }
PHP_METHOD(DOM_CharacterData, deleteData) PHP_METHOD(Dom_CharacterData, deleteData)
{ {
dom_character_data_delete_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); dom_character_data_delete_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, false);
} }
@ -407,7 +407,7 @@ PHP_METHOD(DOMCharacterData, replaceData)
dom_character_data_replace_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); dom_character_data_replace_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, true);
} }
PHP_METHOD(DOM_CharacterData, replaceData) PHP_METHOD(Dom_CharacterData, replaceData)
{ {
dom_character_data_replace_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); dom_character_data_replace_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, false);
} }

View file

@ -457,7 +457,7 @@ PHP_METHOD(DOMDocument, createElement)
DOM_RET_OBJ(node, intern); DOM_RET_OBJ(node, intern);
} }
PHP_METHOD(DOM_Document, createElement) PHP_METHOD(Dom_Document, createElement)
{ {
xmlNode *node; xmlNode *node;
xmlDocPtr docp; xmlDocPtr docp;
@ -662,7 +662,7 @@ PHP_METHOD(DOMDocument, createProcessingInstruction)
dom_document_create_processing_instruction(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); dom_document_create_processing_instruction(INTERNAL_FUNCTION_PARAM_PASSTHRU, false);
} }
PHP_METHOD(DOM_Document, createProcessingInstruction) PHP_METHOD(Dom_Document, createProcessingInstruction)
{ {
dom_document_create_processing_instruction(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); dom_document_create_processing_instruction(INTERNAL_FUNCTION_PARAM_PASSTHRU, true);
} }
@ -827,13 +827,13 @@ static void dom_modern_document_import_node(INTERNAL_FUNCTION_PARAMETERS, zend_c
DOM_RET_OBJ(retnodep, intern); DOM_RET_OBJ(retnodep, intern);
} }
PHP_METHOD(DOM_Document, importNode) PHP_METHOD(Dom_Document, importNode)
{ {
dom_modern_document_import_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_node_class_entry); dom_modern_document_import_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_node_class_entry);
} }
/* }}} end dom_document_import_node */ /* }}} end dom_document_import_node */
PHP_METHOD(DOM_Document, importLegacyNode) PHP_METHOD(Dom_Document, importLegacyNode)
{ {
dom_modern_document_import_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_node_class_entry); dom_modern_document_import_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_node_class_entry);
} }
@ -893,7 +893,7 @@ PHP_METHOD(DOMDocument, createElementNS)
DOM_RET_OBJ(nodep, intern); DOM_RET_OBJ(nodep, intern);
} }
PHP_METHOD(DOM_Document, createElementNS) PHP_METHOD(Dom_Document, createElementNS)
{ {
xmlDocPtr docp; xmlDocPtr docp;
dom_object *intern; dom_object *intern;
@ -1199,7 +1199,7 @@ PHP_METHOD(DOMDocument, adoptNode)
dom_document_adopt_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); dom_document_adopt_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, false);
} }
PHP_METHOD(DOM_Document, adoptNode) PHP_METHOD(Dom_Document, adoptNode)
{ {
dom_document_adopt_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); dom_document_adopt_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, true);
} }
@ -1693,7 +1693,7 @@ PHP_METHOD(DOMDocument, saveXML)
dom_document_save_xml(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_node_class_entry); dom_document_save_xml(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_node_class_entry);
} }
PHP_METHOD(DOM_XMLDocument, saveXML) PHP_METHOD(Dom_XMLDocument, saveXml)
{ {
dom_document_save_xml(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_node_class_entry); dom_document_save_xml(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_node_class_entry);
} }
@ -2266,7 +2266,7 @@ PHP_METHOD(DOMDocument, registerNodeClass)
dom_document_register_node_class(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); dom_document_register_node_class(INTERNAL_FUNCTION_PARAM_PASSTHRU, false);
} }
PHP_METHOD(DOM_Document, registerNodeClass) PHP_METHOD(Dom_Document, registerNodeClass)
{ {
dom_document_register_node_class(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); dom_document_register_node_class(INTERNAL_FUNCTION_PARAM_PASSTHRU, true);
} }

View file

@ -107,7 +107,7 @@ PHP_METHOD(DOMImplementation, createDocumentType)
DOM_RET_OBJ((xmlNodePtr) doctype, NULL); DOM_RET_OBJ((xmlNodePtr) doctype, NULL);
} }
PHP_METHOD(DOM_Implementation, createDocumentType) PHP_METHOD(Dom_Implementation, createDocumentType)
{ {
size_t name_len, publicid_len = 0, systemid_len = 0; size_t name_len, publicid_len = 0, systemid_len = 0;
const char *name, *publicid = NULL, *systemid = NULL; const char *name, *publicid = NULL, *systemid = NULL;
@ -249,7 +249,7 @@ PHP_METHOD(DOMImplementation, createDocument)
} }
} }
PHP_METHOD(DOM_Implementation, createDocument) PHP_METHOD(Dom_Implementation, createDocument)
{ {
zval *dtd = NULL; zval *dtd = NULL;
xmlDtdPtr doctype = NULL; xmlDtdPtr doctype = NULL;
@ -343,7 +343,7 @@ error:
/* }}} end dom_domimplementation_create_document */ /* }}} end dom_domimplementation_create_document */
/* {{{ URL: https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument */ /* {{{ URL: https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument */
PHP_METHOD(DOM_Implementation, createHTMLDocument) PHP_METHOD(Dom_Implementation, createHTMLDocument)
{ {
const char *title = NULL; const char *title = NULL;
size_t title_len = 0; size_t title_len = 0;

View file

@ -572,7 +572,7 @@ PHP_METHOD(DOMElement, removeAttribute)
RETURN_BOOL(dom_remove_attribute(nodep, attrp)); RETURN_BOOL(dom_remove_attribute(nodep, attrp));
} }
PHP_METHOD(DOM_Element, removeAttribute) PHP_METHOD(Dom_Element, removeAttribute)
{ {
xmlNodePtr nodep, attrp; xmlNodePtr nodep, attrp;
dom_object *intern; dom_object *intern;
@ -749,7 +749,7 @@ PHP_METHOD(DOMElement, removeAttributeNode)
dom_element_remove_attribute_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_node_class_entry); dom_element_remove_attribute_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_node_class_entry);
} }
PHP_METHOD(DOM_Element, removeAttributeNode) PHP_METHOD(Dom_Element, removeAttributeNode)
{ {
dom_element_remove_attribute_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_node_class_entry); dom_element_remove_attribute_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_node_class_entry);
} }
@ -785,7 +785,7 @@ PHP_METHOD(DOMElement, getElementsByTagName)
dom_element_get_elements_by_tag_name(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); dom_element_get_elements_by_tag_name(INTERNAL_FUNCTION_PARAM_PASSTHRU, false);
} }
PHP_METHOD(DOM_Element, getElementsByTagName) PHP_METHOD(Dom_Element, getElementsByTagName)
{ {
dom_element_get_elements_by_tag_name(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); dom_element_get_elements_by_tag_name(INTERNAL_FUNCTION_PARAM_PASSTHRU, true);
} }
@ -1172,7 +1172,7 @@ PHP_METHOD(DOMElement, setAttributeNodeNS)
dom_element_set_attribute_node_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, /* use_ns */ true, /* modern */ false); dom_element_set_attribute_node_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, /* use_ns */ true, /* modern */ false);
} }
PHP_METHOD(DOM_Element, setAttributeNodeNS) PHP_METHOD(Dom_Element, setAttributeNodeNS)
{ {
dom_element_set_attribute_node_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, /* use_ns */ true, /* modern */ true); dom_element_set_attribute_node_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, /* use_ns */ true, /* modern */ true);
} }
@ -1208,7 +1208,7 @@ PHP_METHOD(DOMElement, getElementsByTagNameNS)
dom_element_get_elements_by_tag_name_ns(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); dom_element_get_elements_by_tag_name_ns(INTERNAL_FUNCTION_PARAM_PASSTHRU, false);
} }
PHP_METHOD(DOM_Element, getElementsByTagNameNS) PHP_METHOD(Dom_Element, getElementsByTagNameNS)
{ {
dom_element_get_elements_by_tag_name_ns(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); dom_element_get_elements_by_tag_name_ns(INTERNAL_FUNCTION_PARAM_PASSTHRU, true);
} }
@ -1387,7 +1387,7 @@ PHP_METHOD(DOMElement, setIdAttributeNode)
dom_element_set_id_attribute_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_attr_class_entry); dom_element_set_id_attribute_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_attr_class_entry);
} }
PHP_METHOD(DOM_Element, setIdAttributeNode) PHP_METHOD(Dom_Element, setIdAttributeNode)
{ {
dom_element_set_id_attribute_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_attr_class_entry); dom_element_set_id_attribute_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_attr_class_entry);
} }
@ -1595,7 +1595,7 @@ PHP_METHOD(DOMElement, insertAdjacentElement)
dom_element_insert_adjacent_element(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_element_class_entry); dom_element_insert_adjacent_element(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_element_class_entry);
} }
PHP_METHOD(DOM_Element, insertAdjacentElement) PHP_METHOD(Dom_Element, insertAdjacentElement)
{ {
dom_element_insert_adjacent_element(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_element_class_entry); dom_element_insert_adjacent_element(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_element_class_entry);
} }

View file

@ -89,7 +89,7 @@ static void dom_html_collection_named_item_into_zval(zval *return_value, zend_st
} }
} }
PHP_METHOD(DOM_HTMLCollection, namedItem) PHP_METHOD(Dom_HTMLCollection, namedItem)
{ {
zend_string *key; zend_string *key;
ZEND_PARSE_PARAMETERS_START(1, 1) ZEND_PARSE_PARAMETERS_START(1, 1)

View file

@ -722,13 +722,13 @@ static bool check_options_validity(uint32_t arg_num, zend_long options)
"LIBXML_NOERROR, " "LIBXML_NOERROR, "
"LIBXML_COMPACT, " "LIBXML_COMPACT, "
"LIBXML_HTML_NOIMPLIED, " "LIBXML_HTML_NOIMPLIED, "
"DOM\\NO_DEFAULT_NS)"); "Dom\\NO_DEFAULT_NS)");
return false; return false;
} }
return true; return true;
} }
PHP_METHOD(DOM_HTMLDocument, createEmpty) PHP_METHOD(Dom_HTMLDocument, createEmpty)
{ {
const char *encoding = "UTF-8"; const char *encoding = "UTF-8";
size_t encoding_len = strlen("UTF-8"); size_t encoding_len = strlen("UTF-8");
@ -775,7 +775,7 @@ static bool dom_should_register_error_handlers(zend_long options)
return php_libxml_uses_internal_errors() || ((EG(error_reporting) | EG(user_error_handler_error_reporting)) & E_WARNING); return php_libxml_uses_internal_errors() || ((EG(error_reporting) | EG(user_error_handler_error_reporting)) & E_WARNING);
} }
PHP_METHOD(DOM_HTMLDocument, createFromString) PHP_METHOD(Dom_HTMLDocument, createFromString)
{ {
const char *source, *override_encoding = NULL; const char *source, *override_encoding = NULL;
size_t source_len, override_encoding_len; size_t source_len, override_encoding_len;
@ -926,7 +926,7 @@ fail_oom:
RETURN_THROWS(); RETURN_THROWS();
} }
PHP_METHOD(DOM_HTMLDocument, createFromFile) PHP_METHOD(Dom_HTMLDocument, createFromFile)
{ {
const char *filename, *override_encoding = NULL; const char *filename, *override_encoding = NULL;
php_dom_libxml_ns_mapper *ns_mapper = NULL; php_dom_libxml_ns_mapper *ns_mapper = NULL;
@ -1265,7 +1265,7 @@ static zend_result dom_common_save(dom_output_ctx *output_ctx, const xmlDoc *doc
return SUCCESS; return SUCCESS;
} }
PHP_METHOD(DOM_HTMLDocument, saveHTMLFile) PHP_METHOD(Dom_HTMLDocument, saveHtmlFile)
{ {
zval *id; zval *id;
xmlDoc *docp; xmlDoc *docp;
@ -1304,7 +1304,7 @@ PHP_METHOD(DOM_HTMLDocument, saveHTMLFile)
RETURN_LONG(bytes); RETURN_LONG(bytes);
} }
PHP_METHOD(DOM_HTMLDocument, saveHTML) PHP_METHOD(Dom_HTMLDocument, saveHtml)
{ {
zval *nodep = NULL; zval *nodep = NULL;
const xmlDoc *docp; const xmlDoc *docp;

View file

@ -1021,7 +1021,7 @@ PHP_METHOD(DOMNode, insertBefore)
dom_node_insert_before(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); dom_node_insert_before(INTERNAL_FUNCTION_PARAM_PASSTHRU, false);
} }
PHP_METHOD(DOM_Node, insertBefore) PHP_METHOD(Dom_Node, insertBefore)
{ {
dom_node_insert_before(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); dom_node_insert_before(INTERNAL_FUNCTION_PARAM_PASSTHRU, true);
} }
@ -1207,7 +1207,7 @@ PHP_METHOD(DOMNode, replaceChild)
dom_node_replace_child(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); dom_node_replace_child(INTERNAL_FUNCTION_PARAM_PASSTHRU, false);
} }
PHP_METHOD(DOM_Node, replaceChild) PHP_METHOD(Dom_Node, replaceChild)
{ {
dom_node_replace_child(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); dom_node_replace_child(INTERNAL_FUNCTION_PARAM_PASSTHRU, true);
} }
@ -1257,7 +1257,7 @@ PHP_METHOD(DOMNode, removeChild)
dom_node_remove_child(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_node_class_entry); dom_node_remove_child(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_node_class_entry);
} }
PHP_METHOD(DOM_Node, removeChild) PHP_METHOD(Dom_Node, removeChild)
{ {
dom_node_remove_child(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_node_class_entry); dom_node_remove_child(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_node_class_entry);
} }
@ -1389,7 +1389,7 @@ PHP_METHOD(DOMNode, appendChild)
dom_node_append_child_legacy(return_value, intern, childobj, nodep, child); dom_node_append_child_legacy(return_value, intern, childobj, nodep, child);
} }
PHP_METHOD(DOM_Node, appendChild) PHP_METHOD(Dom_Node, appendChild)
{ {
zval *node; zval *node;
xmlNodePtr nodep, child; xmlNodePtr nodep, child;
@ -1580,7 +1580,7 @@ PHP_METHOD(DOMNode, isSameNode)
dom_node_is_same_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, node); dom_node_is_same_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, node);
} }
PHP_METHOD(DOM_Node, isSameNode) PHP_METHOD(Dom_Node, isSameNode)
{ {
zval *node; zval *node;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O!", &node, dom_modern_node_class_entry) != SUCCESS) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "O!", &node, dom_modern_node_class_entry) != SUCCESS) {
@ -1780,7 +1780,7 @@ PHP_METHOD(DOMNode, isEqualNode)
dom_node_is_equal_node_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); dom_node_is_equal_node_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, false);
} }
PHP_METHOD(DOM_Node, isEqualNode) PHP_METHOD(Dom_Node, isEqualNode)
{ {
dom_node_is_equal_node_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); dom_node_is_equal_node_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, true);
} }
@ -1877,7 +1877,7 @@ PHP_METHOD(DOMNode, lookupPrefix)
dom_node_lookup_prefix(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); dom_node_lookup_prefix(INTERNAL_FUNCTION_PARAM_PASSTHRU, false);
} }
PHP_METHOD(DOM_Node, lookupPrefix) PHP_METHOD(Dom_Node, lookupPrefix)
{ {
dom_node_lookup_prefix(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); dom_node_lookup_prefix(INTERNAL_FUNCTION_PARAM_PASSTHRU, true);
} }
@ -1989,7 +1989,7 @@ PHP_METHOD(DOMNode, isDefaultNamespace)
RETURN_FALSE; RETURN_FALSE;
} }
PHP_METHOD(DOM_Node, isDefaultNamespace) PHP_METHOD(Dom_Node, isDefaultNamespace)
{ {
zval *id; zval *id;
xmlNodePtr nodep; xmlNodePtr nodep;
@ -2291,7 +2291,7 @@ PHP_METHOD(DOMNode, getNodePath)
dom_node_get_node_path(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); dom_node_get_node_path(INTERNAL_FUNCTION_PARAM_PASSTHRU, false);
} }
PHP_METHOD(DOM_Node, getNodePath) PHP_METHOD(Dom_Node, getNodePath)
{ {
dom_node_get_node_path(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); dom_node_get_node_path(INTERNAL_FUNCTION_PARAM_PASSTHRU, true);
} }
@ -2354,7 +2354,7 @@ PHP_METHOD(DOMNode, contains)
RETURN_BOOL(dom_node_contains(thisp, otherp)); RETURN_BOOL(dom_node_contains(thisp, otherp));
} }
PHP_METHOD(DOM_Node, contains) PHP_METHOD(Dom_Node, contains)
{ {
zval *other, *id; zval *other, *id;
xmlNodePtr otherp, thisp; xmlNodePtr otherp, thisp;
@ -2570,7 +2570,7 @@ PHP_METHOD(DOMNode, compareDocumentPosition)
dom_node_compare_document_position(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_node_class_entry); dom_node_compare_document_position(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_node_class_entry);
} }
PHP_METHOD(DOM_Node, compareDocumentPosition) PHP_METHOD(Dom_Node, compareDocumentPosition)
{ {
dom_node_compare_document_position(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_node_class_entry); dom_node_compare_document_position(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_node_class_entry);
} }
@ -2585,7 +2585,7 @@ PHP_METHOD(DOM_Node, compareDocumentPosition)
* - If the user implements __sleep / __wakeup, then it's also not a problem because they will not enter the throwing methods. * - If the user implements __sleep / __wakeup, then it's also not a problem because they will not enter the throwing methods.
*/ */
PHP_METHOD(DOM_Node, __construct) PHP_METHOD(Dom_Node, __construct)
{ {
ZEND_UNREACHABLE(); ZEND_UNREACHABLE();
} }

View file

@ -521,7 +521,7 @@ static void dom_import_simplexml_common(INTERNAL_FUNCTION_PARAMETERS, php_libxml
if (new_class == PHP_LIBXML_CLASS_MODERN) { if (new_class == PHP_LIBXML_CLASS_MODERN) {
zend_argument_type_error(1, "must not be already imported as a DOMNode"); zend_argument_type_error(1, "must not be already imported as a DOMNode");
} else { } else {
zend_argument_type_error(1, "must not be already imported as a DOM\\Node"); zend_argument_type_error(1, "must not be already imported as a Dom\\Node");
} }
RETURN_THROWS(); RETURN_THROWS();
} }
@ -545,7 +545,7 @@ PHP_FUNCTION(dom_import_simplexml)
dom_import_simplexml_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_LIBXML_CLASS_LEGACY); dom_import_simplexml_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_LIBXML_CLASS_LEGACY);
} }
PHP_FUNCTION(DOM_import_simplexml) PHP_FUNCTION(Dom_import_simplexml)
{ {
dom_import_simplexml_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_LIBXML_CLASS_MODERN); dom_import_simplexml_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_LIBXML_CLASS_MODERN);
} }
@ -733,15 +733,15 @@ PHP_MINIT_FUNCTION(dom)
dom_domexception_class_entry = register_class_DOMException(zend_ce_exception); dom_domexception_class_entry = register_class_DOMException(zend_ce_exception);
dom_parentnode_class_entry = register_class_DOMParentNode(); dom_parentnode_class_entry = register_class_DOMParentNode();
dom_modern_parentnode_class_entry = register_class_DOM_ParentNode(); dom_modern_parentnode_class_entry = register_class_Dom_ParentNode();
dom_childnode_class_entry = register_class_DOMChildNode(); dom_childnode_class_entry = register_class_DOMChildNode();
dom_modern_childnode_class_entry = register_class_DOM_ChildNode(); dom_modern_childnode_class_entry = register_class_Dom_ChildNode();
dom_domimplementation_class_entry = register_class_DOMImplementation(); dom_domimplementation_class_entry = register_class_DOMImplementation();
dom_domimplementation_class_entry->create_object = dom_objects_new; dom_domimplementation_class_entry->create_object = dom_objects_new;
dom_domimplementation_class_entry->default_object_handlers = &dom_object_handlers; dom_domimplementation_class_entry->default_object_handlers = &dom_object_handlers;
dom_modern_domimplementation_class_entry = register_class_DOM_Implementation(); dom_modern_domimplementation_class_entry = register_class_Dom_Implementation();
dom_modern_domimplementation_class_entry->create_object = dom_objects_new; dom_modern_domimplementation_class_entry->create_object = dom_objects_new;
dom_modern_domimplementation_class_entry->default_object_handlers = &dom_modern_domimplementation_object_handlers; dom_modern_domimplementation_class_entry->default_object_handlers = &dom_modern_domimplementation_object_handlers;
@ -770,7 +770,7 @@ PHP_MINIT_FUNCTION(dom)
DOM_REGISTER_PROP_HANDLER(&dom_node_prop_handlers, "textContent", dom_node_text_content_read, dom_node_text_content_write); DOM_REGISTER_PROP_HANDLER(&dom_node_prop_handlers, "textContent", dom_node_text_content_read, dom_node_text_content_write);
zend_hash_add_new_ptr(&classes, dom_node_class_entry->name, &dom_node_prop_handlers); zend_hash_add_new_ptr(&classes, dom_node_class_entry->name, &dom_node_prop_handlers);
dom_modern_node_class_entry = register_class_DOM_Node(); dom_modern_node_class_entry = register_class_Dom_Node();
dom_modern_node_class_entry->create_object = dom_objects_new; dom_modern_node_class_entry->create_object = dom_objects_new;
dom_modern_node_class_entry->default_object_handlers = &dom_object_handlers; dom_modern_node_class_entry->default_object_handlers = &dom_object_handlers;
@ -820,7 +820,7 @@ PHP_MINIT_FUNCTION(dom)
zend_hash_merge(&dom_documentfragment_prop_handlers, &dom_node_prop_handlers, NULL, false); zend_hash_merge(&dom_documentfragment_prop_handlers, &dom_node_prop_handlers, NULL, false);
zend_hash_add_new_ptr(&classes, dom_documentfragment_class_entry->name, &dom_documentfragment_prop_handlers); zend_hash_add_new_ptr(&classes, dom_documentfragment_class_entry->name, &dom_documentfragment_prop_handlers);
dom_modern_documentfragment_class_entry = register_class_DOM_DocumentFragment(dom_modern_node_class_entry, dom_modern_parentnode_class_entry); dom_modern_documentfragment_class_entry = register_class_Dom_DocumentFragment(dom_modern_node_class_entry, dom_modern_parentnode_class_entry);
dom_modern_documentfragment_class_entry->create_object = dom_objects_new; dom_modern_documentfragment_class_entry->create_object = dom_objects_new;
dom_modern_documentfragment_class_entry->default_object_handlers = &dom_object_handlers; dom_modern_documentfragment_class_entry->default_object_handlers = &dom_object_handlers;
zend_hash_init(&dom_modern_documentfragment_prop_handlers, 0, NULL, NULL, true); zend_hash_init(&dom_modern_documentfragment_prop_handlers, 0, NULL, NULL, true);
@ -832,7 +832,7 @@ PHP_MINIT_FUNCTION(dom)
DOM_OVERWRITE_PROP_HANDLER(&dom_modern_documentfragment_prop_handlers, "textContent", dom_node_text_content_read, dom_node_text_content_write); DOM_OVERWRITE_PROP_HANDLER(&dom_modern_documentfragment_prop_handlers, "textContent", dom_node_text_content_read, dom_node_text_content_write);
zend_hash_add_new_ptr(&classes, dom_modern_documentfragment_class_entry->name, &dom_modern_documentfragment_prop_handlers); zend_hash_add_new_ptr(&classes, dom_modern_documentfragment_class_entry->name, &dom_modern_documentfragment_prop_handlers);
dom_abstract_base_document_class_entry = register_class_DOM_Document(dom_modern_node_class_entry, dom_modern_parentnode_class_entry); dom_abstract_base_document_class_entry = register_class_Dom_Document(dom_modern_node_class_entry, dom_modern_parentnode_class_entry);
dom_abstract_base_document_class_entry->default_object_handlers = &dom_object_handlers; dom_abstract_base_document_class_entry->default_object_handlers = &dom_object_handlers;
zend_hash_init(&dom_abstract_base_document_prop_handlers, 0, NULL, NULL, true); zend_hash_init(&dom_abstract_base_document_prop_handlers, 0, NULL, NULL, true);
DOM_REGISTER_PROP_HANDLER(&dom_abstract_base_document_prop_handlers, "implementation", dom_modern_document_implementation_read, NULL); DOM_REGISTER_PROP_HANDLER(&dom_abstract_base_document_prop_handlers, "implementation", dom_modern_document_implementation_read, NULL);
@ -879,11 +879,11 @@ PHP_MINIT_FUNCTION(dom)
zend_hash_merge(&dom_document_prop_handlers, &dom_node_prop_handlers, NULL, false); zend_hash_merge(&dom_document_prop_handlers, &dom_node_prop_handlers, NULL, false);
zend_hash_add_new_ptr(&classes, dom_document_class_entry->name, &dom_document_prop_handlers); zend_hash_add_new_ptr(&classes, dom_document_class_entry->name, &dom_document_prop_handlers);
dom_html_document_class_entry = register_class_DOM_HTMLDocument(dom_abstract_base_document_class_entry); dom_html_document_class_entry = register_class_Dom_HTMLDocument(dom_abstract_base_document_class_entry);
dom_html_document_class_entry->default_object_handlers = &dom_object_handlers; dom_html_document_class_entry->default_object_handlers = &dom_object_handlers;
zend_hash_add_new_ptr(&classes, dom_html_document_class_entry->name, &dom_abstract_base_document_prop_handlers); zend_hash_add_new_ptr(&classes, dom_html_document_class_entry->name, &dom_abstract_base_document_prop_handlers);
dom_xml_document_class_entry = register_class_DOM_XMLDocument(dom_abstract_base_document_class_entry); dom_xml_document_class_entry = register_class_Dom_XMLDocument(dom_abstract_base_document_class_entry);
dom_xml_document_class_entry->default_object_handlers = &dom_object_handlers; dom_xml_document_class_entry->default_object_handlers = &dom_object_handlers;
zend_hash_init(&dom_xml_document_prop_handlers, 0, NULL, NULL, true); zend_hash_init(&dom_xml_document_prop_handlers, 0, NULL, NULL, true);
DOM_REGISTER_PROP_HANDLER(&dom_xml_document_prop_handlers, "xmlEncoding", dom_document_encoding_read, NULL); DOM_REGISTER_PROP_HANDLER(&dom_xml_document_prop_handlers, "xmlEncoding", dom_document_encoding_read, NULL);
@ -903,7 +903,7 @@ PHP_MINIT_FUNCTION(dom)
DOM_REGISTER_PROP_HANDLER(&dom_nodelist_prop_handlers, "length", dom_nodelist_length_read, NULL); DOM_REGISTER_PROP_HANDLER(&dom_nodelist_prop_handlers, "length", dom_nodelist_length_read, NULL);
zend_hash_add_new_ptr(&classes, dom_nodelist_class_entry->name, &dom_nodelist_prop_handlers); zend_hash_add_new_ptr(&classes, dom_nodelist_class_entry->name, &dom_nodelist_prop_handlers);
dom_modern_nodelist_class_entry = register_class_DOM_NodeList(zend_ce_aggregate, zend_ce_countable); dom_modern_nodelist_class_entry = register_class_Dom_NodeList(zend_ce_aggregate, zend_ce_countable);
dom_modern_nodelist_class_entry->create_object = dom_nnodemap_objects_new; dom_modern_nodelist_class_entry->create_object = dom_nnodemap_objects_new;
dom_modern_nodelist_class_entry->default_object_handlers = &dom_modern_nodelist_object_handlers; dom_modern_nodelist_class_entry->default_object_handlers = &dom_modern_nodelist_object_handlers;
dom_modern_nodelist_class_entry->get_iterator = php_dom_get_iterator; dom_modern_nodelist_class_entry->get_iterator = php_dom_get_iterator;
@ -919,21 +919,21 @@ PHP_MINIT_FUNCTION(dom)
DOM_REGISTER_PROP_HANDLER(&dom_namednodemap_prop_handlers, "length", dom_namednodemap_length_read, NULL); DOM_REGISTER_PROP_HANDLER(&dom_namednodemap_prop_handlers, "length", dom_namednodemap_length_read, NULL);
zend_hash_add_new_ptr(&classes, dom_namednodemap_class_entry->name, &dom_namednodemap_prop_handlers); zend_hash_add_new_ptr(&classes, dom_namednodemap_class_entry->name, &dom_namednodemap_prop_handlers);
dom_modern_namednodemap_class_entry = register_class_DOM_NamedNodeMap(zend_ce_aggregate, zend_ce_countable); dom_modern_namednodemap_class_entry = register_class_Dom_NamedNodeMap(zend_ce_aggregate, zend_ce_countable);
dom_modern_namednodemap_class_entry->create_object = dom_nnodemap_objects_new; dom_modern_namednodemap_class_entry->create_object = dom_nnodemap_objects_new;
dom_modern_namednodemap_class_entry->default_object_handlers = &dom_modern_nnodemap_object_handlers; dom_modern_namednodemap_class_entry->default_object_handlers = &dom_modern_nnodemap_object_handlers;
dom_modern_namednodemap_class_entry->get_iterator = php_dom_get_iterator; dom_modern_namednodemap_class_entry->get_iterator = php_dom_get_iterator;
zend_hash_add_new_ptr(&classes, dom_modern_namednodemap_class_entry->name, &dom_namednodemap_prop_handlers); zend_hash_add_new_ptr(&classes, dom_modern_namednodemap_class_entry->name, &dom_namednodemap_prop_handlers);
dom_modern_dtd_namednodemap_class_entry = register_class_DOM_DTDNamedNodeMap(zend_ce_aggregate, zend_ce_countable); dom_modern_dtd_namednodemap_class_entry = register_class_Dom_DtdNamedNodeMap(zend_ce_aggregate, zend_ce_countable);
dom_modern_dtd_namednodemap_class_entry->create_object = dom_nnodemap_objects_new; dom_modern_dtd_namednodemap_class_entry->create_object = dom_nnodemap_objects_new;
dom_modern_dtd_namednodemap_class_entry->default_object_handlers = &dom_modern_nnodemap_object_handlers; dom_modern_dtd_namednodemap_class_entry->default_object_handlers = &dom_modern_nnodemap_object_handlers;
dom_modern_dtd_namednodemap_class_entry->get_iterator = php_dom_get_iterator; dom_modern_dtd_namednodemap_class_entry->get_iterator = php_dom_get_iterator;
zend_hash_add_new_ptr(&classes, dom_modern_dtd_namednodemap_class_entry->name, &dom_namednodemap_prop_handlers); zend_hash_add_new_ptr(&classes, dom_modern_dtd_namednodemap_class_entry->name, &dom_namednodemap_prop_handlers);
dom_html_collection_class_entry = register_class_DOM_HTMLCollection(zend_ce_aggregate, zend_ce_countable); dom_html_collection_class_entry = register_class_Dom_HTMLCollection(zend_ce_aggregate, zend_ce_countable);
dom_html_collection_class_entry->create_object = dom_nnodemap_objects_new; dom_html_collection_class_entry->create_object = dom_nnodemap_objects_new;
dom_html_collection_class_entry->default_object_handlers = &dom_html_collection_object_handlers; dom_html_collection_class_entry->default_object_handlers = &dom_html_collection_object_handlers;
dom_html_collection_class_entry->get_iterator = php_dom_get_iterator; dom_html_collection_class_entry->get_iterator = php_dom_get_iterator;
@ -952,7 +952,7 @@ PHP_MINIT_FUNCTION(dom)
zend_hash_merge(&dom_characterdata_prop_handlers, &dom_node_prop_handlers, NULL, false); zend_hash_merge(&dom_characterdata_prop_handlers, &dom_node_prop_handlers, NULL, false);
zend_hash_add_new_ptr(&classes, dom_characterdata_class_entry->name, &dom_characterdata_prop_handlers); zend_hash_add_new_ptr(&classes, dom_characterdata_class_entry->name, &dom_characterdata_prop_handlers);
dom_modern_characterdata_class_entry = register_class_DOM_CharacterData(dom_modern_node_class_entry, dom_modern_childnode_class_entry); dom_modern_characterdata_class_entry = register_class_Dom_CharacterData(dom_modern_node_class_entry, dom_modern_childnode_class_entry);
dom_modern_characterdata_class_entry->create_object = dom_objects_new; dom_modern_characterdata_class_entry->create_object = dom_objects_new;
dom_modern_characterdata_class_entry->default_object_handlers = &dom_object_handlers; dom_modern_characterdata_class_entry->default_object_handlers = &dom_object_handlers;
@ -979,7 +979,7 @@ PHP_MINIT_FUNCTION(dom)
zend_hash_merge(&dom_attr_prop_handlers, &dom_node_prop_handlers, NULL, false); zend_hash_merge(&dom_attr_prop_handlers, &dom_node_prop_handlers, NULL, false);
zend_hash_add_new_ptr(&classes, dom_attr_class_entry->name, &dom_attr_prop_handlers); zend_hash_add_new_ptr(&classes, dom_attr_class_entry->name, &dom_attr_prop_handlers);
dom_modern_attr_class_entry = register_class_DOM_Attr(dom_modern_node_class_entry); dom_modern_attr_class_entry = register_class_Dom_Attr(dom_modern_node_class_entry);
dom_modern_attr_class_entry->create_object = dom_objects_new; dom_modern_attr_class_entry->create_object = dom_objects_new;
dom_modern_attr_class_entry->default_object_handlers = &dom_object_handlers; dom_modern_attr_class_entry->default_object_handlers = &dom_object_handlers;
@ -1013,7 +1013,7 @@ PHP_MINIT_FUNCTION(dom)
zend_hash_merge(&dom_element_prop_handlers, &dom_node_prop_handlers, NULL, false); zend_hash_merge(&dom_element_prop_handlers, &dom_node_prop_handlers, NULL, false);
zend_hash_add_new_ptr(&classes, dom_element_class_entry->name, &dom_element_prop_handlers); zend_hash_add_new_ptr(&classes, dom_element_class_entry->name, &dom_element_prop_handlers);
dom_modern_element_class_entry = register_class_DOM_Element(dom_modern_node_class_entry, dom_modern_parentnode_class_entry, dom_modern_childnode_class_entry); dom_modern_element_class_entry = register_class_Dom_Element(dom_modern_node_class_entry, dom_modern_parentnode_class_entry, dom_modern_childnode_class_entry);
dom_modern_element_class_entry->create_object = dom_objects_new; dom_modern_element_class_entry->create_object = dom_objects_new;
dom_modern_element_class_entry->default_object_handlers = &dom_object_handlers; dom_modern_element_class_entry->default_object_handlers = &dom_object_handlers;
@ -1043,7 +1043,7 @@ PHP_MINIT_FUNCTION(dom)
zend_hash_merge(&dom_text_prop_handlers, &dom_characterdata_prop_handlers, NULL, false); zend_hash_merge(&dom_text_prop_handlers, &dom_characterdata_prop_handlers, NULL, false);
zend_hash_add_new_ptr(&classes, dom_text_class_entry->name, &dom_text_prop_handlers); zend_hash_add_new_ptr(&classes, dom_text_class_entry->name, &dom_text_prop_handlers);
dom_modern_text_class_entry = register_class_DOM_Text(dom_modern_characterdata_class_entry); dom_modern_text_class_entry = register_class_Dom_Text(dom_modern_characterdata_class_entry);
dom_modern_text_class_entry->create_object = dom_objects_new; dom_modern_text_class_entry->create_object = dom_objects_new;
dom_modern_text_class_entry->default_object_handlers = &dom_object_handlers; dom_modern_text_class_entry->default_object_handlers = &dom_object_handlers;
@ -1057,7 +1057,7 @@ PHP_MINIT_FUNCTION(dom)
dom_comment_class_entry->default_object_handlers = &dom_object_handlers; dom_comment_class_entry->default_object_handlers = &dom_object_handlers;
zend_hash_add_new_ptr(&classes, dom_comment_class_entry->name, &dom_characterdata_prop_handlers); zend_hash_add_new_ptr(&classes, dom_comment_class_entry->name, &dom_characterdata_prop_handlers);
dom_modern_comment_class_entry = register_class_DOM_Comment(dom_modern_characterdata_class_entry); dom_modern_comment_class_entry = register_class_Dom_Comment(dom_modern_characterdata_class_entry);
dom_modern_comment_class_entry->create_object = dom_objects_new; dom_modern_comment_class_entry->create_object = dom_objects_new;
dom_modern_comment_class_entry->default_object_handlers = &dom_object_handlers; dom_modern_comment_class_entry->default_object_handlers = &dom_object_handlers;
zend_hash_add_new_ptr(&classes, dom_modern_comment_class_entry->name, &dom_modern_characterdata_prop_handlers); zend_hash_add_new_ptr(&classes, dom_modern_comment_class_entry->name, &dom_modern_characterdata_prop_handlers);
@ -1067,7 +1067,7 @@ PHP_MINIT_FUNCTION(dom)
dom_cdatasection_class_entry->default_object_handlers = &dom_object_handlers; dom_cdatasection_class_entry->default_object_handlers = &dom_object_handlers;
zend_hash_add_new_ptr(&classes, dom_cdatasection_class_entry->name, &dom_text_prop_handlers); zend_hash_add_new_ptr(&classes, dom_cdatasection_class_entry->name, &dom_text_prop_handlers);
dom_modern_cdatasection_class_entry = register_class_DOM_CDATASection(dom_modern_text_class_entry); dom_modern_cdatasection_class_entry = register_class_Dom_CDATASection(dom_modern_text_class_entry);
dom_modern_cdatasection_class_entry->create_object = dom_objects_new; dom_modern_cdatasection_class_entry->create_object = dom_objects_new;
dom_modern_cdatasection_class_entry->default_object_handlers = &dom_object_handlers; dom_modern_cdatasection_class_entry->default_object_handlers = &dom_object_handlers;
zend_hash_add_new_ptr(&classes, dom_modern_cdatasection_class_entry->name, &dom_modern_text_prop_handlers); zend_hash_add_new_ptr(&classes, dom_modern_cdatasection_class_entry->name, &dom_modern_text_prop_handlers);
@ -1086,7 +1086,7 @@ PHP_MINIT_FUNCTION(dom)
zend_hash_merge(&dom_documenttype_prop_handlers, &dom_node_prop_handlers, NULL, false); zend_hash_merge(&dom_documenttype_prop_handlers, &dom_node_prop_handlers, NULL, false);
zend_hash_add_new_ptr(&classes, dom_documenttype_class_entry->name, &dom_documenttype_prop_handlers); zend_hash_add_new_ptr(&classes, dom_documenttype_class_entry->name, &dom_documenttype_prop_handlers);
dom_modern_documenttype_class_entry = register_class_DOM_DocumentType(dom_modern_node_class_entry, dom_modern_childnode_class_entry); dom_modern_documenttype_class_entry = register_class_Dom_DocumentType(dom_modern_node_class_entry, dom_modern_childnode_class_entry);
dom_modern_documenttype_class_entry->create_object = dom_objects_new; dom_modern_documenttype_class_entry->create_object = dom_objects_new;
dom_modern_documenttype_class_entry->default_object_handlers = &dom_object_handlers; dom_modern_documenttype_class_entry->default_object_handlers = &dom_object_handlers;
@ -1110,7 +1110,7 @@ PHP_MINIT_FUNCTION(dom)
zend_hash_merge(&dom_notation_prop_handlers, &dom_node_prop_handlers, NULL, false); zend_hash_merge(&dom_notation_prop_handlers, &dom_node_prop_handlers, NULL, false);
zend_hash_add_new_ptr(&classes, dom_notation_class_entry->name, &dom_notation_prop_handlers); zend_hash_add_new_ptr(&classes, dom_notation_class_entry->name, &dom_notation_prop_handlers);
dom_modern_notation_class_entry = register_class_DOM_Notation(dom_modern_node_class_entry); dom_modern_notation_class_entry = register_class_Dom_Notation(dom_modern_node_class_entry);
dom_modern_notation_class_entry->create_object = dom_objects_new; dom_modern_notation_class_entry->create_object = dom_objects_new;
dom_modern_notation_class_entry->default_object_handlers = &dom_object_handlers; dom_modern_notation_class_entry->default_object_handlers = &dom_object_handlers;
@ -1134,7 +1134,7 @@ PHP_MINIT_FUNCTION(dom)
zend_hash_merge(&dom_entity_prop_handlers, &dom_node_prop_handlers, NULL, false); zend_hash_merge(&dom_entity_prop_handlers, &dom_node_prop_handlers, NULL, false);
zend_hash_add_new_ptr(&classes, dom_entity_class_entry->name, &dom_entity_prop_handlers); zend_hash_add_new_ptr(&classes, dom_entity_class_entry->name, &dom_entity_prop_handlers);
dom_modern_entity_class_entry = register_class_DOM_Entity(dom_modern_node_class_entry); dom_modern_entity_class_entry = register_class_Dom_Entity(dom_modern_node_class_entry);
dom_modern_entity_class_entry->create_object = dom_objects_new; dom_modern_entity_class_entry->create_object = dom_objects_new;
dom_modern_entity_class_entry->default_object_handlers = &dom_object_handlers; dom_modern_entity_class_entry->default_object_handlers = &dom_object_handlers;
@ -1157,7 +1157,7 @@ PHP_MINIT_FUNCTION(dom)
DOM_OVERWRITE_PROP_HANDLER(&dom_entity_reference_prop_handlers, "childNodes", dom_entity_reference_child_nodes_read, NULL); DOM_OVERWRITE_PROP_HANDLER(&dom_entity_reference_prop_handlers, "childNodes", dom_entity_reference_child_nodes_read, NULL);
zend_hash_add_new_ptr(&classes, dom_entityreference_class_entry->name, &dom_entity_reference_prop_handlers); zend_hash_add_new_ptr(&classes, dom_entityreference_class_entry->name, &dom_entity_reference_prop_handlers);
dom_modern_entityreference_class_entry = register_class_DOM_EntityReference(dom_modern_node_class_entry); dom_modern_entityreference_class_entry = register_class_Dom_EntityReference(dom_modern_node_class_entry);
dom_modern_entityreference_class_entry->create_object = dom_objects_new; dom_modern_entityreference_class_entry->create_object = dom_objects_new;
dom_modern_entityreference_class_entry->default_object_handlers = &dom_object_handlers; dom_modern_entityreference_class_entry->default_object_handlers = &dom_object_handlers;
@ -1179,7 +1179,7 @@ PHP_MINIT_FUNCTION(dom)
zend_hash_merge(&dom_processinginstruction_prop_handlers, &dom_node_prop_handlers, NULL, false); zend_hash_merge(&dom_processinginstruction_prop_handlers, &dom_node_prop_handlers, NULL, false);
zend_hash_add_new_ptr(&classes, dom_processinginstruction_class_entry->name, &dom_processinginstruction_prop_handlers); zend_hash_add_new_ptr(&classes, dom_processinginstruction_class_entry->name, &dom_processinginstruction_prop_handlers);
dom_modern_processinginstruction_class_entry = register_class_DOM_ProcessingInstruction(dom_modern_characterdata_class_entry); dom_modern_processinginstruction_class_entry = register_class_Dom_ProcessingInstruction(dom_modern_characterdata_class_entry);
dom_modern_processinginstruction_class_entry->create_object = dom_objects_new; dom_modern_processinginstruction_class_entry->create_object = dom_objects_new;
dom_modern_processinginstruction_class_entry->default_object_handlers = &dom_object_handlers; dom_modern_processinginstruction_class_entry->default_object_handlers = &dom_object_handlers;
@ -1205,7 +1205,7 @@ PHP_MINIT_FUNCTION(dom)
DOM_REGISTER_PROP_HANDLER(&dom_xpath_prop_handlers, "registerNodeNamespaces", dom_xpath_register_node_ns_read, dom_xpath_register_node_ns_write); DOM_REGISTER_PROP_HANDLER(&dom_xpath_prop_handlers, "registerNodeNamespaces", dom_xpath_register_node_ns_read, dom_xpath_register_node_ns_write);
zend_hash_add_new_ptr(&classes, dom_xpath_class_entry->name, &dom_xpath_prop_handlers); zend_hash_add_new_ptr(&classes, dom_xpath_class_entry->name, &dom_xpath_prop_handlers);
dom_modern_xpath_class_entry = register_class_DOM_XPath(); dom_modern_xpath_class_entry = register_class_Dom_XPath();
dom_modern_xpath_class_entry->create_object = dom_xpath_objects_new; dom_modern_xpath_class_entry->create_object = dom_xpath_objects_new;
dom_modern_xpath_class_entry->default_object_handlers = &dom_xpath_object_handlers; dom_modern_xpath_class_entry->default_object_handlers = &dom_xpath_object_handlers;

View file

@ -889,7 +889,7 @@ namespace
public function replaceChildren(...$nodes): void {} public function replaceChildren(...$nodes): void {}
} }
/** @alias DOM\DOMException */ /** @alias Dom\DOMException */
final class DOMException extends Exception final class DOMException extends Exception
{ {
/** /**
@ -1025,7 +1025,7 @@ namespace
function dom_import_simplexml(object $node): DOMElement {} function dom_import_simplexml(object $node): DOMElement {}
} }
namespace DOM namespace Dom
{ {
/** /**
* @var int * @var int
@ -1252,7 +1252,7 @@ namespace DOM
public function getIterator(): \Iterator {} public function getIterator(): \Iterator {}
} }
class DTDNamedNodeMap implements \IteratorAggregate, \Countable class DtdNamedNodeMap implements \IteratorAggregate, \Countable
{ {
/** @readonly */ /** @readonly */
public int $length; public int $length;
@ -1330,7 +1330,7 @@ namespace DOM
public function getAttributeNode(string $qualifiedName): ?Attr {} public function getAttributeNode(string $qualifiedName): ?Attr {}
/** @implementation-alias DOMElement::getAttributeNodeNS */ /** @implementation-alias DOMElement::getAttributeNodeNS */
public function getAttributeNodeNS(?string $namespace, string $localName): ?Attr {} public function getAttributeNodeNS(?string $namespace, string $localName): ?Attr {}
/** @implementation-alias DOM\Element::setAttributeNodeNS */ /** @implementation-alias Dom\Element::setAttributeNodeNS */
public function setAttributeNode(Attr $attr) : ?Attr {} public function setAttributeNode(Attr $attr) : ?Attr {}
public function setAttributeNodeNS(Attr $attr) : ?Attr {} public function setAttributeNodeNS(Attr $attr) : ?Attr {}
public function removeAttributeNode(Attr $attr) : Attr {} public function removeAttributeNode(Attr $attr) : Attr {}
@ -1452,9 +1452,9 @@ namespace DOM
/** @readonly */ /** @readonly */
public string $name; public string $name;
/** @readonly */ /** @readonly */
public DTDNamedNodeMap $entities; public DtdNamedNodeMap $entities;
/** @readonly */ /** @readonly */
public DTDNamedNodeMap $notations; public DtdNamedNodeMap $notations;
/** @readonly */ /** @readonly */
public string $publicId; public string $publicId;
/** @readonly */ /** @readonly */
@ -1482,7 +1482,7 @@ namespace DOM
public int $childElementCount; public int $childElementCount;
/** @implementation-alias DOMDocumentFragment::appendXML */ /** @implementation-alias DOMDocumentFragment::appendXML */
public function appendXML(string $data): bool {} public function appendXml(string $data): bool {}
/** @implementation-alias DOMElement::append */ /** @implementation-alias DOMElement::append */
public function append(Node|string ...$nodes): void {} public function append(Node|string ...$nodes): void {}
/** @implementation-alias DOMElement::prepend */ /** @implementation-alias DOMElement::prepend */
@ -1525,9 +1525,9 @@ namespace DOM
public ?DocumentType $doctype; public ?DocumentType $doctype;
/** @readonly */ /** @readonly */
public ?Element $documentElement; public ?Element $documentElement;
/** @implementation-alias DOM\Element::getElementsByTagName */ /** @implementation-alias Dom\Element::getElementsByTagName */
public function getElementsByTagName(string $qualifiedName): HTMLCollection {} public function getElementsByTagName(string $qualifiedName): HTMLCollection {}
/** @implementation-alias DOM\Element::getElementsByTagNameNS */ /** @implementation-alias Dom\Element::getElementsByTagNameNS */
public function getElementsByTagNameNS(?string $namespace, string $localName): HTMLCollection {} public function getElementsByTagNameNS(?string $namespace, string $localName): HTMLCollection {}
public function createElement(string $localName): Element {} public function createElement(string $localName): Element {}
@ -1568,9 +1568,9 @@ namespace DOM
/** @implementation-alias DOMDocument::schemaValidateSource */ /** @implementation-alias DOMDocument::schemaValidateSource */
public function schemaValidateSource(string $source, int $flags = 0): bool {} public function schemaValidateSource(string $source, int $flags = 0): bool {}
/** @implementation-alias DOMDocument::relaxNGValidate */ /** @implementation-alias DOMDocument::relaxNGValidate */
public function relaxNGValidate(string $filename): bool {} public function relaxNgValidate(string $filename): bool {}
/** @implementation-alias DOMDocument::relaxNGValidateSource */ /** @implementation-alias DOMDocument::relaxNGValidateSource */
public function relaxNGValidateSource(string $source): bool {} public function relaxNgValidateSource(string $source): bool {}
#endif #endif
/** @implementation-alias DOMElement::append */ /** @implementation-alias DOMElement::append */
@ -1591,15 +1591,15 @@ namespace DOM
public static function createFromString(string $source, int $options = 0, ?string $overrideEncoding = null): HTMLDocument {} public static function createFromString(string $source, int $options = 0, ?string $overrideEncoding = null): HTMLDocument {}
/** @implementation-alias DOM\XMLDocument::saveXML */ /** @implementation-alias Dom\XMLDocument::saveXml */
public function saveXML(?Node $node = null, int $options = 0): string|false {} public function saveXml(?Node $node = null, int $options = 0): string|false {}
/** @implementation-alias DOMDocument::save */ /** @implementation-alias DOMDocument::save */
public function saveXMLFile(string $filename, int $options = 0): int|false {} public function saveXmlFile(string $filename, int $options = 0): int|false {}
public function saveHTML(?Node $node = null): string {} public function saveHtml(?Node $node = null): string {}
public function saveHTMLFile(string $filename): int|false {} public function saveHtmlFile(string $filename): int|false {}
} }
final class XMLDocument extends Document final class XMLDocument extends Document
@ -1628,10 +1628,10 @@ namespace DOM
/** @implementation-alias DOMDocument::xinclude */ /** @implementation-alias DOMDocument::xinclude */
public function xinclude(int $options = 0): int|false {} public function xinclude(int $options = 0): int|false {}
public function saveXML(?Node $node = null, int $options = 0): string|false {} public function saveXml(?Node $node = null, int $options = 0): string|false {}
/** @implementation-alias DOMDocument::save */ /** @implementation-alias DOMDocument::save */
public function saveXMLFile(string $filename, int $options = 0): int|false {} public function saveXmlFile(string $filename, int $options = 0): int|false {}
} }
#ifdef LIBXML_XPATH_ENABLED #ifdef LIBXML_XPATH_ENABLED

1036
ext/dom/php_dom_arginfo.h generated

File diff suppressed because it is too large Load diff

View file

@ -15,7 +15,7 @@ print $dom->ownerDocument->saveXML();
// This should fail because it has been imported already above in legacy DOM // This should fail because it has been imported already above in legacy DOM
try { try {
DOM\import_simplexml($s); Dom\import_simplexml($s);
} catch (TypeError $e) { } catch (TypeError $e) {
echo $e->getMessage(), "\n"; echo $e->getMessage(), "\n";
} }
@ -32,4 +32,4 @@ try {
<author>John Steinbeck</author> <author>John Steinbeck</author>
</book> </book>
</books> </books>
DOM\import_simplexml(): Argument #1 ($node) must not be already imported as a DOMNode Dom\import_simplexml(): Argument #1 ($node) must not be already imported as a DOMNode

View file

@ -6,7 +6,7 @@ dom
<?php <?php
foreach (['firstChild', 'lastChild', 'textContent', 'childNodes'] as $prop) { foreach (['firstChild', 'lastChild', 'textContent', 'childNodes'] as $prop) {
$dom = DOM\XMLDocument::createFromString(<<<XML $dom = Dom\XMLDocument::createFromString(<<<XML
<!DOCTYPE foo [ <!DOCTYPE foo [
<!ENTITY foo "bar"> <!ENTITY foo "bar">
]> ]>
@ -28,7 +28,7 @@ foreach (['firstChild', 'lastChild', 'textContent', 'childNodes'] as $prop) {
NULL NULL
NULL NULL
NULL NULL
object(DOM\NodeList)#1 (1) { object(Dom\NodeList)#1 (1) {
["length"]=> ["length"]=>
int(0) int(0)
} }

View file

@ -26,7 +26,7 @@ function createTestDoc(DomType $type) {
$doc->preserveWhiteSpace = false; $doc->preserveWhiteSpace = false;
$doc->loadXML($xml); $doc->loadXML($xml);
} else { } else {
$doc = DOM\XMLDocument::createFromString($xml, LIBXML_NOBLANKS); $doc = Dom\XMLDocument::createFromString($xml, LIBXML_NOBLANKS);
} }
return $doc; return $doc;

View file

@ -5,7 +5,7 @@ dom
--FILE-- --FILE--
<?php <?php
$xml = DOM\XMLDocument::createFromString(<<<XML $xml = Dom\XMLDocument::createFromString(<<<XML
<!DOCTYPE root [ <!DOCTYPE root [
<!ENTITY foo "foo"> <!ENTITY foo "foo">
]> ]>
@ -13,11 +13,11 @@ $xml = DOM\XMLDocument::createFromString(<<<XML
XML); XML);
$el = $xml->documentElement->firstChild; $el = $xml->documentElement->firstChild;
echo $xml->saveXML(), "\n"; echo $xml->saveXml(), "\n";
$html = DOM\HTMLDocument::createEmpty(); $html = Dom\HTMLDocument::createEmpty();
$html->append($html->importNode($el, true)); $html->append($html->importNode($el, true));
echo $html->saveHTML(), "\n"; echo $html->saveHtml(), "\n";
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,21 +1,21 @@
--TEST-- --TEST--
DOM\HTMLDocument GB18030 encoding test Dom\HTMLDocument GB18030 encoding test
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromFile(__DIR__ . "/gb18030.html"); $dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/gb18030.html");
var_dump($dom->charset); var_dump($dom->charset);
$dom->documentElement->firstChild->nextElementSibling->textContent = "é"; $dom->documentElement->firstChild->nextElementSibling->textContent = "é";
$output = $dom->saveHTML(); $output = $dom->saveHtml();
echo $output, "\n"; echo $output, "\n";
$dom->saveHTMLFile(__DIR__ . "/gb18030_output.tmp"); $dom->saveHtmlFile(__DIR__ . "/gb18030_output.tmp");
var_dump(file_get_contents(__DIR__ . "/gb18030_output.tmp") === $output); var_dump(file_get_contents(__DIR__ . "/gb18030_output.tmp") === $output);
echo "--- After changing encoding to UTF-8 ---\n"; echo "--- After changing encoding to UTF-8 ---\n";
$dom->charset = "UTF-8"; $dom->charset = "UTF-8";
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
?> ?>
--CLEAN-- --CLEAN--

View file

@ -1,21 +1,21 @@
--TEST-- --TEST--
DOM\HTMLDocument Shift JIS encoding test Dom\HTMLDocument Shift JIS encoding test
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromFile(__DIR__ . "/shift_jis.html"); $dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/shift_jis.html");
var_dump($dom->charset); var_dump($dom->charset);
$dom->documentElement->firstChild->nextElementSibling->textContent .= "é"; $dom->documentElement->firstChild->nextElementSibling->textContent .= "é";
$output = $dom->saveHTML(); $output = $dom->saveHtml();
echo $output, "\n"; echo $output, "\n";
$dom->saveHTMLFile(__DIR__ . "/shift_jis.tmp"); $dom->saveHtmlFile(__DIR__ . "/shift_jis.tmp");
var_dump(file_get_contents(__DIR__ . "/shift_jis.tmp") === $output); var_dump(file_get_contents(__DIR__ . "/shift_jis.tmp") === $output);
echo "--- After changing encoding to UTF-8 ---\n"; echo "--- After changing encoding to UTF-8 ---\n";
$dom->charset = "UTF-8"; $dom->charset = "UTF-8";
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
?> ?>
--CLEAN-- --CLEAN--

View file

@ -1,21 +1,21 @@
--TEST-- --TEST--
DOM\HTMLDocument UTF-16BE BOM encoding test Dom\HTMLDocument UTF-16BE BOM encoding test
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromFile(__DIR__ . "/utf16be_bom.html"); $dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/utf16be_bom.html");
var_dump($dom->characterSet); var_dump($dom->characterSet);
$dom->documentElement->firstChild->nextElementSibling->textContent = "é"; $dom->documentElement->firstChild->nextElementSibling->textContent = "é";
$output = $dom->saveHTML(); $output = $dom->saveHtml();
echo $output, "\n"; echo $output, "\n";
$dom->saveHTMLFile(__DIR__ . "/utf16be_bom_output.tmp"); $dom->saveHtmlFile(__DIR__ . "/utf16be_bom_output.tmp");
var_dump(file_get_contents(__DIR__ . "/utf16be_bom_output.tmp") === $output); var_dump(file_get_contents(__DIR__ . "/utf16be_bom_output.tmp") === $output);
echo "--- After changing encoding to UTF-8 ---\n"; echo "--- After changing encoding to UTF-8 ---\n";
$dom->characterSet = "UTF-8"; $dom->characterSet = "UTF-8";
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
?> ?>
--CLEAN-- --CLEAN--

View file

@ -1,21 +1,21 @@
--TEST-- --TEST--
DOM\HTMLDocument UTF-16LE BOM encoding test Dom\HTMLDocument UTF-16LE BOM encoding test
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromFile(__DIR__ . "/utf16le_bom.html"); $dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/utf16le_bom.html");
var_dump($dom->inputEncoding); var_dump($dom->inputEncoding);
$dom->documentElement->firstChild->nextElementSibling->textContent = "é"; $dom->documentElement->firstChild->nextElementSibling->textContent = "é";
$output = $dom->saveHTML(); $output = $dom->saveHtml();
echo $output, "\n"; echo $output, "\n";
$dom->saveHTMLFile(__DIR__ . "/utf16le_bom_output.tmp"); $dom->saveHtmlFile(__DIR__ . "/utf16le_bom_output.tmp");
var_dump(file_get_contents(__DIR__ . "/utf16le_bom_output.tmp") === $output); var_dump(file_get_contents(__DIR__ . "/utf16le_bom_output.tmp") === $output);
echo "--- After changing encoding to UTF-8 ---\n"; echo "--- After changing encoding to UTF-8 ---\n";
$dom->inputEncoding = "UTF-8"; $dom->inputEncoding = "UTF-8";
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
?> ?>
--CLEAN-- --CLEAN--

View file

@ -1,21 +1,21 @@
--TEST-- --TEST--
DOM\HTMLDocument UTF-8 BOM encoding test Dom\HTMLDocument UTF-8 BOM encoding test
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromFile(__DIR__ . "/utf8_bom.html"); $dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/utf8_bom.html");
var_dump($dom->charset); var_dump($dom->charset);
$dom->documentElement->firstChild->nextElementSibling->textContent = "é"; $dom->documentElement->firstChild->nextElementSibling->textContent = "é";
$output = $dom->saveHTML(); $output = $dom->saveHtml();
echo $output, "\n"; echo $output, "\n";
$dom->saveHTMLFile(__DIR__ . "/utf8_bom_output.tmp"); $dom->saveHtmlFile(__DIR__ . "/utf8_bom_output.tmp");
var_dump(file_get_contents(__DIR__ . "/utf8_bom_output.tmp") === $output); var_dump(file_get_contents(__DIR__ . "/utf8_bom_output.tmp") === $output);
echo "--- After changing encoding to UTF-8 ---\n"; echo "--- After changing encoding to UTF-8 ---\n";
$dom->charset = "UTF-8"; $dom->charset = "UTF-8";
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
?> ?>
--CLEAN-- --CLEAN--

View file

@ -1,21 +1,21 @@
--TEST-- --TEST--
DOM\HTMLDocument Windows-1251 encoding test Dom\HTMLDocument Windows-1251 encoding test
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromFile(__DIR__ . "/windows1251.html"); $dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/windows1251.html");
var_dump($dom->charset); var_dump($dom->charset);
$dom->documentElement->firstChild->nextElementSibling->textContent .= "é"; // Note: won't show up in Windows 1251 because it doesn't exist there $dom->documentElement->firstChild->nextElementSibling->textContent .= "é"; // Note: won't show up in Windows 1251 because it doesn't exist there
$output = $dom->saveHTML(); $output = $dom->saveHtml();
echo $output, "\n"; echo $output, "\n";
$dom->saveHTMLFile(__DIR__ . "/windows1251_output.tmp"); $dom->saveHtmlFile(__DIR__ . "/windows1251_output.tmp");
var_dump(file_get_contents(__DIR__ . "/windows1251_output.tmp") === $output); var_dump(file_get_contents(__DIR__ . "/windows1251_output.tmp") === $output);
echo "--- After changing encoding to UTF-8 ---\n"; echo "--- After changing encoding to UTF-8 ---\n";
$dom->charset = "UTF-8"; $dom->charset = "UTF-8";
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
?> ?>
--CLEAN-- --CLEAN--

View file

@ -1,5 +1,5 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromFile() HTTP header Content-Type Dom\HTMLDocument::createFromFile() HTTP header Content-Type
--EXTENSIONS-- --EXTENSIONS--
dom dom
--SKIPIF-- --SKIPIF--
@ -62,7 +62,7 @@ foreach ($tests as $name => $headers) {
$responses = array_map(fn ($header) => "data://text/plain,HTTP/1.1 200 OK\r\nContent-Type: " . $header . "\r\n\r\n" . "<p>\xE4\xF6\xFC</p>\n", $headers); $responses = array_map(fn ($header) => "data://text/plain,HTTP/1.1 200 OK\r\nContent-Type: " . $header . "\r\n\r\n" . "<p>\xE4\xF6\xFC</p>\n", $headers);
['pid' => $pid, 'uri' => $uri] = http_server($responses); ['pid' => $pid, 'uri' => $uri] = http_server($responses);
for ($i = 0; $i < count($responses); $i++) { for ($i = 0; $i < count($responses); $i++) {
$result = DOM\HTMLDocument::createFromFile($uri, LIBXML_NOERROR); $result = Dom\HTMLDocument::createFromFile($uri, LIBXML_NOERROR);
echo $result->getElementsByTagName("p")[0]->textContent, "\n"; echo $result->getElementsByTagName("p")[0]->textContent, "\n";
} }
http_server_kill($pid); http_server_kill($pid);

View file

@ -1,29 +1,29 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromFile() with overrideEncoding Dom\HTMLDocument::createFromFile() with overrideEncoding
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
try { try {
DOM\HTMLDocument::createFromFile(__DIR__ . '/gb18030_without_charset.html', overrideEncoding: 'nonexistent'); Dom\HTMLDocument::createFromFile(__DIR__ . '/gb18030_without_charset.html', overrideEncoding: 'nonexistent');
} catch (ValueError $e) { } catch (ValueError $e) {
echo $e->getMessage(), "\n"; echo $e->getMessage(), "\n";
} }
// The override encoding matches with the document encoding attribute // The override encoding matches with the document encoding attribute
$dom = DOM\HTMLDocument::createFromFile(__DIR__ . '/gb18030_without_charset.html', overrideEncoding: 'GB18030'); $dom = Dom\HTMLDocument::createFromFile(__DIR__ . '/gb18030_without_charset.html', overrideEncoding: 'GB18030');
var_dump($dom->documentElement->lastChild->textContent); var_dump($dom->documentElement->lastChild->textContent);
var_dump($dom->charset); var_dump($dom->charset);
// The override encoding mismatches with the document encoding attribute // The override encoding mismatches with the document encoding attribute
$dom = DOM\HTMLDocument::createFromFile(__DIR__ . '/fallback_encoding.html', overrideEncoding: 'Windows-1252'); $dom = Dom\HTMLDocument::createFromFile(__DIR__ . '/fallback_encoding.html', overrideEncoding: 'Windows-1252');
var_dump($dom->documentElement->lastChild->textContent); var_dump($dom->documentElement->lastChild->textContent);
var_dump($dom->charset); var_dump($dom->charset);
?> ?>
--EXPECT-- --EXPECT--
DOM\HTMLDocument::createFromFile(): Argument #3 ($overrideEncoding) must be a valid document encoding Dom\HTMLDocument::createFromFile(): Argument #3 ($overrideEncoding) must be a valid document encoding
string(20) " string(20) "
Héllo, world! Héllo, world!
" "

View file

@ -1,29 +1,29 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromString() with overrideEncoding Dom\HTMLDocument::createFromString() with overrideEncoding
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
try { try {
DOM\HTMLDocument::createFromString(file_get_contents(__DIR__ . '/gb18030_without_charset.html'), overrideEncoding: 'nonexistent'); Dom\HTMLDocument::createFromString(file_get_contents(__DIR__ . '/gb18030_without_charset.html'), overrideEncoding: 'nonexistent');
} catch (ValueError $e) { } catch (ValueError $e) {
echo $e->getMessage(), "\n"; echo $e->getMessage(), "\n";
} }
// The override encoding matches with the document encoding attribute // The override encoding matches with the document encoding attribute
$dom = DOM\HTMLDocument::createFromString(file_get_contents(__DIR__ . '/gb18030_without_charset.html'), overrideEncoding: 'GB18030'); $dom = Dom\HTMLDocument::createFromString(file_get_contents(__DIR__ . '/gb18030_without_charset.html'), overrideEncoding: 'GB18030');
var_dump($dom->documentElement->lastChild->textContent); var_dump($dom->documentElement->lastChild->textContent);
var_dump($dom->charset); var_dump($dom->charset);
// The override encoding mismatches with the document encoding attribute // The override encoding mismatches with the document encoding attribute
$dom = DOM\HTMLDocument::createFromString(file_get_contents(__DIR__ . '/fallback_encoding.html'), overrideEncoding: 'Windows-1252'); $dom = Dom\HTMLDocument::createFromString(file_get_contents(__DIR__ . '/fallback_encoding.html'), overrideEncoding: 'Windows-1252');
var_dump($dom->documentElement->lastChild->textContent); var_dump($dom->documentElement->lastChild->textContent);
var_dump($dom->charset); var_dump($dom->charset);
?> ?>
--EXPECT-- --EXPECT--
DOM\HTMLDocument::createFromString(): Argument #3 ($overrideEncoding) must be a valid document encoding Dom\HTMLDocument::createFromString(): Argument #3 ($overrideEncoding) must be a valid document encoding
string(20) " string(20) "
Héllo, world! Héllo, world!
" "

View file

@ -1,5 +1,5 @@
--TEST-- --TEST--
DOM\HTMLDocument edge case encoding 01 Dom\HTMLDocument edge case encoding 01
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
@ -7,11 +7,11 @@ dom
// UTF-8 -> UTF-8 // UTF-8 -> UTF-8
// Create a UTF-8 string where a UTF-8 byte sequence falls over the boundary of the 4096 byte buffer // Create a UTF-8 string where a UTF-8 byte sequence falls over the boundary of the 4096 byte buffer
$dom = DOM\HTMLDocument::createEmpty(); $dom = Dom\HTMLDocument::createEmpty();
$element = $dom->createElement("container"); $element = $dom->createElement("container");
$dom->append($element); $dom->append($element);
$element->append(str_repeat("A", 4096 - 2 - strlen("<container>")) . "\xf0\x90\x8d\x88AA"); $element->append(str_repeat("A", 4096 - 2 - strlen("<container>")) . "\xf0\x90\x8d\x88AA");
var_dump($dom->saveHTML()); var_dump($dom->saveHtml());
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,18 +1,18 @@
--TEST-- --TEST--
DOM\HTMLDocument edge case encoding 02 Dom\HTMLDocument edge case encoding 02
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
// UTF-8 -> GB18030 // UTF-8 -> GB18030
$dom = DOM\HTMLDocument::createEmpty("GB18030"); $dom = Dom\HTMLDocument::createEmpty("GB18030");
$element = $dom->createElement("container"); $element = $dom->createElement("container");
$dom->append($element); $dom->append($element);
// Create a UTF-8 string where a UTF-8 byte sequence falls over the boundary of the 4096 byte buffer // Create a UTF-8 string where a UTF-8 byte sequence falls over the boundary of the 4096 byte buffer
// *and* the sequence also falls over the boundary for the result // *and* the sequence also falls over the boundary for the result
$element->append(str_repeat("A", 4096 - 2 - strlen("<container>")) . "\xf0\x90\x8d\x88AA"); $element->append(str_repeat("A", 4096 - 2 - strlen("<container>")) . "\xf0\x90\x8d\x88AA");
var_dump($output = $dom->saveHTML()); var_dump($output = $dom->saveHtml());
// GB18030 encoding of the above UTF-8 symbol // GB18030 encoding of the above UTF-8 symbol
var_dump($output[4094] == "\x90"); var_dump($output[4094] == "\x90");

View file

@ -1,18 +1,18 @@
--TEST-- --TEST--
DOM\HTMLDocument edge case encoding 03 Dom\HTMLDocument edge case encoding 03
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
// UTF-8 -> GB18030 // UTF-8 -> GB18030
$dom = DOM\HTMLDocument::createEmpty("GB18030"); $dom = Dom\HTMLDocument::createEmpty("GB18030");
$element = $dom->createElement("container"); $element = $dom->createElement("container");
$dom->append($element); $dom->append($element);
// Create a UTF-8 string where an invalid UTF-8 byte sequence falls over the boundary of the 4096 byte buffer // Create a UTF-8 string where an invalid UTF-8 byte sequence falls over the boundary of the 4096 byte buffer
// Note: the strange ?1?7 sequence is the GB18030 encoding for the unicode replacement character // Note: the strange ?1?7 sequence is the GB18030 encoding for the unicode replacement character
$element->append(str_repeat("A", 4096 - 2 - strlen("<container>")) . "\xff\xff\xff"); $element->append(str_repeat("A", 4096 - 2 - strlen("<container>")) . "\xff\xff\xff");
var_dump($dom->saveHTML()); var_dump($dom->saveHtml());
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,17 +1,17 @@
--TEST-- --TEST--
DOM\HTMLDocument edge case encoding 04 Dom\HTMLDocument edge case encoding 04
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
// UTF-8 -> UTF-8 // UTF-8 -> UTF-8
$dom = DOM\HTMLDocument::createEmpty(); $dom = Dom\HTMLDocument::createEmpty();
$element = $dom->createElement("container"); $element = $dom->createElement("container");
$dom->append($element); $dom->append($element);
// Create a UTF-8 string where an invalid UTF-8 byte sequence falls over the boundary of the 4096 byte buffer // Create a UTF-8 string where an invalid UTF-8 byte sequence falls over the boundary of the 4096 byte buffer
$element->append(str_repeat("A", 4096 - 2 - strlen("<container>")) . "\xff\xff\xff"); $element->append(str_repeat("A", 4096 - 2 - strlen("<container>")) . "\xff\xff\xff");
var_dump($dom->saveHTML()); var_dump($dom->saveHtml());
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,5 +1,5 @@
--TEST-- --TEST--
DOM\HTMLDocument edge case encoding 05 Dom\HTMLDocument edge case encoding 05
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
@ -9,11 +9,11 @@ dom
$header = "<!doctype html><html><head><meta charset=\"gb18030\"></head><body>"; $header = "<!doctype html><html><head><meta charset=\"gb18030\"></head><body>";
$padding_required_until_4094 = 4094 - strlen($header); $padding_required_until_4094 = 4094 - strlen($header);
$trailer = "\x90\x30\xd5\x30"; $trailer = "\x90\x30\xd5\x30";
$dom = DOM\HTMLDocument::createFromString($header . str_repeat("A", $padding_required_until_4094) . $trailer); $dom = Dom\HTMLDocument::createFromString($header . str_repeat("A", $padding_required_until_4094) . $trailer);
// GB18030 byte sequence crossing the 4096 boundary // GB18030 byte sequence crossing the 4096 boundary
var_dump($dom->charset); var_dump($dom->charset);
$dom->charset = "UTF-8"; $dom->charset = "UTF-8";
var_dump($dom->saveHTML()); var_dump($dom->saveHtml());
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,17 +1,17 @@
--TEST-- --TEST--
DOM\HTMLDocument edge case encoding 06 Dom\HTMLDocument edge case encoding 06
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
// UTF-8 -> UTF-8 // UTF-8 -> UTF-8
$dom = DOM\HTMLDocument::createEmpty(); $dom = Dom\HTMLDocument::createEmpty();
$element = $dom->createElement("container"); $element = $dom->createElement("container");
$dom->append($element); $dom->append($element);
// Create a UTF-8 string where a *broken* UTF-8 byte sequence falls over the boundary of the 4096 byte buffer // Create a UTF-8 string where a *broken* UTF-8 byte sequence falls over the boundary of the 4096 byte buffer
$element->append(str_repeat("A", 4096 - 1 - strlen("<container>")) . "\xf0\x90"); $element->append(str_repeat("A", 4096 - 1 - strlen("<container>")) . "\xf0\x90");
var_dump($dom->saveHTML()); var_dump($dom->saveHtml());
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,5 +1,5 @@
--TEST-- --TEST--
DOM\HTMLDocument edge case encoding 07 Dom\HTMLDocument edge case encoding 07
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
@ -9,11 +9,11 @@ dom
$header = "<!doctype html><html><head><meta charset=\"gb18030\"></head><body>"; $header = "<!doctype html><html><head><meta charset=\"gb18030\"></head><body>";
$padding_required_until_4095 = 4095 - strlen($header); $padding_required_until_4095 = 4095 - strlen($header);
$trailer = "\x90\x30"; $trailer = "\x90\x30";
$dom = DOM\HTMLDocument::createFromString($header . str_repeat("A", $padding_required_until_4095) . $trailer); $dom = Dom\HTMLDocument::createFromString($header . str_repeat("A", $padding_required_until_4095) . $trailer);
// GB18030 *broken* byte sequence crossing the 4096 boundary // GB18030 *broken* byte sequence crossing the 4096 boundary
var_dump($dom->charset); var_dump($dom->charset);
$dom->charset = "UTF-8"; $dom->charset = "UTF-8";
var_dump($dom->saveHTML()); var_dump($dom->saveHtml());
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,11 +1,11 @@
--TEST-- --TEST--
DOM\HTMLDocument test values for encoding field Dom\HTMLDocument test values for encoding field
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createEmpty(); $dom = Dom\HTMLDocument::createEmpty();
var_dump($dom->charset); var_dump($dom->charset);
$dom->inputEncoding = "CSeuckr"; $dom->inputEncoding = "CSeuckr";
var_dump($dom->characterSet); var_dump($dom->characterSet);
@ -23,10 +23,10 @@ try {
echo $e->getMessage(), "\n"; echo $e->getMessage(), "\n";
} }
var_dump($dom->inputEncoding); var_dump($dom->inputEncoding);
echo $dom->saveHTML(); echo $dom->saveHtml();
try { try {
$dom = DOM\HTMLDocument::createEmpty("bogus"); $dom = Dom\HTMLDocument::createEmpty("bogus");
} catch (ValueError $e) { } catch (ValueError $e) {
echo $e->getMessage(), "\n"; echo $e->getMessage(), "\n";
} }
@ -40,4 +40,4 @@ string(6) "EUC-KR"
string(12) "windows-1251" string(12) "windows-1251"
Invalid document encoding Invalid document encoding
string(12) "windows-1251" string(12) "windows-1251"
DOM\HTMLDocument::createEmpty(): Argument #1 ($encoding) must be a valid document encoding Dom\HTMLDocument::createEmpty(): Argument #1 ($encoding) must be a valid document encoding

View file

@ -1,26 +1,26 @@
--TEST-- --TEST--
DOM\HTMLDocument loading with unicode codepoints resulting in an error Dom\HTMLDocument loading with unicode codepoints resulting in an error
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
echo "--- createFromFile ---\n"; echo "--- createFromFile ---\n";
DOM\HTMLDocument::createFromFile(__DIR__."/utf16le_error.html"); Dom\HTMLDocument::createFromFile(__DIR__."/utf16le_error.html");
echo "--- createFromString ---\n"; echo "--- createFromString ---\n";
DOM\HTMLDocument::createFromString(file_get_contents(__DIR__."/utf16le_error.html")); Dom\HTMLDocument::createFromString(file_get_contents(__DIR__."/utf16le_error.html"));
?> ?>
--EXPECTF-- --EXPECTF--
--- createFromFile --- --- createFromFile ---
Warning: DOM\HTMLDocument::createFromFile(): tokenizer error missing-end-tag-name in %s on line %d Warning: Dom\HTMLDocument::createFromFile(): tokenizer error missing-end-tag-name in %s on line %d
Warning: DOM\HTMLDocument::createFromFile(): tree error unexpected-token in %s on line %d Warning: Dom\HTMLDocument::createFromFile(): tree error unexpected-token in %s on line %d
Warning: DOM\HTMLDocument::createFromFile(): tree error unexpected-token in %s on line %d Warning: Dom\HTMLDocument::createFromFile(): tree error unexpected-token in %s on line %d
--- createFromString --- --- createFromString ---
Warning: DOM\HTMLDocument::createFromString(): tokenizer error missing-end-tag-name in Entity, line: 7, column: 29 in %s on line %d Warning: Dom\HTMLDocument::createFromString(): tokenizer error missing-end-tag-name in Entity, line: 7, column: 29 in %s on line %d
Warning: DOM\HTMLDocument::createFromString(): tree error unexpected-token in Entity, line: 7, column: 14-17 in %s on line %d Warning: Dom\HTMLDocument::createFromString(): tree error unexpected-token in Entity, line: 7, column: 14-17 in %s on line %d
Warning: DOM\HTMLDocument::createFromString(): tree error unexpected-token in Entity, line: 8, column: 7-10 in %s on line %d Warning: Dom\HTMLDocument::createFromString(): tree error unexpected-token in Entity, line: 8, column: 7-10 in %s on line %d

View file

@ -1,13 +1,13 @@
--TEST-- --TEST--
DOM\HTMLDocument fallback encoding test Dom\HTMLDocument fallback encoding test
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromFile(__DIR__ . "/fallback_encoding.html"); $dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/fallback_encoding.html");
var_dump($dom->inputEncoding); var_dump($dom->inputEncoding);
echo $dom->saveHTML(); echo $dom->saveHtml();
?> ?>
--CLEAN-- --CLEAN--

View file

@ -1,11 +1,11 @@
--TEST-- --TEST--
DOM\HTMLDocument: overrideEncoding with incompatible charset Dom\HTMLDocument: overrideEncoding with incompatible charset
--EXTENSIONS-- --EXTENSIONS--
iconv iconv
dom dom
--FILE-- --FILE--
<?php <?php
$doc = DOM\HTMLDocument::createFromString( $doc = Dom\HTMLDocument::createFromString(
iconv( iconv(
'ISO-8859-1', 'ISO-8859-1',
'UTF-8', 'UTF-8',
@ -14,10 +14,10 @@ $doc = DOM\HTMLDocument::createFromString(
<html> <html>
<head> <head>
<meta charset="iso-8859-1"> <meta charset="iso-8859-1">
<title>äöü</title> <title><EFBFBD><EFBFBD><EFBFBD></title>
</head> </head>
<body> <body>
äöü <EFBFBD><EFBFBD><EFBFBD>
</body> </body>
</html> </html>
DOC, DOC,
@ -29,8 +29,8 @@ var_dump(iconv('UTF-8', 'ISO-8859-1', $doc->getElementsByTagName('title')->item(
var_dump(iconv('UTF-8', 'ISO-8859-1', $doc->getElementsByTagName('body')->item(0)->textContent)); var_dump(iconv('UTF-8', 'ISO-8859-1', $doc->getElementsByTagName('body')->item(0)->textContent));
?> ?>
--EXPECT-- --EXPECT--
string(3) "äöü" string(9) "<22><><EFBFBD>"
string(9) " string(15) "
äöü <EFBFBD><EFBFBD><EFBFBD>
" "

View file

@ -5,7 +5,7 @@ dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\XMLDocument::createFromString('<root/>'); $dom = Dom\XMLDocument::createFromString('<root/>');
try { try {
$dom->getElementsByTagName('root')[][1] = 1; $dom->getElementsByTagName('root')[][1] = 1;
@ -27,6 +27,6 @@ try {
?> ?>
--EXPECT-- --EXPECT--
Cannot append to DOM\HTMLCollection Cannot append to Dom\HTMLCollection
Cannot access offset of type bool on DOM\HTMLCollection Cannot access offset of type bool on Dom\HTMLCollection
Cannot access offset of type bool in isset or empty Cannot access offset of type bool in isset or empty

View file

@ -21,7 +21,7 @@ $xml = <<<XML
</root> </root>
XML; XML;
$dom = DOM\XMLDocument::createFromString($xml); $dom = Dom\XMLDocument::createFromString($xml);
function test($obj, $name) { function test($obj, $name) {
echo "--- Query \"$name\" ---\n"; echo "--- Query \"$name\" ---\n";

View file

@ -1,11 +1,11 @@
--TEST-- --TEST--
Cloning a DOM\HTMLDocument Cloning a Dom\HTMLDocument
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromString("<p>foo</p>"); $dom = Dom\HTMLDocument::createFromString("<p>foo</p>");
$dom2 = clone $dom; $dom2 = clone $dom;
var_dump($dom2->firstChild->tagName); var_dump($dom2->firstChild->tagName);
@ -17,7 +17,7 @@ var_dump(get_class($element->ownerDocument));
?> ?>
--EXPECTF-- --EXPECTF--
Warning: DOM\HTMLDocument::createFromString(): tree error unexpected-token-in-initial-mode in Entity, line: 1, column: 2 in %s on line %d Warning: Dom\HTMLDocument::createFromString(): tree error unexpected-token-in-initial-mode in Entity, line: 1, column: 2 in %s on line %d
string(4) "HTML" string(4) "HTML"
string(3) "foo" string(3) "foo"
string(16) "DOM\HTMLDocument" string(16) "Dom\HTMLDocument"

View file

@ -1,17 +1,17 @@
--TEST-- --TEST--
DOM\HTMLDocument::documentURI Dom\HTMLDocument::documentURI
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromFile(__DIR__ . "/test foo.html", LIBXML_NOERROR); $dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/test foo.html", LIBXML_NOERROR);
var_dump($dom->documentURI); var_dump($dom->documentURI);
$memory = fopen("php://memory", "w+"); $memory = fopen("php://memory", "w+");
fwrite($memory, "foobar"); fwrite($memory, "foobar");
rewind($memory); rewind($memory);
$dom = DOM\HTMLDocument::createFromFile("php://memory"); $dom = Dom\HTMLDocument::createFromFile("php://memory");
var_dump($dom->documentURI); var_dump($dom->documentURI);
fclose($memory); fclose($memory);
@ -37,7 +37,7 @@ class DummyWrapper {
stream_wrapper_register("dummy", DummyWrapper::class); stream_wrapper_register("dummy", DummyWrapper::class);
$dom = DOM\HTMLDocument::createFromFile("dummy://foo/ bar"); $dom = Dom\HTMLDocument::createFromFile("dummy://foo/ bar");
var_dump($dom->documentURI); var_dump($dom->documentURI);
?> ?>

View file

@ -1,11 +1,11 @@
--TEST-- --TEST--
Test DOM\HTMLDocument::getElementsByTagName(NS) Test Dom\HTMLDocument::getElementsByTagName(NS)
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromString(<<<HTML $dom = Dom\HTMLDocument::createFromString(<<<HTML
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>

View file

@ -1,17 +1,17 @@
--TEST-- --TEST--
DOM\HTMLDocument::registerNodeClass 01 Dom\HTMLDocument::registerNodeClass 01
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = new DOMDocument(); $dom = new DOMDocument();
$dom->registerNodeClass("DOM\\HTMLDocument", "DOMDocument"); $dom->registerNodeClass("Dom\\HTMLDocument", "DOMDocument");
?> ?>
--EXPECTF-- --EXPECTF--
Fatal error: Uncaught TypeError: DOMDocument::registerNodeClass(): Argument #1 ($baseClass) must be a class name derived from DOMNode, DOM\HTMLDocument given in %s:%d Fatal error: Uncaught TypeError: DOMDocument::registerNodeClass(): Argument #1 ($baseClass) must be a class name derived from DOMNode, Dom\HTMLDocument given in %s:%d
Stack trace: Stack trace:
#0 %s(%d): DOMDocument->registerNodeClass('DOM\\HTMLDocumen...', 'DOMDocument') #0 %s(%d): DOMDocument->registerNodeClass('Dom\\HTMLDocumen...', 'DOMDocument')
#1 {main} #1 {main}
thrown in %s on line %d thrown in %s on line %d

View file

@ -1,18 +1,18 @@
--TEST-- --TEST--
DOM\HTMLDocument::registerNodeClass 02 Dom\HTMLDocument::registerNodeClass 02
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
class Custom extends DOM\Document { class Custom extends Dom\Document {
public function foo() { public function foo() {
} }
} }
$dom = DOM\HTMLDocument::createEmpty(); $dom = Dom\HTMLDocument::createEmpty();
try { try {
$dom->registerNodeClass("DOM\\Document", "Custom"); $dom->registerNodeClass("Dom\\Document", "Custom");
} catch (ValueError $e) { } catch (ValueError $e) {
echo $e->getMessage(), "\n"; echo $e->getMessage(), "\n";
} }
@ -27,10 +27,10 @@ $element->ownerDocument->foo();
?> ?>
--EXPECTF-- --EXPECTF--
DOM\Document::registerNodeClass(): Argument #1 ($baseClass) must not be an abstract class Dom\Document::registerNodeClass(): Argument #1 ($baseClass) must not be an abstract class
string(16) "DOM\HTMLDocument" string(16) "Dom\HTMLDocument"
Fatal error: Uncaught Error: Call to undefined method DOM\HTMLDocument::foo() in %s:%d Fatal error: Uncaught Error: Call to undefined method Dom\HTMLDocument::foo() in %s:%d
Stack trace: Stack trace:
#0 {main} #0 {main}
thrown in %s on line %d thrown in %s on line %d

View file

@ -1,11 +1,11 @@
--TEST-- --TEST--
DOM\HTMLDocument::registerNodeClass 03 Dom\HTMLDocument::registerNodeClass 03
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
class Custom extends DOM\Element { class Custom extends Dom\Element {
public int $test = 1; public int $test = 1;
public function reverseTagName(): string { public function reverseTagName(): string {
@ -14,8 +14,8 @@ class Custom extends DOM\Element {
} }
} }
$dom = DOM\HTMLDocument::createFromString("<div>foo</div>", LIBXML_NOERROR); $dom = Dom\HTMLDocument::createFromString("<div>foo</div>", LIBXML_NOERROR);
$dom->registerNodeClass("DOM\\Element", "Custom"); $dom->registerNodeClass("Dom\\Element", "Custom");
var_dump($dom->getElementsByTagName('div')[0]->reverseTagName()); var_dump($dom->getElementsByTagName('div')[0]->reverseTagName());

View file

@ -1,18 +1,18 @@
--TEST-- --TEST--
DOM\HTMLDocument::saveHTMLFile() empty path Dom\HTMLDocument::saveHtmlFile() empty path
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createEmpty(); $dom = Dom\HTMLDocument::createEmpty();
$root = $dom->appendChild($dom->createElement("root")); $root = $dom->appendChild($dom->createElement("root"));
$dom->saveHTMLFile(""); $dom->saveHtmlFile("");
?> ?>
--EXPECTF-- --EXPECTF--
Fatal error: Uncaught ValueError: DOM\HTMLDocument::saveHTMLFile(): Argument #1 ($filename) must not be empty in %s:%d Fatal error: Uncaught ValueError: Dom\HTMLDocument::saveHtmlFile(): Argument #1 ($filename) must not be empty in %s:%d
Stack trace: Stack trace:
#0 %s(%d): DOM\HTMLDocument->saveHTMLFile('') #0 %s(%d): Dom\HTMLDocument->saveHtmlFile('')
#1 {main} #1 {main}
thrown in %s on line %d thrown in %s on line %d

View file

@ -1,17 +1,17 @@
--TEST-- --TEST--
DOM\HTMLDocument::saveHTML() wrong document Dom\HTMLDocument::saveHtml() wrong document
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createEmpty(); $dom = Dom\HTMLDocument::createEmpty();
$dom->saveHTML(DOM\HTMLDocument::createEmpty()); $dom->saveHtml(Dom\HTMLDocument::createEmpty());
?> ?>
--EXPECTF-- --EXPECTF--
Fatal error: Uncaught DOMException: Wrong Document Error in %s:%d Fatal error: Uncaught DOMException: Wrong Document Error in %s:%d
Stack trace: Stack trace:
#0 %s(%d): DOM\HTMLDocument->saveHTML(Object(DOM\HTMLDocument)) #0 %s(%d): Dom\HTMLDocument->saveHtml(Object(Dom\HTMLDocument))
#1 {main} #1 {main}
thrown in %s on line %d thrown in %s on line %d

View file

@ -1,21 +1,21 @@
--TEST-- --TEST--
DOM\HTMLDocument should retain properties and ownerDocument relation 01 Dom\HTMLDocument should retain properties and ownerDocument relation 01
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
class MyElement extends DOM\Element {} class MyElement extends Dom\Element {}
$dom = DOM\HTMLDocument::createFromString("<p>foo</p>", LIBXML_NOERROR); $dom = Dom\HTMLDocument::createFromString("<p>foo</p>", LIBXML_NOERROR);
$dom->registerNodeClass("DOM\\Element", "MyElement"); $dom->registerNodeClass("Dom\\Element", "MyElement");
// Destroy reference to the DOM // Destroy reference to the DOM
$child = $dom->documentElement; $child = $dom->documentElement;
unset($dom); unset($dom);
// Regain reference using the ownerDocument property // Regain reference using the ownerDocument property
// Should be a DOM\HTMLDocument // Should be a Dom\HTMLDocument
$dom = $child->ownerDocument; $dom = $child->ownerDocument;
var_dump($dom); var_dump($dom);
// Test if property is preserved (any random doc_props property will do) // Test if property is preserved (any random doc_props property will do)
@ -23,7 +23,7 @@ var_dump(get_class($dom->getElementsByTagName("p")->item(0)));
?> ?>
--EXPECT-- --EXPECT--
object(DOM\HTMLDocument)#1 (25) { object(Dom\HTMLDocument)#1 (25) {
["implementation"]=> ["implementation"]=>
string(22) "(object value omitted)" string(22) "(object value omitted)"
["URL"]=> ["URL"]=>

View file

@ -1,21 +1,21 @@
--TEST-- --TEST--
DOM\HTMLDocument should retain properties and ownerDocument relation 02 Dom\HTMLDocument should retain properties and ownerDocument relation 02
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
class MyElement extends DOM\Element {} class MyElement extends Dom\Element {}
$dom = DOM\HTMLDocument::createFromString("<p>foo</p>", LIBXML_NOERROR); $dom = Dom\HTMLDocument::createFromString("<p>foo</p>", LIBXML_NOERROR);
$dom->registerNodeClass("DOM\\Element", "MyElement"); $dom->registerNodeClass("Dom\\Element", "MyElement");
$child = $dom->documentElement->appendChild($dom->createElement('html')); $child = $dom->documentElement->appendChild($dom->createElement('html'));
// Destroy reference to the DOM // Destroy reference to the DOM
unset($dom); unset($dom);
// Regain reference using the ownerDocument property // Regain reference using the ownerDocument property
// Should be a DOM\HTMLDocument // Should be a Dom\HTMLDocument
$dom = $child->ownerDocument; $dom = $child->ownerDocument;
var_dump($dom); var_dump($dom);
// Test if property is preserved (any random doc_props property will do) // Test if property is preserved (any random doc_props property will do)
@ -23,7 +23,7 @@ var_dump(get_class($dom->getElementsByTagName("p")->item(0)));
?> ?>
--EXPECT-- --EXPECT--
object(DOM\HTMLDocument)#1 (25) { object(Dom\HTMLDocument)#1 (25) {
["implementation"]=> ["implementation"]=>
string(22) "(object value omitted)" string(22) "(object value omitted)"
["URL"]=> ["URL"]=>

View file

@ -12,7 +12,7 @@ $html = str_repeat("\n", 65536) . <<<EOF
</body> </body>
EOF; EOF;
$dom = DOM\HTMLDocument::createFromString($html); $dom = Dom\HTMLDocument::createFromString($html);
var_dump($dom->documentElement->firstChild->nextSibling->firstChild->nextSibling->getLineNo()); var_dump($dom->documentElement->firstChild->nextSibling->firstChild->nextSibling->getLineNo());
?> ?>

View file

@ -7,25 +7,25 @@ dom
echo "--- Parsing ---\n"; echo "--- Parsing ---\n";
$dom = DOM\HTMLDocument::createFromString("<!doctype html><html><body><noscript><p>hi</p></noscript></body></html>", DOM\HTML_NO_DEFAULT_NS); $dom = Dom\HTMLDocument::createFromString("<!doctype html><html><body><noscript><p>hi</p></noscript></body></html>", Dom\HTML_NO_DEFAULT_NS);
var_dump($dom->documentElement->textContent); var_dump($dom->documentElement->textContent);
var_dump($dom->documentElement->namespaceURI); var_dump($dom->documentElement->namespaceURI);
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
echo $dom->saveXML(), "\n"; echo $dom->saveXml(), "\n";
echo "--- Modifying the text content: tag ---\n"; echo "--- Modifying the text content: tag ---\n";
$xpath = new DOM\XPath($dom); $xpath = new Dom\XPath($dom);
$noscript = $xpath->query("//noscript")[0]; $noscript = $xpath->query("//noscript")[0];
$noscript->textContent = "<p>bye</p>"; $noscript->textContent = "<p>bye</p>";
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
echo $dom->saveXML(), "\n"; echo $dom->saveXml(), "\n";
echo "--- Modifying the text content: trick ---\n"; echo "--- Modifying the text content: trick ---\n";
$noscript->textContent = "<!-- </noscript> -->"; $noscript->textContent = "<!-- </noscript> -->";
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
echo $dom->saveXML(), "\n"; echo $dom->saveXml(), "\n";
?> ?>
--EXPECT-- --EXPECT--

View file

@ -5,7 +5,7 @@ dom
--FILE-- --FILE--
<?php <?php
foreach (['DOM\HTMLDocument', 'DOM\XMLDocument'] as $class) { foreach (['Dom\HTMLDocument', 'Dom\XMLDocument'] as $class) {
try { try {
$rc = new ReflectionClass($class); $rc = new ReflectionClass($class);
$rc->newInstanceWithoutConstructor(); $rc->newInstanceWithoutConstructor();
@ -16,5 +16,5 @@ foreach (['DOM\HTMLDocument', 'DOM\XMLDocument'] as $class) {
?> ?>
--EXPECT-- --EXPECT--
Class DOM\HTMLDocument is an internal class marked as final that cannot be instantiated without invoking its constructor Class Dom\HTMLDocument is an internal class marked as final that cannot be instantiated without invoking its constructor
Class DOM\XMLDocument is an internal class marked as final that cannot be instantiated without invoking its constructor Class Dom\XMLDocument is an internal class marked as final that cannot be instantiated without invoking its constructor

View file

@ -1,5 +1,5 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromFile()/createFromString() BOM with a buffer on the edge Dom\HTMLDocument::createFromFile()/createFromString() BOM with a buffer on the edge
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
@ -9,13 +9,13 @@ $header = "\xEF\xBB\xBF<!doctype html><html><body>";
$trailer = "</body></html>"; $trailer = "</body></html>";
$data = $header . str_repeat("a", 4096 - strlen($header) - strlen($trailer)) . $trailer; $data = $header . str_repeat("a", 4096 - strlen($header) - strlen($trailer)) . $trailer;
$dom = DOM\HTMLDocument::createFromString($header . str_repeat("a", 4096 - strlen($header) - strlen($trailer)) . $trailer); $dom = Dom\HTMLDocument::createFromString($header . str_repeat("a", 4096 - strlen($header) - strlen($trailer)) . $trailer);
var_dump($dom->documentElement->textContent); var_dump($dom->documentElement->textContent);
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
file_put_contents(__DIR__ . "/BOM_edge.tmp", $data); file_put_contents(__DIR__ . "/BOM_edge.tmp", $data);
$dom = DOM\HTMLDocument::createFromFile(__DIR__ . "/BOM_edge.tmp"); $dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/BOM_edge.tmp");
var_dump($dom->documentElement->textContent); var_dump($dom->documentElement->textContent);
?> ?>

View file

@ -5,7 +5,7 @@ dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromString(<<<HTML $dom = Dom\HTMLDocument::createFromString(<<<HTML
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<svg width="1" xmlns:xlink='http://www.w3.org/1999/xlink'> <svg width="1" xmlns:xlink='http://www.w3.org/1999/xlink'>

View file

@ -1,37 +1,37 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromFile() with DOM\HTML_NO_DEFAULT_NS Dom\HTMLDocument::createFromFile() with Dom\HTML_NO_DEFAULT_NS
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromFile(__DIR__ . "/paragraph.html", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR); $dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/paragraph.html", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR);
$xpath = new DOM\XPath($dom); $xpath = new Dom\XPath($dom);
$xpath->registerNamespace("x", "http://www.w3.org/1999/xhtml"); $xpath->registerNamespace("x", "http://www.w3.org/1999/xhtml");
var_dump($xpath->query("//p")); var_dump($xpath->query("//p"));
var_dump($xpath->query("//x:p")); var_dump($xpath->query("//x:p"));
$dom = DOM\HTMLDocument::createFromFile(__DIR__ . "/paragraph.html", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR | DOM\HTML_NO_DEFAULT_NS); $dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/paragraph.html", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR | Dom\HTML_NO_DEFAULT_NS);
$xpath = new DOM\XPath($dom); $xpath = new Dom\XPath($dom);
$xpath->registerNamespace("x", "http://www.w3.org/1999/xhtml"); $xpath->registerNamespace("x", "http://www.w3.org/1999/xhtml");
var_dump($xpath->query("//p")); var_dump($xpath->query("//p"));
var_dump($xpath->query("//x:p")); var_dump($xpath->query("//x:p"));
?> ?>
--EXPECT-- --EXPECT--
object(DOM\NodeList)#3 (1) { object(Dom\NodeList)#3 (1) {
["length"]=> ["length"]=>
int(0) int(0)
} }
object(DOM\NodeList)#4 (1) { object(Dom\NodeList)#4 (1) {
["length"]=> ["length"]=>
int(1) int(1)
} }
object(DOM\NodeList)#3 (1) { object(Dom\NodeList)#3 (1) {
["length"]=> ["length"]=>
int(1) int(1)
} }
object(DOM\NodeList)#3 (1) { object(Dom\NodeList)#3 (1) {
["length"]=> ["length"]=>
int(0) int(0)
} }

View file

@ -1,16 +1,16 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromFile() - empty path Dom\HTMLDocument::createFromFile() - empty path
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromFile(""); $dom = Dom\HTMLDocument::createFromFile("");
?> ?>
--EXPECTF-- --EXPECTF--
Fatal error: Uncaught ValueError: Path cannot be empty in %s:%d Fatal error: Uncaught ValueError: Path cannot be empty in %s:%d
Stack trace: Stack trace:
#0 %s(%d): DOM\HTMLDocument::createFromFile('') #0 %s(%d): Dom\HTMLDocument::createFromFile('')
#1 {main} #1 {main}
thrown in %s on line %d thrown in %s on line %d

View file

@ -1,16 +1,16 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromFile() - local existing file Dom\HTMLDocument::createFromFile() - local existing file
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromFile(__DIR__ . "/../../../test.html"); $dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/../../../test.html");
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
?> ?>
--EXPECTF-- --EXPECTF--
Warning: DOM\HTMLDocument::createFromFile(): tree error unexpected-token-in-initial-mode in %s on line %d Warning: Dom\HTMLDocument::createFromFile(): tree error unexpected-token-in-initial-mode in %s on line %d
<html><head> <html><head>
<title>Hello world</title> <title>Hello world</title>
</head> </head>

View file

@ -1,19 +1,19 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromFile() - local file that does not exist Dom\HTMLDocument::createFromFile() - local file that does not exist
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromFile(__DIR__ . "/../foobar"); $dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/../foobar");
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
?> ?>
--EXPECTF-- --EXPECTF--
Warning: DOM\HTMLDocument::createFromFile(%s): Failed to open stream: No such file or directory in %s on line %d Warning: Dom\HTMLDocument::createFromFile(%s): Failed to open stream: No such file or directory in %s on line %d
Fatal error: Uncaught Exception: Cannot open file '%s' in %s:%d Fatal error: Uncaught Exception: Cannot open file '%s' in %s:%d
Stack trace: Stack trace:
#0 %s(%d): DOM\HTMLDocument::createFromFile('%s') #0 %s(%d): Dom\HTMLDocument::createFromFile('%s')
#1 {main} #1 {main}
thrown in %s on line %d thrown in %s on line %d

View file

@ -1,22 +1,22 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromFile() - NUL terminator cases path Dom\HTMLDocument::createFromFile() - NUL terminator cases path
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
try { try {
DOM\HTMLDocument::createFromFile("\0"); Dom\HTMLDocument::createFromFile("\0");
} catch (ValueError $e) { } catch (ValueError $e) {
echo $e->getMessage(), "\n"; echo $e->getMessage(), "\n";
} }
try { try {
DOM\HTMLDocument::createFromFile('%00'); Dom\HTMLDocument::createFromFile('%00');
} catch (ValueError $e) { } catch (ValueError $e) {
echo $e->getMessage(), "\n"; echo $e->getMessage(), "\n";
} }
?> ?>
--EXPECT-- --EXPECT--
DOM\HTMLDocument::createFromFile(): Argument #1 ($path) must not contain any null bytes Dom\HTMLDocument::createFromFile(): Argument #1 ($path) must not contain any null bytes
DOM\HTMLDocument::createFromFile(): Argument #1 ($path) must not contain percent-encoded NUL bytes Dom\HTMLDocument::createFromFile(): Argument #1 ($path) must not contain percent-encoded NUL bytes

View file

@ -1,12 +1,12 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromFile() - parser warning 01 Dom\HTMLDocument::createFromFile() - parser warning 01
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromFile(__DIR__."/parser_warning_01.html", LIBXML_NOERROR); $dom = Dom\HTMLDocument::createFromFile(__DIR__."/parser_warning_01.html", LIBXML_NOERROR);
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,12 +1,12 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromFile() - parser warning 02 Dom\HTMLDocument::createFromFile() - parser warning 02
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromFile(__DIR__."/parser_warning_02.html", LIBXML_NOERROR); $dom = Dom\HTMLDocument::createFromFile(__DIR__."/parser_warning_02.html", LIBXML_NOERROR);
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,12 +1,12 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromFile() - parser warning 03 Dom\HTMLDocument::createFromFile() - parser warning 03
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromFile(__DIR__."/parser_warning_03.html", LIBXML_NOERROR); $dom = Dom\HTMLDocument::createFromFile(__DIR__."/parser_warning_03.html", LIBXML_NOERROR);
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,5 +1,5 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromFile() - parser warning libxml_get_last_error() Dom\HTMLDocument::createFromFile() - parser warning libxml_get_last_error()
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
@ -8,7 +8,7 @@ dom
libxml_use_internal_errors(true); libxml_use_internal_errors(true);
$html = '<>x</> <!doctype html>'; $html = '<>x</> <!doctype html>';
$dom = DOM\HTMLDocument::createFromFile(__DIR__."/parser_warning_01.html"); $dom = Dom\HTMLDocument::createFromFile(__DIR__."/parser_warning_01.html");
var_dump(libxml_get_last_error()); var_dump(libxml_get_last_error());

View file

@ -1,5 +1,5 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromFile() with failing stream wrapper Dom\HTMLDocument::createFromFile() with failing stream wrapper
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
@ -32,13 +32,13 @@ class FailingWrapper {
stream_wrapper_register("fail", FailingWrapper::class, 0); stream_wrapper_register("fail", FailingWrapper::class, 0);
DOM\HTMLDocument::createFromFile("fail://x"); Dom\HTMLDocument::createFromFile("fail://x");
?> ?>
--EXPECTF-- --EXPECTF--
Fatal error: Uncaught Error: fail in %s:%d Fatal error: Uncaught Error: fail in %s:%d
Stack trace: Stack trace:
#0 [internal function]: FailingWrapper->stream_read(8192) #0 [internal function]: FailingWrapper->stream_read(8192)
#1 %s(%d): DOM\HTMLDocument::createFromFile('fail://x') #1 %s(%d): Dom\HTMLDocument::createFromFile('fail://x')
#2 {main} #2 {main}
thrown in %s on line %d thrown in %s on line %d

View file

@ -1,5 +1,5 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromFile() with working stream wrapper Dom\HTMLDocument::createFromFile() with working stream wrapper
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
@ -34,15 +34,15 @@ stream_wrapper_register("euw", EchoUriWrapper::class, 0);
echo "--- Stream wrapper case ---\n"; echo "--- Stream wrapper case ---\n";
$dom = DOM\HTMLDocument::createFromFile("euw://<p>hello</p>"); $dom = Dom\HTMLDocument::createFromFile("euw://<p>hello</p>");
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
echo "--- Stream wrapper in two chunks case ---\n"; echo "--- Stream wrapper in two chunks case ---\n";
libxml_use_internal_errors(true); libxml_use_internal_errors(true);
// To properly test this, keep the 4096 in sync with document.c's input stream buffer size. // To properly test this, keep the 4096 in sync with document.c's input stream buffer size.
$dom = DOM\HTMLDocument::createFromFile("euw://<!doctype html><html>" . str_repeat("\n", 4096-22) . "<></html>"); $dom = Dom\HTMLDocument::createFromFile("euw://<!doctype html><html>" . str_repeat("\n", 4096-22) . "<></html>");
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
foreach (libxml_get_errors() as $error) { foreach (libxml_get_errors() as $error) {
var_dump($error->line, $error->column); var_dump($error->line, $error->column);
@ -52,7 +52,7 @@ foreach (libxml_get_errors() as $error) {
--EXPECTF-- --EXPECTF--
--- Stream wrapper case --- --- Stream wrapper case ---
Warning: DOM\HTMLDocument::createFromFile(): tree error unexpected-token-in-initial-mode in euw://<p>hello</p>, line: 1, column: 2 in %s on line %d Warning: Dom\HTMLDocument::createFromFile(): tree error unexpected-token-in-initial-mode in euw://<p>hello</p>, line: 1, column: 2 in %s on line %d
<html><head></head><body><p>hello</p></body></html> <html><head></head><body><p>hello</p></body></html>
--- Stream wrapper in two chunks case --- --- Stream wrapper in two chunks case ---
<!DOCTYPE html><html><head></head><body>&lt;&gt;</body></html> <!DOCTYPE html><html><head></head><body>&lt;&gt;</body></html>

View file

@ -1,37 +1,37 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromString() with DOM\HTML_NO_DEFAULT_NS Dom\HTMLDocument::createFromString() with Dom\HTML_NO_DEFAULT_NS
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromString(file_get_contents(__DIR__ . "/paragraph.html"), LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR); $dom = Dom\HTMLDocument::createFromString(file_get_contents(__DIR__ . "/paragraph.html"), LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR);
$xpath = new DOM\XPath($dom); $xpath = new Dom\XPath($dom);
$xpath->registerNamespace("x", "http://www.w3.org/1999/xhtml"); $xpath->registerNamespace("x", "http://www.w3.org/1999/xhtml");
var_dump($xpath->query("//p")); var_dump($xpath->query("//p"));
var_dump($xpath->query("//x:p")); var_dump($xpath->query("//x:p"));
$dom = DOM\HTMLDocument::createFromString(file_get_contents(__DIR__ . "/paragraph.html"), LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR | DOM\HTML_NO_DEFAULT_NS); $dom = Dom\HTMLDocument::createFromString(file_get_contents(__DIR__ . "/paragraph.html"), LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR | Dom\HTML_NO_DEFAULT_NS);
$xpath = new DOM\XPath($dom); $xpath = new Dom\XPath($dom);
$xpath->registerNamespace("x", "http://www.w3.org/1999/xhtml"); $xpath->registerNamespace("x", "http://www.w3.org/1999/xhtml");
var_dump($xpath->query("//p")); var_dump($xpath->query("//p"));
var_dump($xpath->query("//x:p")); var_dump($xpath->query("//x:p"));
?> ?>
--EXPECT-- --EXPECT--
object(DOM\NodeList)#3 (1) { object(Dom\NodeList)#3 (1) {
["length"]=> ["length"]=>
int(0) int(0)
} }
object(DOM\NodeList)#4 (1) { object(Dom\NodeList)#4 (1) {
["length"]=> ["length"]=>
int(1) int(1)
} }
object(DOM\NodeList)#3 (1) { object(Dom\NodeList)#3 (1) {
["length"]=> ["length"]=>
int(1) int(1)
} }
object(DOM\NodeList)#3 (1) { object(Dom\NodeList)#3 (1) {
["length"]=> ["length"]=>
int(0) int(0)
} }

View file

@ -1,11 +1,11 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromString() with LIBXML_COMPACT Dom\HTMLDocument::createFromString() with LIBXML_COMPACT
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromString(<<<HTML $dom = Dom\HTMLDocument::createFromString(<<<HTML
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html> <html>
<head> <head>
@ -23,7 +23,7 @@ $dom = DOM\HTMLDocument::createFromString(<<<HTML
</html> </html>
HTML, LIBXML_COMPACT); HTML, LIBXML_COMPACT);
$xpath = new DOM\XPath($dom); $xpath = new Dom\XPath($dom);
foreach ($xpath->query("//*[name()='p']") as $p) { foreach ($xpath->query("//*[name()='p']") as $p) {
echo $p->textContent, "\n"; echo $p->textContent, "\n";
} }

View file

@ -1,12 +1,12 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromString() with LIBXML_HTML_NOIMPLIED - tree error should not happen Dom\HTMLDocument::createFromString() with LIBXML_HTML_NOIMPLIED - tree error should not happen
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromString("<div>foo</div>", LIBXML_HTML_NOIMPLIED); $dom = Dom\HTMLDocument::createFromString("<div>foo</div>", LIBXML_HTML_NOIMPLIED);
echo $dom->saveHTML(); echo $dom->saveHtml();
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,5 +1,5 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromString() with LIBXML_HTML_NOIMPLIED namespace check Dom\HTMLDocument::createFromString() with LIBXML_HTML_NOIMPLIED namespace check
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
@ -7,20 +7,20 @@ dom
echo "--- No elements ---\n"; echo "--- No elements ---\n";
$dom = DOM\HTMLDocument::createFromString("", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR); $dom = Dom\HTMLDocument::createFromString("", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR);
echo $dom->saveXML(), "\n"; echo $dom->saveXml(), "\n";
echo "--- Single element ---\n"; echo "--- Single element ---\n";
$dom = DOM\HTMLDocument::createFromString("<p>foo</p>", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR); $dom = Dom\HTMLDocument::createFromString("<p>foo</p>", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR);
echo $dom->saveXML(), "\n"; echo $dom->saveXml(), "\n";
var_dump($dom->documentElement->namespaceURI); var_dump($dom->documentElement->namespaceURI);
var_dump($dom->documentElement->prefix); var_dump($dom->documentElement->prefix);
echo "--- Multiple elements ---\n"; echo "--- Multiple elements ---\n";
$dom = DOM\HTMLDocument::createFromString("<p>foo</p><strong>bar</strong>", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR); $dom = Dom\HTMLDocument::createFromString("<p>foo</p><strong>bar</strong>", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR);
echo $dom->saveXML(), "\n"; echo $dom->saveXml(), "\n";
var_dump($dom->documentElement->namespaceURI); var_dump($dom->documentElement->namespaceURI);
var_dump($dom->documentElement->prefix); var_dump($dom->documentElement->prefix);
var_dump($dom->documentElement->nextSibling->namespaceURI); var_dump($dom->documentElement->nextSibling->namespaceURI);

View file

@ -1,12 +1,12 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromString() - empty document Dom\HTMLDocument::createFromString() - empty document
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromString(''); $dom = Dom\HTMLDocument::createFromString('');
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,21 +1,21 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromString()/createFromFile() with LIBXML_HTML_NOIMPLIED Dom\HTMLDocument::createFromString()/createFromFile() with LIBXML_HTML_NOIMPLIED
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
function test(string $html) { function test(string $html) {
echo "Testing: $html\n"; echo "Testing: $html\n";
$dom = DOM\HTMLDocument::createFromString($html, LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR); $dom = Dom\HTMLDocument::createFromString($html, LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR);
$output = $dom->saveHTML(); $output = $dom->saveHtml();
echo $output, "\n"; echo $output, "\n";
// Also test the loadHTMLFile variation. We won't print out the result, just checking the result is the same. // Also test the loadHTMLFile variation. We won't print out the result, just checking the result is the same.
$temp = fopen(__DIR__."/DOM_HTMLDocument_loadHTML_LIBXML_HTML_NOIMPLIED_input.tmp", "w"); $temp = fopen(__DIR__."/DOM_HTMLDocument_loadHTML_LIBXML_HTML_NOIMPLIED_input.tmp", "w");
fwrite($temp, $html); fwrite($temp, $html);
fclose($temp); fclose($temp);
$dom = DOM\HTMLDocument::createFromFile(__DIR__."/DOM_HTMLDocument_loadHTML_LIBXML_HTML_NOIMPLIED_input.tmp", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR); $dom = Dom\HTMLDocument::createFromFile(__DIR__."/DOM_HTMLDocument_loadHTML_LIBXML_HTML_NOIMPLIED_input.tmp", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR);
var_dump($output === $dom->saveHTML()); var_dump($output === $dom->saveHtml());
} }
echo "--- Missing html, head, body ---\n"; echo "--- Missing html, head, body ---\n";

View file

@ -1,11 +1,11 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromString() - line and column test Dom\HTMLDocument::createFromString() - line and column test
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromString(<<<HTML $dom = Dom\HTMLDocument::createFromString(<<<HTML
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
@ -22,7 +22,7 @@ $dom = DOM\HTMLDocument::createFromString(<<<HTML
</html> </html>
HTML); HTML);
$xpath = new DOM\XPath($dom); $xpath = new Dom\XPath($dom);
foreach ($xpath->query("//*") as $element) { foreach ($xpath->query("//*") as $element) {
echo "Element: '", $element->tagName, "', ", $element->getLineNo(), "\n"; echo "Element: '", $element->tagName, "', ", $element->getLineNo(), "\n";

View file

@ -1,5 +1,5 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromString() - normal document, no error Dom\HTMLDocument::createFromString() - normal document, no error
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
@ -21,8 +21,8 @@ $html = <<<HTML
</body> </body>
</html> </html>
HTML; HTML;
$dom = DOM\HTMLDocument::createFromString($html); $dom = Dom\HTMLDocument::createFromString($html);
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,11 +1,11 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromString(): Old DTD Dom\HTMLDocument::createFromString(): Old DTD
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromString(<<<HTML $dom = Dom\HTMLDocument::createFromString(<<<HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html> <html>
<head> <head>
@ -16,13 +16,13 @@ $dom = DOM\HTMLDocument::createFromString(<<<HTML
HTML); HTML);
echo "--- HTML serialization ---\n"; echo "--- HTML serialization ---\n";
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
echo "--- XML serialization ---\n"; echo "--- XML serialization ---\n";
echo $dom->saveXML(); echo $dom->saveXml();
?> ?>
--EXPECTF-- --EXPECTF--
Warning: DOM\HTMLDocument::createFromString(): tree error bad-doctype-token-in-initial-mode in Entity, line: 1, column: 3-9 in %s on line %d Warning: Dom\HTMLDocument::createFromString(): tree error bad-doctype-token-in-initial-mode in Entity, line: 1, column: 3-9 in %s on line %d
--- HTML serialization --- --- HTML serialization ---
<!DOCTYPE html><html><head> <!DOCTYPE html><html><head>
</head> </head>

View file

@ -1,19 +1,19 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromString() - parser warning 01 Dom\HTMLDocument::createFromString() - parser warning 01
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$html = file_get_contents(__DIR__."/parser_warning_01.html"); $html = file_get_contents(__DIR__."/parser_warning_01.html");
$dom = DOM\HTMLDocument::createFromString($html); $dom = Dom\HTMLDocument::createFromString($html);
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
?> ?>
--EXPECTF-- --EXPECTF--
Warning: DOM\HTMLDocument::createFromString(): tokenizer error missing-end-tag-name in Entity, line: 7, column: 11 in %s on line %d Warning: Dom\HTMLDocument::createFromString(): tokenizer error missing-end-tag-name in Entity, line: 7, column: 11 in %s on line %d
Warning: DOM\HTMLDocument::createFromString(): tree error unexpected-token-in-initial-mode in Entity, line: 1, column: 2-6 in %s on line %d Warning: Dom\HTMLDocument::createFromString(): tree error unexpected-token-in-initial-mode in Entity, line: 1, column: 2-6 in %s on line %d
<html><head><title>foo</title> <html><head><title>foo</title>
</head><body><datalist id="fruits"> </head><body><datalist id="fruits">
<option value="Apple"> <option value="Apple">

View file

@ -1,27 +1,27 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromString() - parser warning 02 Dom\HTMLDocument::createFromString() - parser warning 02
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$html = file_get_contents(__DIR__."/parser_warning_02.html"); $html = file_get_contents(__DIR__."/parser_warning_02.html");
$dom = DOM\HTMLDocument::createFromString($html); $dom = Dom\HTMLDocument::createFromString($html);
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
?> ?>
--EXPECTF-- --EXPECTF--
Warning: DOM\HTMLDocument::createFromString(): tokenizer error unexpected-null-character in Entity, line: 4, column: 11 in %s on line %d Warning: Dom\HTMLDocument::createFromString(): tokenizer error unexpected-null-character in Entity, line: 4, column: 11 in %s on line %d
Warning: DOM\HTMLDocument::createFromString(): tokenizer error missing-whitespace-between-attributes in Entity, line: 5, column: 20 in %s on line %d Warning: Dom\HTMLDocument::createFromString(): tokenizer error missing-whitespace-between-attributes in Entity, line: 5, column: 20 in %s on line %d
Warning: DOM\HTMLDocument::createFromString(): tokenizer error incorrectly-opened-comment in Entity, line: 6, column: 11 in %s on line %d Warning: Dom\HTMLDocument::createFromString(): tokenizer error incorrectly-opened-comment in Entity, line: 6, column: 11 in %s on line %d
Warning: DOM\HTMLDocument::createFromString(): tokenizer error nested-comment in Entity, line: 7, column: 18 in %s on line %d Warning: Dom\HTMLDocument::createFromString(): tokenizer error nested-comment in Entity, line: 7, column: 18 in %s on line %d
Warning: DOM\HTMLDocument::createFromString(): tree error unexpected-closed-token in Entity, line: 4, column: 18 in %s on line %d Warning: Dom\HTMLDocument::createFromString(): tree error unexpected-closed-token in Entity, line: 4, column: 18 in %s on line %d
Warning: DOM\HTMLDocument::createFromString(): tree error doctype-token-in-body-mode in Entity, line: 8, column: 11-17 in %s on line %d Warning: Dom\HTMLDocument::createFromString(): tree error doctype-token-in-body-mode in Entity, line: 8, column: 11-17 in %s on line %d
<!DOCTYPE html><html><head></head><body> <!DOCTYPE html><html><head></head><body>
<p<>>foo<p></p> <p<>>foo<p></p>
<p id="foo" class="bar"> <p id="foo" class="bar">

View file

@ -1,13 +1,13 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromString() - parser warning 03 Dom\HTMLDocument::createFromString() - parser warning 03
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$html = file_get_contents(__DIR__."/parser_warning_03.html"); $html = file_get_contents(__DIR__."/parser_warning_03.html");
$dom = DOM\HTMLDocument::createFromString($html, LIBXML_NOERROR); $dom = Dom\HTMLDocument::createFromString($html, LIBXML_NOERROR);
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,5 +1,5 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromString() - parser warning via internal error Dom\HTMLDocument::createFromString() - parser warning via internal error
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
@ -8,7 +8,7 @@ dom
libxml_use_internal_errors(true); libxml_use_internal_errors(true);
$html = '<>x</> <!doctype html>'; $html = '<>x</> <!doctype html>';
$dom = DOM\HTMLDocument::createFromString($html); $dom = Dom\HTMLDocument::createFromString($html);
foreach (libxml_get_errors() as $error) { foreach (libxml_get_errors() as $error) {
var_dump($error->message, $error->line, $error->column); var_dump($error->message, $error->line, $error->column);
} }

View file

@ -1,12 +1,12 @@
--TEST-- --TEST--
DOM\HTMLDocument::createFromString() - document without body Dom\HTMLDocument::createFromString() - document without body
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromString('<!doctype html><p align="\'">foo &apos;</p>'); $dom = Dom\HTMLDocument::createFromString('<!doctype html><p align="\'">foo &apos;</p>');
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,5 +1,5 @@
--TEST-- --TEST--
DOM\HTMLDocument: loading $options check Dom\HTMLDocument: loading $options check
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
@ -30,7 +30,7 @@ foreach (["createFromString", "createFromFile"] as $method) {
foreach ($tested_options as $options) { foreach ($tested_options as $options) {
var_dump($options); var_dump($options);
try { try {
DOM\HTMLDocument::{$method}("x", $options); Dom\HTMLDocument::{$method}("x", $options);
} catch (ValueError $e) { } catch (ValueError $e) {
echo $e->getMessage(), "\n"; echo $e->getMessage(), "\n";
} }
@ -41,67 +41,67 @@ foreach (["createFromString", "createFromFile"] as $method) {
--EXPECTF-- --EXPECTF--
--- Method createFromString --- --- Method createFromString ---
int(%d) int(%d)
DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(4194304) int(4194304)
DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(524288) int(524288)
DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(8) int(8)
DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(4) int(4)
DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(16) int(16)
DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(4) int(4)
DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(256) int(256)
DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(16384) int(16384)
DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(4) int(4)
DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(2) int(2)
DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(1024) int(1024)
DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(1) int(1)
DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(2048) int(2048)
DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(64) int(64)
DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(128) int(128)
DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
--- Method createFromFile --- --- Method createFromFile ---
int(%d) int(%d)
DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(4194304) int(4194304)
DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(524288) int(524288)
DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(8) int(8)
DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(4) int(4)
DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(16) int(16)
DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(4) int(4)
DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(256) int(256)
DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(16384) int(16384)
DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(4) int(4)
DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(2) int(2)
DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(1024) int(1024)
DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(1) int(1)
DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(2048) int(2048)
DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(64) int(64)
DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(128) int(128)
DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS) Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)

View file

@ -5,7 +5,7 @@ dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromString(<<<HTML $dom = Dom\HTMLDocument::createFromString(<<<HTML
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@ -28,7 +28,7 @@ $dom = DOM\HTMLDocument::createFromString(<<<HTML
HTML); HTML);
echo "--- Namespaces ---\n"; echo "--- Namespaces ---\n";
$xpath = new DOM\XPath($dom); $xpath = new Dom\XPath($dom);
foreach ($xpath->query("//*[name()='body']//*") as $node) { foreach ($xpath->query("//*[name()='body']//*") as $node) {
echo $node->nodeName, " ", $node->namespaceURI ?? "(NONE)", "\n"; echo $node->nodeName, " ", $node->namespaceURI ?? "(NONE)", "\n";
foreach ($node->attributes as $attribute) { foreach ($node->attributes as $attribute) {
@ -37,9 +37,9 @@ foreach ($xpath->query("//*[name()='body']//*") as $node) {
} }
echo "--- HTML serialization ---\n"; echo "--- HTML serialization ---\n";
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
echo "--- XML serialization ---\n"; echo "--- XML serialization ---\n";
echo $dom->saveXML(); echo $dom->saveXml();
?> ?>
--EXPECT-- --EXPECT--

View file

@ -11,9 +11,9 @@ set_error_handler(function ($errno, $errstr, $errfile, $errline) {
var_dump($errno, $errstr); var_dump($errno, $errstr);
}, E_WARNING); }, E_WARNING);
DOM\HTMLDocument::createFromString('<html></html>'); Dom\HTMLDocument::createFromString('<html></html>');
?> ?>
--EXPECT-- --EXPECT--
int(2) int(2)
string(113) "DOM\HTMLDocument::createFromString(): tree error unexpected-token-in-initial-mode in Entity, line: 1, column: 2-5" string(113) "Dom\HTMLDocument::createFromString(): tree error unexpected-token-in-initial-mode in Entity, line: 1, column: 2-5"

View file

@ -5,7 +5,7 @@ dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromString(<<<HTML $dom = Dom\HTMLDocument::createFromString(<<<HTML
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@ -18,7 +18,7 @@ $dom = DOM\HTMLDocument::createFromString(<<<HTML
HTML); HTML);
echo "--- Namespaces ---\n"; echo "--- Namespaces ---\n";
$xpath = new DOM\XPath($dom); $xpath = new Dom\XPath($dom);
foreach ($xpath->query("//*[name()='body']//*") as $node) { foreach ($xpath->query("//*[name()='body']//*") as $node) {
echo $node->nodeName, " ", $node->namespaceURI ?? "(NONE)", "\n"; echo $node->nodeName, " ", $node->namespaceURI ?? "(NONE)", "\n";
echo "prefix: \"", $node->prefix, "\"\n"; echo "prefix: \"", $node->prefix, "\"\n";
@ -28,9 +28,9 @@ foreach ($xpath->query("//*[name()='body']//*") as $node) {
} }
echo "--- HTML serialization ---\n"; echo "--- HTML serialization ---\n";
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
echo "--- XML serialization ---\n"; echo "--- XML serialization ---\n";
echo $dom->saveXML(); echo $dom->saveXml();
?> ?>
--EXPECT-- --EXPECT--

View file

@ -9,11 +9,11 @@ $dom1 = new DOMDocument();
$root = $dom1->appendChild($dom1->createElement('root')); $root = $dom1->appendChild($dom1->createElement('root'));
$root->appendChild($dom1->createEntityReference('nbsp')); $root->appendChild($dom1->createEntityReference('nbsp'));
$dom2 = DOM\HTMLDocument::createEmpty(); $dom2 = Dom\HTMLDocument::createEmpty();
$dom2->appendChild($dom2->importLegacyNode($root, true)); $dom2->appendChild($dom2->importLegacyNode($root, true));
echo $dom2->saveXML(), "\n"; echo $dom2->saveXml(), "\n";
echo $dom2->saveHTML(), "\n"; echo $dom2->saveHtml(), "\n";
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,14 +1,14 @@
--TEST-- --TEST--
DOM\HTMLDocument serialization escape attribute Dom\HTMLDocument serialization escape attribute
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromString("<p></p>", LIBXML_NOERROR); $dom = Dom\HTMLDocument::createFromString("<p></p>", LIBXML_NOERROR);
$p = $dom->documentElement->firstChild->nextSibling->firstChild; $p = $dom->documentElement->firstChild->nextSibling->firstChild;
$p->setAttribute("foo", "<bar>\"'&"); $p->setAttribute("foo", "<bar>\"'&");
echo $dom->saveHTML(); echo $dom->saveHtml();
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,12 +1,12 @@
--TEST-- --TEST--
DOM\HTMLDocument serialization escape nbsp Dom\HTMLDocument serialization escape nbsp
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromString("<p>these must transform: \xc2\xa0\xc2\xa0 but these not: \xa0|\xc2...</p><br>", LIBXML_NOERROR); $dom = Dom\HTMLDocument::createFromString("<p>these must transform: \xc2\xa0\xc2\xa0 but these not: \xa0|\xc2...</p><br>", LIBXML_NOERROR);
echo $dom->saveHTML(); echo $dom->saveHtml();
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,11 +1,11 @@
--TEST-- --TEST--
DOM\HTMLDocument serialization of an attribute in a namespace Dom\HTMLDocument serialization of an attribute in a namespace
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createEmpty(); $dom = Dom\HTMLDocument::createEmpty();
$root = $dom->appendChild($dom->createElement("root")); $root = $dom->appendChild($dom->createElement("root"));
$root->setAttributeNodeNS($dom->createAttributeNS("http://php.net", "x:foo")); $root->setAttributeNodeNS($dom->createAttributeNS("http://php.net", "x:foo"));
$root->setAttributeNodeNS($dom->createAttributeNS("http://www.w3.org/XML/1998/namespace", "y:id")); $root->setAttributeNodeNS($dom->createAttributeNS("http://www.w3.org/XML/1998/namespace", "y:id"));
@ -14,7 +14,7 @@ $root->setAttributeNodeNS($dom->createAttributeNS("http://www.w3.org/2000/xmlns/
$root->setAttributeNodeNS($dom->createAttributeNS("http://www.w3.org/1999/xlink", "z:f")); $root->setAttributeNodeNS($dom->createAttributeNS("http://www.w3.org/1999/xlink", "z:f"));
// Note: XML declarations are not emitted in HTML5 // Note: XML declarations are not emitted in HTML5
echo $dom->saveHTML(); echo $dom->saveHtml();
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,18 +1,18 @@
--TEST-- --TEST--
DOM\HTMLDocument serialization of CData Dom\HTMLDocument serialization of CData
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
// Note: can't create CData in an HTML document. // Note: can't create CData in an HTML document.
$dom = DOM\XMLDocument::createEmpty(); $dom = Dom\XMLDocument::createEmpty();
$cdata = $dom->createCDATASection("foobaré\"<>-&"); $cdata = $dom->createCDATASection("foobaré\"<>-&");
$dom = DOM\HTMLDocument::createEmpty(); $dom = Dom\HTMLDocument::createEmpty();
$container = $dom->appendChild($dom->createElement("container")); $container = $dom->appendChild($dom->createElement("container"));
$container->appendChild($dom->importNode($cdata)); $container->appendChild($dom->importNode($cdata));
echo $dom->saveHTML(); echo $dom->saveHtml();
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,13 +1,13 @@
--TEST-- --TEST--
DOM\HTMLDocument serialization of comment Dom\HTMLDocument serialization of comment
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createEmpty(); $dom = Dom\HTMLDocument::createEmpty();
$dom->appendChild($dom->createComment("foobaré\"<>-&")); $dom->appendChild($dom->createComment("foobaré\"<>-&"));
echo $dom->saveHTML(); echo $dom->saveHtml();
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,11 +1,11 @@
--TEST-- --TEST--
DOM\HTMLDocument serialization of document type Dom\HTMLDocument serialization of document type
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromString(<<<HTML $dom = Dom\HTMLDocument::createFromString(<<<HTML
<!DOCTYPE HTML1234 PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML1234 PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html> <html>
<head> <head>
@ -16,10 +16,10 @@ $dom = DOM\HTMLDocument::createFromString(<<<HTML
HTML, LIBXML_NOERROR); HTML, LIBXML_NOERROR);
echo "--- XML encoding ---\n"; echo "--- XML encoding ---\n";
echo $dom->saveXML(), "\n"; echo $dom->saveXml(), "\n";
echo "--- HTML encoding ---\n"; echo "--- HTML encoding ---\n";
// We don't expect to see the public ID and the system ID because the serialization algorithm doesn't serialize those // We don't expect to see the public ID and the system ID because the serialization algorithm doesn't serialize those
echo $dom->saveHTML(), "\n"; echo $dom->saveHtml(), "\n";
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,11 +1,11 @@
--TEST-- --TEST--
DOM\HTMLDocument serialization of element in a namespace Dom\HTMLDocument serialization of element in a namespace
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createEmpty(); $dom = Dom\HTMLDocument::createEmpty();
$root = $dom->appendChild($dom->createElement("root")); $root = $dom->appendChild($dom->createElement("root"));
$root->append("\n"); $root->append("\n");
@ -16,7 +16,7 @@ $root->append($dom->createElementNS("http://www.w3.org/2000/svg", "s:svg"), "\n"
$root->append($dom->createElementNS("http://www.w3.org/1998/Math/MathML", "m:math"), "\n"); $root->append($dom->createElementNS("http://www.w3.org/1998/Math/MathML", "m:math"), "\n");
// Note: XML declarations are not emitted in HTML5 // Note: XML declarations are not emitted in HTML5
echo $dom->saveHTML(); echo $dom->saveHtml();
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,5 +1,5 @@
--TEST-- --TEST--
DOM\HTMLDocument serialization with a failing stream Dom\HTMLDocument serialization with a failing stream
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
@ -33,9 +33,9 @@ class FailingWrapper {
stream_wrapper_register("failing", "FailingWrapper"); stream_wrapper_register("failing", "FailingWrapper");
$dom = DOM\HTMLDocument::createEmpty(); $dom = Dom\HTMLDocument::createEmpty();
$root = $dom->appendChild($dom->createElement("root")); $root = $dom->appendChild($dom->createElement("root"));
$dom->saveHTMLFile("failing://foo"); $dom->saveHtmlFile("failing://foo");
?> ?>
--EXPECTF-- --EXPECTF--
@ -44,6 +44,6 @@ string(1) "<"
Fatal error: Uncaught Error: fail in %s:%d Fatal error: Uncaught Error: fail in %s:%d
Stack trace: Stack trace:
#0 [internal function]: FailingWrapper->stream_write('root') #0 [internal function]: FailingWrapper->stream_write('root')
#1 %s(%d): DOM\HTMLDocument->saveHTMLFile('failing://foo') #1 %s(%d): Dom\HTMLDocument->saveHtmlFile('failing://foo')
#2 {main} #2 {main}
thrown in %s on line %d thrown in %s on line %d

View file

@ -1,17 +1,17 @@
--TEST-- --TEST--
DOM\HTMLDocument serialization of document fragment Dom\HTMLDocument serialization of document fragment
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createEmpty(); $dom = Dom\HTMLDocument::createEmpty();
$fragment = $dom->createDocumentFragment(); $fragment = $dom->createDocumentFragment();
$fragment->appendChild($dom->createElement("foo")); $fragment->appendChild($dom->createElement("foo"));
$bar = $fragment->appendChild($dom->createElement("bar")); $bar = $fragment->appendChild($dom->createElement("bar"));
$fragment->appendChild($dom->createElement("baz")); $fragment->appendChild($dom->createElement("baz"));
$bar->appendChild($dom->createElement("inner")); $bar->appendChild($dom->createElement("inner"));
echo $dom->saveHTML($fragment); echo $dom->saveHtml($fragment);
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,11 +1,11 @@
--TEST-- --TEST--
DOM\HTMLDocument serialization of full document Dom\HTMLDocument serialization of full document
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromString(<<<HTML $dom = Dom\HTMLDocument::createFromString(<<<HTML
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html lang="en"> <html lang="en">
<head> <head>
@ -27,7 +27,7 @@ $dom = DOM\HTMLDocument::createFromString(<<<HTML
</body> </body>
</html> </html>
HTML); HTML);
echo $dom->saveHTML(); echo $dom->saveHtml();
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,24 +1,24 @@
--TEST-- --TEST--
DOM\HTMLDocument serialization with an imported namespace node 01 Dom\HTMLDocument serialization with an imported namespace node 01
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$xml = DOM\XMLDocument::createFromString('<?xml version="1.0"?><container xmlns="some:ns" xmlns:bar="another:ns"/>'); $xml = Dom\XMLDocument::createFromString('<?xml version="1.0"?><container xmlns="some:ns" xmlns:bar="another:ns"/>');
$xml->documentElement->setAttributeNS("http://foo/", "foo:bar", "value"); $xml->documentElement->setAttributeNS("http://foo/", "foo:bar", "value");
$xml->documentElement->appendChild($xml->createElementNS('some:ns2', 'child')); $xml->documentElement->appendChild($xml->createElementNS('some:ns2', 'child'));
echo $xml->saveXML(), "\n"; echo $xml->saveXml(), "\n";
echo "--- After import into HTML ---\n"; echo "--- After import into HTML ---\n";
$html = DOM\HTMLDocument::createFromString('<p>foo</p>', LIBXML_NOERROR); $html = Dom\HTMLDocument::createFromString('<p>foo</p>', LIBXML_NOERROR);
$p = $html->documentElement->firstChild->nextSibling->firstChild; $p = $html->documentElement->firstChild->nextSibling->firstChild;
$p->appendChild($html->importNode($xml->documentElement, true)); $p->appendChild($html->importNode($xml->documentElement, true));
echo $html->saveXML(), "\n"; echo $html->saveXml(), "\n";
echo $html->saveHTML(), "\n"; echo $html->saveHtml(), "\n";
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,23 +1,23 @@
--TEST-- --TEST--
DOM\HTMLDocument serialization with an imported namespace node 02 Dom\HTMLDocument serialization with an imported namespace node 02
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$xml = DOM\XMLDocument::createFromFile(__DIR__.'/sample.xml'); $xml = Dom\XMLDocument::createFromFile(__DIR__.'/sample.xml');
$xml->documentElement->appendChild($xml->createElementNS('some:ns2', 'child')); $xml->documentElement->appendChild($xml->createElementNS('some:ns2', 'child'));
echo $xml->saveXML(), "\n"; echo $xml->saveXml(), "\n";
echo "--- After import into HTML ---\n"; echo "--- After import into HTML ---\n";
$html = DOM\HTMLDocument::createFromString('<p>foo</p>', LIBXML_NOERROR); $html = Dom\HTMLDocument::createFromString('<p>foo</p>', LIBXML_NOERROR);
$p = $html->documentElement->firstChild->nextSibling->firstChild; $p = $html->documentElement->firstChild->nextSibling->firstChild;
$p->appendChild($html->importNode($xml->documentElement, true)); $p->appendChild($html->importNode($xml->documentElement, true));
echo $html->saveXML(), "\n"; echo $html->saveXml(), "\n";
echo $html->saveHTML(), "\n"; echo $html->saveHtml(), "\n";
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,23 +1,23 @@
--TEST-- --TEST--
DOM\HTMLDocument serialization with an imported namespace node 03 Dom\HTMLDocument serialization with an imported namespace node 03
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$xml = DOM\XMLDocument::createFromFile(__DIR__.'/sample.xml'); $xml = Dom\XMLDocument::createFromFile(__DIR__.'/sample.xml');
$xml->documentElement->appendChild($xml->createElementNS('some:ns2', 'child')); $xml->documentElement->appendChild($xml->createElementNS('some:ns2', 'child'));
echo $xml->saveXML(), "\n"; echo $xml->saveXml(), "\n";
echo "--- After import into HTML ---\n"; echo "--- After import into HTML ---\n";
$html = DOM\HTMLDocument::createFromString('<p>foo</p>', LIBXML_NOERROR); $html = Dom\HTMLDocument::createFromString('<p>foo</p>', LIBXML_NOERROR);
$p = $html->documentElement->firstChild->nextSibling->firstChild; $p = $html->documentElement->firstChild->nextSibling->firstChild;
$p->appendChild($html->importNode($xml->documentElement, false)); $p->appendChild($html->importNode($xml->documentElement, false));
echo $html->saveXML(), "\n"; echo $html->saveXml(), "\n";
echo $html->saveHTML(), "\n"; echo $html->saveHtml(), "\n";
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,23 +1,23 @@
--TEST-- --TEST--
DOM\HTMLDocument serialization with an imported namespace node 04 Dom\HTMLDocument serialization with an imported namespace node 04
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$xml = DOM\XMLDocument::createFromFile(__DIR__.'/sample.xml'); $xml = Dom\XMLDocument::createFromFile(__DIR__.'/sample.xml');
$xml->documentElement->appendChild($xml->createElementNS('some:ns2', 'child')); $xml->documentElement->appendChild($xml->createElementNS('some:ns2', 'child'));
echo $xml->saveXML(), "\n"; echo $xml->saveXml(), "\n";
echo "--- After import into HTML ---\n"; echo "--- After import into HTML ---\n";
$html = DOM\HTMLDocument::createFromString('<p>foo</p>', LIBXML_NOERROR); $html = Dom\HTMLDocument::createFromString('<p>foo</p>', LIBXML_NOERROR);
$p = $html->documentElement->firstChild->nextSibling->firstChild; $p = $html->documentElement->firstChild->nextSibling->firstChild;
$p->appendChild($html->importNode($xml->documentElement, false)); $p->appendChild($html->importNode($xml->documentElement, false));
echo $html->saveXML(), "\n"; echo $html->saveXml(), "\n";
echo $html->saveHTML(), "\n"; echo $html->saveHtml(), "\n";
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,23 +1,23 @@
--TEST-- --TEST--
DOM\HTMLDocument serialization with an imported namespace node 05 Dom\HTMLDocument serialization with an imported namespace node 05
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$xml = DOM\XMLDocument::createFromFile(__DIR__.'/sample.xml'); $xml = Dom\XMLDocument::createFromFile(__DIR__.'/sample.xml');
$xml->documentElement->appendChild($xml->createElementNS('some:ns2', 'child')); $xml->documentElement->appendChild($xml->createElementNS('some:ns2', 'child'));
echo $xml->saveXML(), "\n"; echo $xml->saveXml(), "\n";
echo "--- After adoption into HTML ---\n"; echo "--- After adoption into HTML ---\n";
$html = DOM\HTMLDocument::createFromString('<p>foo</p>', LIBXML_NOERROR); $html = Dom\HTMLDocument::createFromString('<p>foo</p>', LIBXML_NOERROR);
$p = $html->documentElement->firstChild->nextSibling->firstChild; $p = $html->documentElement->firstChild->nextSibling->firstChild;
$p->appendChild($html->adoptNode($xml->documentElement)); $p->appendChild($html->adoptNode($xml->documentElement));
echo $html->saveXML(), "\n"; echo $html->saveXml(), "\n";
echo $html->saveHTML(), "\n"; echo $html->saveHtml(), "\n";
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,23 +1,23 @@
--TEST-- --TEST--
DOM\HTMLDocument serialization with an imported namespace node 06 Dom\HTMLDocument serialization with an imported namespace node 06
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$xml = DOM\XMLDocument::createFromFile(__DIR__.'/sample.xml'); $xml = Dom\XMLDocument::createFromFile(__DIR__.'/sample.xml');
$xml->documentElement->firstElementChild->appendChild($xml->createElementNS('some:ns2', 'child')); $xml->documentElement->firstElementChild->appendChild($xml->createElementNS('some:ns2', 'child'));
echo $xml->saveXML(), "\n"; echo $xml->saveXml(), "\n";
echo "--- After clone + import into HTML ---\n"; echo "--- After clone + import into HTML ---\n";
$html = DOM\HTMLDocument::createFromString('<p>foo</p>', LIBXML_NOERROR); $html = Dom\HTMLDocument::createFromString('<p>foo</p>', LIBXML_NOERROR);
$p = $html->documentElement->firstElementChild->nextElementSibling->firstElementChild; $p = $html->documentElement->firstElementChild->nextElementSibling->firstElementChild;
$p->appendChild($html->adoptNode($xml->documentElement->firstElementChild->cloneNode(true))); $p->appendChild($html->adoptNode($xml->documentElement->firstElementChild->cloneNode(true)));
echo $html->saveXML(), "\n"; echo $html->saveXml(), "\n";
echo $html->saveHTML(), "\n"; echo $html->saveHtml(), "\n";
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,14 +1,14 @@
--TEST-- --TEST--
DOM\HTMLDocument serialization of processing instruction Dom\HTMLDocument serialization of processing instruction
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createEmpty(); $dom = Dom\HTMLDocument::createEmpty();
// Note: you can put > in a processing instruction element but that breaks (as expected) // Note: you can put > in a processing instruction element but that breaks (as expected)
$dom->appendChild($dom->createProcessingInstruction("target", "foobaré\"&<\xc2\xa0")); $dom->appendChild($dom->createProcessingInstruction("target", "foobaré\"&<\xc2\xa0"));
echo $dom->saveHTML(); echo $dom->saveHtml();
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,15 +1,15 @@
--TEST-- --TEST--
DOM\HTMLDocument serialization of different roots Dom\HTMLDocument serialization of different roots
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
// Note: can't create CData in an HTML document. // Note: can't create CData in an HTML document.
$dom = DOM\XMLDocument::createEmpty(); $dom = Dom\XMLDocument::createEmpty();
$cdata = $dom->createCDATASection("cdata"); $cdata = $dom->createCDATASection("cdata");
$dom = DOM\HTMLDocument::createEmpty(); $dom = Dom\HTMLDocument::createEmpty();
$container = $dom->appendChild($dom->createElement("container")); $container = $dom->appendChild($dom->createElement("container"));
$comment = $container->appendChild($dom->createComment("comment")); $comment = $container->appendChild($dom->createComment("comment"));
$cdata = $container->appendChild($dom->importNode($cdata)); $cdata = $container->appendChild($dom->importNode($cdata));
@ -18,12 +18,12 @@ $text = $container->appendChild($dom->createTextNode("text"));
$pi = $container->appendChild($dom->createProcessingInstruction("target", "data")); $pi = $container->appendChild($dom->createProcessingInstruction("target", "data"));
$fragment = $dom->createDocumentFragment(); $fragment = $dom->createDocumentFragment();
var_dump($dom->saveHTML($comment)); var_dump($dom->saveHtml($comment));
var_dump($dom->saveHTML($cdata)); var_dump($dom->saveHtml($cdata));
var_dump($dom->saveHTML($emptyElement)); var_dump($dom->saveHtml($emptyElement));
var_dump($dom->saveHTML($text)); var_dump($dom->saveHtml($text));
var_dump($dom->saveHTML($pi)); var_dump($dom->saveHtml($pi));
var_dump($dom->saveHTML($fragment)); var_dump($dom->saveHtml($fragment));
?> ?>
--EXPECT-- --EXPECT--

View file

@ -1,14 +1,14 @@
--TEST-- --TEST--
DOM\HTMLDocument serialization escape text 01 Dom\HTMLDocument serialization escape text 01
--EXTENSIONS-- --EXTENSIONS--
dom dom
--FILE-- --FILE--
<?php <?php
$dom = DOM\HTMLDocument::createFromString("<p></p>", LIBXML_NOERROR); $dom = Dom\HTMLDocument::createFromString("<p></p>", LIBXML_NOERROR);
$p = $dom->documentElement->firstChild->nextSibling->firstChild; $p = $dom->documentElement->firstChild->nextSibling->firstChild;
$p->textContent = "this is <some> &text! \"\""; $p->textContent = "this is <some> &text! \"\"";
echo $dom->saveHTML(); echo $dom->saveHtml();
?> ?>
--EXPECT-- --EXPECT--

Some files were not shown because too many files have changed in this diff Show more