From e6f77495c20c985ee0ed68d3f0751195e2a24575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Sat, 11 Apr 2020 22:01:51 +0200 Subject: [PATCH 1/2] Generate method entries for ext/dom --- build/gen_stub.php | 2 +- ext/dom/attr.c | 11 +- ext/dom/attr.stub.php | 9 - ext/dom/attr_arginfo.h | 9 - ext/dom/cdatasection.c | 8 +- ext/dom/cdatasection.stub.php | 6 - ext/dom/cdatasection_arginfo.h | 5 - ext/dom/characterdata.c | 32 +- ext/dom/characterdata.stub.php | 30 - ext/dom/characterdata_arginfo.h | 34 -- ext/dom/comment.c | 8 +- ext/dom/comment.stub.php | 6 - ext/dom/comment_arginfo.h | 5 - ext/dom/document.c | 112 ++-- ext/dom/document.stub.php | 109 ---- ext/dom/document_arginfo.h | 154 ----- ext/dom/documentfragment.c | 17 +- ext/dom/documentfragment.stub.php | 15 - ext/dom/documentfragment_arginfo.h | 14 - ext/dom/dom.stub.php | 8 - ext/dom/dom_arginfo.h | 19 - ext/dom/dom_fe.h | 180 ------ ext/dom/domexception.c | 4 - ext/dom/domimplementation.c | 17 +- ext/dom/domimplementation.stub.php | 17 - ext/dom/domimplementation_arginfo.h | 20 - ext/dom/element.c | 81 +-- ext/dom/element.stub.php | 77 --- ext/dom/element_arginfo.h | 85 --- ext/dom/entity.c | 4 - ext/dom/entityreference.c | 8 +- ext/dom/entityreference.stub.php | 6 - ext/dom/entityreference_arginfo.h | 5 - ext/dom/namednodemap.c | 18 +- ext/dom/namednodemap.stub.php | 16 - ext/dom/namednodemap_arginfo.h | 17 - ext/dom/node.c | 65 +- ext/dom/node.stub.php | 69 --- ext/dom/node_arginfo.h | 79 --- ext/dom/nodelist.c | 11 +- ext/dom/nodelist.stub.php | 10 - ext/dom/nodelist_arginfo.h | 8 - ext/dom/notation.c | 4 - ext/dom/parentnode.c | 9 - ext/dom/parentnode.stub.php | 10 - ext/dom/parentnode_arginfo.h | 7 - ext/dom/php_dom.c | 45 +- ext/dom/php_dom.stub.php | 411 +++++++++++++ ext/dom/php_dom_arginfo.h | 772 ++++++++++++++++++++++++ ext/dom/processinginstruction.c | 8 +- ext/dom/processinginstruction.stub.php | 6 - ext/dom/processinginstruction_arginfo.h | 6 - ext/dom/text.c | 15 +- ext/dom/text.stub.php | 14 - ext/dom/text_arginfo.h | 14 - ext/dom/xpath.c | 21 +- ext/dom/xpath.stub.php | 2 + ext/dom/xpath_arginfo.h | 37 ++ 58 files changed, 1360 insertions(+), 1431 deletions(-) delete mode 100644 ext/dom/attr.stub.php delete mode 100644 ext/dom/attr_arginfo.h delete mode 100644 ext/dom/cdatasection.stub.php delete mode 100644 ext/dom/cdatasection_arginfo.h delete mode 100644 ext/dom/characterdata.stub.php delete mode 100644 ext/dom/characterdata_arginfo.h delete mode 100644 ext/dom/comment.stub.php delete mode 100644 ext/dom/comment_arginfo.h delete mode 100644 ext/dom/document.stub.php delete mode 100644 ext/dom/document_arginfo.h delete mode 100644 ext/dom/documentfragment.stub.php delete mode 100644 ext/dom/documentfragment_arginfo.h delete mode 100644 ext/dom/dom.stub.php delete mode 100644 ext/dom/dom_arginfo.h delete mode 100644 ext/dom/domimplementation.stub.php delete mode 100644 ext/dom/domimplementation_arginfo.h delete mode 100644 ext/dom/element.stub.php delete mode 100644 ext/dom/element_arginfo.h delete mode 100644 ext/dom/entityreference.stub.php delete mode 100644 ext/dom/entityreference_arginfo.h delete mode 100644 ext/dom/namednodemap.stub.php delete mode 100644 ext/dom/namednodemap_arginfo.h delete mode 100644 ext/dom/node.stub.php delete mode 100644 ext/dom/node_arginfo.h delete mode 100644 ext/dom/nodelist.stub.php delete mode 100644 ext/dom/nodelist_arginfo.h delete mode 100644 ext/dom/parentnode.stub.php delete mode 100644 ext/dom/parentnode_arginfo.h create mode 100644 ext/dom/php_dom.stub.php create mode 100644 ext/dom/php_dom_arginfo.h delete mode 100644 ext/dom/processinginstruction.stub.php delete mode 100644 ext/dom/processinginstruction_arginfo.h delete mode 100644 ext/dom/text.stub.php delete mode 100644 ext/dom/text_arginfo.h diff --git a/build/gen_stub.php b/build/gen_stub.php index b108191f64447..131f60bab7697 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -421,7 +421,7 @@ public function getFunctionEntry(): string { if ($this->alias->className) { return sprintf( "\tZEND_MALIAS(%s, %s, %s, %s, %s)\n", - $this->alias->className, $this->name, $this->alias->name, $this->getArgInfoName(), $this->getFlagsAsString() + $this->alias->className, $this->name->name, $this->alias->name, $this->getArgInfoName(), $this->getFlagsAsString() ); } else { return sprintf( diff --git a/ext/dom/attr.c b/ext/dom/attr.c index 9c097eb8430a2..f6612e791a7d7 100644 --- a/ext/dom/attr.c +++ b/ext/dom/attr.c @@ -24,7 +24,6 @@ #if HAVE_LIBXML && HAVE_DOM #include "php_dom.h" -#include "attr_arginfo.h" /* * class DOMAttr extends DOMNode @@ -33,14 +32,8 @@ * Since: */ -const zend_function_entry php_dom_attr_class_functions[] = { - PHP_ME(domattr, isId, arginfo_class_DOMAttr_isId, ZEND_ACC_PUBLIC) - PHP_ME(domattr, __construct, arginfo_class_DOMAttr___construct, ZEND_ACC_PUBLIC) - PHP_FE_END -}; - /* {{{ proto DOMAttr::__construct(string name, [string value]) */ -PHP_METHOD(domattr, __construct) +PHP_METHOD(DOMAttr, __construct) { xmlAttrPtr nodep = NULL; xmlNodePtr oldnode = NULL; @@ -213,7 +206,7 @@ int dom_attr_schema_type_info_read(dom_object *obj, zval *retval) URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Attr-isId Since: DOM Level 3 */ -PHP_METHOD(domattr, isId) +PHP_METHOD(DOMAttr, isId) { zval *id; dom_object *intern; diff --git a/ext/dom/attr.stub.php b/ext/dom/attr.stub.php deleted file mode 100644 index 0d8f748421ed5..0000000000000 --- a/ext/dom/attr.stub.php +++ /dev/null @@ -1,9 +0,0 @@ - #ifdef LIBXML_SCHEMAS_ENABLED #include @@ -45,49 +44,6 @@ struct _idsIterator { * Since: */ -const zend_function_entry php_dom_document_class_functions[] = { /* {{{ */ - PHP_ME(domdocument, createElement, arginfo_class_DOMDocument_createElement, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, createDocumentFragment, arginfo_class_DOMDocument_createDocumentFragment, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, createTextNode, arginfo_class_DOMDocument_createTextNode, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, createComment, arginfo_class_DOMDocument_createComment, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, createCDATASection, arginfo_class_DOMDocument_createCDATASection, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, createProcessingInstruction, arginfo_class_DOMDocument_createProcessingInstruction, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, createAttribute, arginfo_class_DOMDocument_createAttribute, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, createEntityReference, arginfo_class_DOMDocument_createEntityReference, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, getElementsByTagName, arginfo_class_DOMDocument_getElementsByTagName, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, importNode, arginfo_class_DOMDocument_importNode, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, createElementNS, arginfo_class_DOMDocument_createElementNS, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, createAttributeNS, arginfo_class_DOMDocument_createAttributeNS, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, getElementsByTagNameNS, arginfo_class_DOMDocument_getElementsByTagNameNS, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, getElementById, arginfo_class_DOMDocument_getElementById, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, adoptNode, arginfo_class_DOMDocument_adoptNode, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, normalizeDocument, arginfo_class_DOMDocument_normalizeDocument, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, load, arginfo_class_DOMDocument_load, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, save, arginfo_class_DOMDocument_save, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, loadXML, arginfo_class_DOMDocument_loadXML, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, saveXML, arginfo_class_DOMDocument_saveXML, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, __construct, arginfo_class_DOMDocument___construct, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, validate, arginfo_class_DOMDocument_validate, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, xinclude, arginfo_class_DOMDocument_xinclude, ZEND_ACC_PUBLIC) -#if defined(LIBXML_HTML_ENABLED) - PHP_ME(domdocument, loadHTML, arginfo_class_DOMDocument_loadHTML, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, loadHTMLFile, arginfo_class_DOMDocument_loadHTMLFile, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, saveHTML, arginfo_class_DOMDocument_saveHTML, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, saveHTMLFile, arginfo_class_DOMDocument_saveHTMLFile, ZEND_ACC_PUBLIC) -#endif /* defined(LIBXML_HTML_ENABLED) */ -#if defined(LIBXML_SCHEMAS_ENABLED) - PHP_ME(domdocument, schemaValidate, arginfo_class_DOMDocument_schemaValidate, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, schemaValidateSource, arginfo_class_DOMDocument_schemaValidateSource, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, relaxNGValidate, arginfo_class_DOMDocument_relaxNGValidate, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, relaxNGValidateSource, arginfo_class_DOMDocument_relaxNGValidateSource, ZEND_ACC_PUBLIC) -#endif - PHP_ME(domdocument, registerNodeClass, arginfo_class_DOMDocument_registerNodeClass, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, append, arginfo_class_DOMDocument_append, ZEND_ACC_PUBLIC) - PHP_ME(domdocument, prepend, arginfo_class_DOMDocument_prepend, ZEND_ACC_PUBLIC) - PHP_FE_END -}; -/* }}} */ - /* {{{ docType DOMDocumentType readonly=yes URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-B63ED1A31 @@ -553,7 +509,7 @@ int dom_document_config_read(dom_object *obj, zval *retval) URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-2141741547 Since: */ -PHP_METHOD(domdocument, createElement) +PHP_METHOD(DOMDocument, createElement) { zval *id; xmlNode *node; @@ -588,7 +544,7 @@ PHP_METHOD(domdocument, createElement) URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-35CB04B5 Since: */ -PHP_METHOD(domdocument, createDocumentFragment) +PHP_METHOD(DOMDocument, createDocumentFragment) { zval *id; xmlNode *node; @@ -616,7 +572,7 @@ PHP_METHOD(domdocument, createDocumentFragment) URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1975348127 Since: */ -PHP_METHOD(domdocument, createTextNode) +PHP_METHOD(DOMDocument, createTextNode) { zval *id; xmlNode *node; @@ -646,7 +602,7 @@ PHP_METHOD(domdocument, createTextNode) URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1334481328 Since: */ -PHP_METHOD(domdocument, createComment) +PHP_METHOD(DOMDocument, createComment) { zval *id; xmlNode *node; @@ -676,7 +632,7 @@ PHP_METHOD(domdocument, createComment) URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-D26C0AF8 Since: */ -PHP_METHOD(domdocument, createCDATASection) +PHP_METHOD(DOMDocument, createCDATASection) { zval *id; xmlNode *node; @@ -706,7 +662,7 @@ PHP_METHOD(domdocument, createCDATASection) URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-135944439 Since: */ -PHP_METHOD(domdocument, createProcessingInstruction) +PHP_METHOD(DOMDocument, createProcessingInstruction) { zval *id; xmlNode *node; @@ -743,7 +699,7 @@ PHP_METHOD(domdocument, createProcessingInstruction) URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1084891198 Since: */ -PHP_METHOD(domdocument, createAttribute) +PHP_METHOD(DOMDocument, createAttribute) { zval *id; xmlAttrPtr node; @@ -779,7 +735,7 @@ PHP_METHOD(domdocument, createAttribute) URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-392B75AE Since: */ -PHP_METHOD(domdocument, createEntityReference) +PHP_METHOD(DOMDocument, createEntityReference) { zval *id; xmlNode *node; @@ -814,7 +770,7 @@ PHP_METHOD(domdocument, createEntityReference) URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-A6C9094 Since: */ -PHP_METHOD(domdocument, getElementsByTagName) +PHP_METHOD(DOMDocument, getElementsByTagName) { zval *id; xmlDocPtr docp; @@ -841,7 +797,7 @@ PHP_METHOD(domdocument, getElementsByTagName) URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Core-Document-importNode Since: DOM Level 2 */ -PHP_METHOD(domdocument, importNode) +PHP_METHOD(DOMDocument, importNode) { zval *id, *node; xmlDocPtr docp; @@ -897,7 +853,7 @@ PHP_METHOD(domdocument, importNode) URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-DocCrElNS Since: DOM Level 2 */ -PHP_METHOD(domdocument, createElementNS) +PHP_METHOD(DOMDocument, createElementNS) { zval *id; xmlDocPtr docp; @@ -962,7 +918,7 @@ PHP_METHOD(domdocument, createElementNS) URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-DocCrAttrNS Since: DOM Level 2 */ -PHP_METHOD(domdocument, createAttributeNS) +PHP_METHOD(DOMDocument, createAttributeNS) { zval *id; xmlDocPtr docp; @@ -1029,7 +985,7 @@ PHP_METHOD(domdocument, createAttributeNS) URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-getElBTNNS Since: DOM Level 2 */ -PHP_METHOD(domdocument, getElementsByTagNameNS) +PHP_METHOD(DOMDocument, getElementsByTagNameNS) { zval *id; xmlDocPtr docp; @@ -1057,7 +1013,7 @@ PHP_METHOD(domdocument, getElementsByTagNameNS) URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-getElBId Since: DOM Level 2 */ -PHP_METHOD(domdocument, getElementById) +PHP_METHOD(DOMDocument, getElementById) { zval *id; xmlDocPtr docp; @@ -1089,7 +1045,7 @@ PHP_METHOD(domdocument, getElementById) URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-adoptNode Since: DOM Level 3 */ -PHP_METHOD(domdocument, adoptNode) +PHP_METHOD(DOMDocument, adoptNode) { zval *nodep = NULL; @@ -1105,7 +1061,7 @@ PHP_METHOD(domdocument, adoptNode) URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-normalizeDocument Since: DOM Level 3 */ -PHP_METHOD(domdocument, normalizeDocument) +PHP_METHOD(DOMDocument, normalizeDocument) { zval *id; xmlDocPtr docp; @@ -1123,7 +1079,7 @@ PHP_METHOD(domdocument, normalizeDocument) /* }}} end dom_document_normalize_document */ /* {{{ proto DOMDocument::__construct([string version], [string encoding]); */ -PHP_METHOD(domdocument, __construct) +PHP_METHOD(DOMDocument, __construct) { xmlDoc *docp = NULL, *olddoc; dom_object *intern; @@ -1411,7 +1367,7 @@ static void dom_parse_document(INTERNAL_FUNCTION_PARAMETERS, int mode) { URL: http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS-load Since: DOM Level 3 */ -PHP_METHOD(domdocument, load) +PHP_METHOD(DOMDocument, load) { dom_parse_document(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_FILE); } @@ -1421,7 +1377,7 @@ PHP_METHOD(domdocument, load) URL: http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS-loadXML Since: DOM Level 3 */ -PHP_METHOD(domdocument, loadXML) +PHP_METHOD(DOMDocument, loadXML) { dom_parse_document(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_STRING); } @@ -1430,7 +1386,7 @@ PHP_METHOD(domdocument, loadXML) /* {{{ proto int dom_document_save(string file) Convenience method to save to file */ -PHP_METHOD(domdocument, save) +PHP_METHOD(DOMDocument, save) { zval *id; xmlDoc *docp; @@ -1476,7 +1432,7 @@ PHP_METHOD(domdocument, save) URL: http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS-saveXML Since: DOM Level 3 */ -PHP_METHOD(domdocument, saveXML) +PHP_METHOD(DOMDocument, saveXML) { zval *id, *nodep = NULL; xmlDoc *docp; @@ -1587,7 +1543,7 @@ static void php_dom_remove_xinclude_nodes(xmlNodePtr cur) /* {{{ */ /* {{{ proto int dom_document_xinclude([int options]) Substitutues xincludes in a DomDocument */ -PHP_METHOD(domdocument, xinclude) +PHP_METHOD(DOMDocument, xinclude) { zval *id; xmlDoc *docp; @@ -1634,7 +1590,7 @@ PHP_METHOD(domdocument, xinclude) /* {{{ proto bool dom_document_validate() Since: DOM extended */ -PHP_METHOD(domdocument, validate) +PHP_METHOD(DOMDocument, validate) { zval *id; xmlDoc *docp; @@ -1754,14 +1710,14 @@ static void _dom_document_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type /* }}} */ /* {{{ proto bool dom_document_schema_validate_file(string filename, int flags); */ -PHP_METHOD(domdocument, schemaValidate) +PHP_METHOD(DOMDocument, schemaValidate) { _dom_document_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_FILE); } /* }}} end dom_document_schema_validate_file */ /* {{{ proto bool dom_document_schema_validate(string source, int flags); */ -PHP_METHOD(domdocument, schemaValidateSource) +PHP_METHOD(DOMDocument, schemaValidateSource) { _dom_document_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_STRING); } @@ -1848,14 +1804,14 @@ static void _dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAMETERS, int typ /* }}} */ /* {{{ proto bool dom_document_relaxNG_validate_file(string filename); */ -PHP_METHOD(domdocument, relaxNGValidate) +PHP_METHOD(DOMDocument, relaxNGValidate) { _dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_FILE); } /* }}} end dom_document_relaxNG_validate_file */ /* {{{ proto bool dom_document_relaxNG_validate_xml(string source); */ -PHP_METHOD(domdocument, relaxNGValidateSource) +PHP_METHOD(DOMDocument, relaxNGValidateSource) { _dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_STRING); } @@ -1962,7 +1918,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ /* {{{ proto DOMNode dom_document_load_html_file(string source) Since: DOM extended */ -PHP_METHOD(domdocument, loadHTMLFile) +PHP_METHOD(DOMDocument, loadHTMLFile) { dom_load_html(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_FILE); } @@ -1971,7 +1927,7 @@ PHP_METHOD(domdocument, loadHTMLFile) /* {{{ proto DOMNode dom_document_load_html(string source) Since: DOM extended */ -PHP_METHOD(domdocument, loadHTML) +PHP_METHOD(DOMDocument, loadHTML) { dom_load_html(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_STRING); } @@ -1980,7 +1936,7 @@ PHP_METHOD(domdocument, loadHTML) /* {{{ proto int dom_document_save_html_file(string file) Convenience method to save to file as html */ -PHP_METHOD(domdocument, saveHTMLFile) +PHP_METHOD(DOMDocument, saveHTMLFile) { zval *id; xmlDoc *docp; @@ -2020,7 +1976,7 @@ PHP_METHOD(domdocument, saveHTMLFile) /* {{{ proto string dom_document_save_html() Convenience method to output as html */ -PHP_METHOD(domdocument, saveHTML) +PHP_METHOD(DOMDocument, saveHTML) { zval *id, *nodep = NULL; xmlDoc *docp; @@ -2108,7 +2064,7 @@ PHP_METHOD(domdocument, saveHTML) /* {{{ proto bool DOMDocument::registerNodeClass(string baseclass, string extendedclass) Register extended class used to create base node type */ -PHP_METHOD(domdocument, registerNodeClass) +PHP_METHOD(DOMDocument, registerNodeClass) { zval *id; xmlDoc *docp; @@ -2134,7 +2090,7 @@ PHP_METHOD(domdocument, registerNodeClass) URL: https://dom.spec.whatwg.org/#dom-parentnode-append Since: DOM Living Standard (DOM4) */ -PHP_METHOD(domdocument, append) +PHP_METHOD(DOMDocument, append) { int argc; zval *args, *id; @@ -2156,7 +2112,7 @@ PHP_METHOD(domdocument, append) URL: https://dom.spec.whatwg.org/#dom-parentnode-prepend Since: DOM Living Standard (DOM4) */ -PHP_METHOD(domdocument, prepend) +PHP_METHOD(DOMDocument, prepend) { int argc; zval *args, *id; diff --git a/ext/dom/document.stub.php b/ext/dom/document.stub.php deleted file mode 100644 index fefb46f450682..0000000000000 --- a/ext/dom/document.stub.php +++ /dev/null @@ -1,109 +0,0 @@ -ce_flags |= ZEND_ACC_FINAL; zend_declare_property_long(dom_domexception_class_entry, "code", sizeof("code")-1, 0, ZEND_ACC_PUBLIC); - INIT_CLASS_ENTRY(ce, "DOMParentNode", php_dom_parent_node_class_functions); + INIT_CLASS_ENTRY(ce, "DOMParentNode", class_DOMParentNode_methods); dom_parentnode_class_entry = zend_register_internal_interface(&ce); - INIT_CLASS_ENTRY(ce, "DOMChildNode", php_dom_child_node_class_functions); + INIT_CLASS_ENTRY(ce, "DOMChildNode", class_DOMChildNode_methods); dom_childnode_class_entry = zend_register_internal_interface(&ce); - REGISTER_DOM_CLASS(ce, "DOMImplementation", NULL, php_dom_domimplementation_class_functions, dom_domimplementation_class_entry); + REGISTER_DOM_CLASS(ce, "DOMImplementation", NULL, class_DOMImplementation_methods, dom_domimplementation_class_entry); - REGISTER_DOM_CLASS(ce, "DOMNode", NULL, php_dom_node_class_functions, dom_node_class_entry); + REGISTER_DOM_CLASS(ce, "DOMNode", NULL, class_DOMNode_methods, dom_node_class_entry); zend_hash_init(&dom_node_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1); dom_register_prop_handler(&dom_node_prop_handlers, "nodeName", sizeof("nodeName")-1, dom_node_node_name_read, NULL); @@ -625,7 +628,7 @@ PHP_MINIT_FUNCTION(dom) dom_register_prop_handler(&dom_namespace_node_prop_handlers, "parentNode", sizeof("parentNode")-1, dom_node_parent_node_read, NULL); zend_hash_add_ptr(&classes, ce.name, &dom_namespace_node_prop_handlers); - REGISTER_DOM_CLASS(ce, "DOMDocumentFragment", dom_node_class_entry, php_dom_documentfragment_class_functions, dom_documentfragment_class_entry); + REGISTER_DOM_CLASS(ce, "DOMDocumentFragment", dom_node_class_entry, class_DOMDocumentFragment_methods, dom_documentfragment_class_entry); zend_hash_init(&dom_documentfragment_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1); dom_register_prop_handler(&dom_documentfragment_prop_handlers, "firstElementChild", sizeof("firstElementChild")-1, dom_parent_node_first_element_child_read, NULL); @@ -636,7 +639,7 @@ PHP_MINIT_FUNCTION(dom) zend_hash_add_ptr(&classes, ce.name, &dom_documentfragment_prop_handlers); zend_class_implements(dom_documentfragment_class_entry, 1, dom_parentnode_class_entry); - REGISTER_DOM_CLASS(ce, "DOMDocument", dom_node_class_entry, php_dom_document_class_functions, dom_document_class_entry); + REGISTER_DOM_CLASS(ce, "DOMDocument", dom_node_class_entry, class_DOMDocument_methods, dom_document_class_entry); zend_hash_init(&dom_document_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1); dom_register_prop_handler(&dom_document_prop_handlers, "doctype", sizeof("doctype")-1, dom_document_doctype_read, NULL); dom_register_prop_handler(&dom_document_prop_handlers, "implementation", sizeof("implementation")-1, dom_document_implementation_read, NULL); @@ -666,7 +669,7 @@ PHP_MINIT_FUNCTION(dom) zend_hash_add_ptr(&classes, ce.name, &dom_document_prop_handlers); zend_class_implements(dom_document_class_entry, 1, dom_parentnode_class_entry); - INIT_CLASS_ENTRY(ce, "DOMNodeList", php_dom_nodelist_class_functions); + INIT_CLASS_ENTRY(ce, "DOMNodeList", class_DOMNodeList_methods); ce.create_object = dom_nnodemap_objects_new; dom_nodelist_class_entry = zend_register_internal_class_ex(&ce, NULL); dom_nodelist_class_entry->get_iterator = php_dom_get_iterator; @@ -676,7 +679,7 @@ PHP_MINIT_FUNCTION(dom) dom_register_prop_handler(&dom_nodelist_prop_handlers, "length", sizeof("length")-1, dom_nodelist_length_read, NULL); zend_hash_add_ptr(&classes, ce.name, &dom_nodelist_prop_handlers); - INIT_CLASS_ENTRY(ce, "DOMNamedNodeMap", php_dom_namednodemap_class_functions); + INIT_CLASS_ENTRY(ce, "DOMNamedNodeMap", class_DOMNamedNodeMap_methods); ce.create_object = dom_nnodemap_objects_new; dom_namednodemap_class_entry = zend_register_internal_class_ex(&ce, NULL); dom_namednodemap_class_entry->get_iterator = php_dom_get_iterator; @@ -686,7 +689,7 @@ PHP_MINIT_FUNCTION(dom) dom_register_prop_handler(&dom_namednodemap_prop_handlers, "length", sizeof("length")-1, dom_namednodemap_length_read, NULL); zend_hash_add_ptr(&classes, ce.name, &dom_namednodemap_prop_handlers); - REGISTER_DOM_CLASS(ce, "DOMCharacterData", dom_node_class_entry, php_dom_characterdata_class_functions, dom_characterdata_class_entry); + REGISTER_DOM_CLASS(ce, "DOMCharacterData", dom_node_class_entry, class_DOMCharacterData_methods, dom_characterdata_class_entry); zend_hash_init(&dom_characterdata_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1); dom_register_prop_handler(&dom_characterdata_prop_handlers, "data", sizeof("data")-1, dom_characterdata_data_read, dom_characterdata_data_write); @@ -698,7 +701,7 @@ PHP_MINIT_FUNCTION(dom) zend_class_implements(dom_characterdata_class_entry, 1, dom_childnode_class_entry); - REGISTER_DOM_CLASS(ce, "DOMAttr", dom_node_class_entry, php_dom_attr_class_functions, dom_attr_class_entry); + REGISTER_DOM_CLASS(ce, "DOMAttr", dom_node_class_entry, class_DOMAttr_methods, dom_attr_class_entry); zend_hash_init(&dom_attr_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1); dom_register_prop_handler(&dom_attr_prop_handlers, "name", sizeof("name")-1, dom_attr_name_read, NULL); @@ -709,7 +712,7 @@ PHP_MINIT_FUNCTION(dom) zend_hash_merge(&dom_attr_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0); zend_hash_add_ptr(&classes, ce.name, &dom_attr_prop_handlers); - REGISTER_DOM_CLASS(ce, "DOMElement", dom_node_class_entry, php_dom_element_class_functions, dom_element_class_entry); + REGISTER_DOM_CLASS(ce, "DOMElement", dom_node_class_entry, class_DOMElement_methods, dom_element_class_entry); zend_hash_init(&dom_element_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1); dom_register_prop_handler(&dom_element_prop_handlers, "tagName", sizeof("tagName")-1, dom_element_tag_name_read, NULL); @@ -724,17 +727,17 @@ PHP_MINIT_FUNCTION(dom) zend_class_implements(dom_element_class_entry, 2, dom_parentnode_class_entry, dom_childnode_class_entry); - REGISTER_DOM_CLASS(ce, "DOMText", dom_characterdata_class_entry, php_dom_text_class_functions, dom_text_class_entry); + REGISTER_DOM_CLASS(ce, "DOMText", dom_characterdata_class_entry, class_DOMText_methods, dom_text_class_entry); zend_hash_init(&dom_text_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1); dom_register_prop_handler(&dom_text_prop_handlers, "wholeText", sizeof("wholeText")-1, dom_text_whole_text_read, NULL); zend_hash_merge(&dom_text_prop_handlers, &dom_characterdata_prop_handlers, dom_copy_prop_handler, 0); zend_hash_add_ptr(&classes, ce.name, &dom_text_prop_handlers); - REGISTER_DOM_CLASS(ce, "DOMComment", dom_characterdata_class_entry, php_dom_comment_class_functions, dom_comment_class_entry); + REGISTER_DOM_CLASS(ce, "DOMComment", dom_characterdata_class_entry, class_DOMComment_methods, dom_comment_class_entry); zend_hash_add_ptr(&classes, ce.name, &dom_characterdata_prop_handlers); - REGISTER_DOM_CLASS(ce, "DOMCdataSection", dom_text_class_entry, php_dom_cdatasection_class_functions, dom_cdatasection_class_entry); + REGISTER_DOM_CLASS(ce, "DOMCdataSection", dom_text_class_entry, class_DOMCdataSection_methods, dom_cdatasection_class_entry); zend_hash_add_ptr(&classes, ce.name, &dom_text_prop_handlers); REGISTER_DOM_CLASS(ce, "DOMDocumentType", dom_node_class_entry, class_DOMDocumentType_methods, dom_documenttype_class_entry); @@ -749,7 +752,7 @@ PHP_MINIT_FUNCTION(dom) zend_hash_merge(&dom_documenttype_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0); zend_hash_add_ptr(&classes, ce.name, &dom_documenttype_prop_handlers); - REGISTER_DOM_CLASS(ce, "DOMNotation", dom_node_class_entry, php_dom_notation_class_functions, dom_notation_class_entry); + REGISTER_DOM_CLASS(ce, "DOMNotation", dom_node_class_entry, class_DOMNotation_methods, dom_notation_class_entry); zend_hash_init(&dom_notation_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1); dom_register_prop_handler(&dom_notation_prop_handlers, "publicId", sizeof("publicId")-1, dom_notation_public_id_read, NULL); @@ -757,7 +760,7 @@ PHP_MINIT_FUNCTION(dom) zend_hash_merge(&dom_notation_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0); zend_hash_add_ptr(&classes, ce.name, &dom_notation_prop_handlers); - REGISTER_DOM_CLASS(ce, "DOMEntity", dom_node_class_entry, php_dom_entity_class_functions, dom_entity_class_entry); + REGISTER_DOM_CLASS(ce, "DOMEntity", dom_node_class_entry, class_DOMEntity_methods, dom_entity_class_entry); zend_hash_init(&dom_entity_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1); dom_register_prop_handler(&dom_entity_prop_handlers, "publicId", sizeof("publicId")-1, dom_entity_public_id_read, NULL); @@ -769,10 +772,10 @@ PHP_MINIT_FUNCTION(dom) zend_hash_merge(&dom_entity_prop_handlers, &dom_node_prop_handlers, dom_copy_prop_handler, 0); zend_hash_add_ptr(&classes, ce.name, &dom_entity_prop_handlers); - REGISTER_DOM_CLASS(ce, "DOMEntityReference", dom_node_class_entry, php_dom_entityreference_class_functions, dom_entityreference_class_entry); + REGISTER_DOM_CLASS(ce, "DOMEntityReference", dom_node_class_entry, class_DOMEntityReference_methods, dom_entityreference_class_entry); zend_hash_add_ptr(&classes, ce.name, &dom_node_prop_handlers); - REGISTER_DOM_CLASS(ce, "DOMProcessingInstruction", dom_node_class_entry, php_dom_processinginstruction_class_functions, dom_processinginstruction_class_entry); + REGISTER_DOM_CLASS(ce, "DOMProcessingInstruction", dom_node_class_entry, class_DOMProcessingInstruction_methods, dom_processinginstruction_class_entry); zend_hash_init(&dom_processinginstruction_prop_handlers, 0, NULL, dom_dtor_prop_handler, 1); dom_register_prop_handler(&dom_processinginstruction_prop_handlers, "target", sizeof("target")-1, dom_processinginstruction_target_read, NULL); @@ -785,7 +788,7 @@ PHP_MINIT_FUNCTION(dom) dom_xpath_object_handlers.offset = XtOffsetOf(dom_xpath_object, dom) + XtOffsetOf(dom_object, std); dom_xpath_object_handlers.free_obj = dom_xpath_objects_free_storage; - INIT_CLASS_ENTRY(ce, "DOMXPath", php_dom_xpath_class_functions); + INIT_CLASS_ENTRY(ce, "DOMXPath", class_DOMXPath_methods); ce.create_object = dom_xpath_objects_new; dom_xpath_class_entry = zend_register_internal_class_ex(&ce, NULL); diff --git a/ext/dom/php_dom.stub.php b/ext/dom/php_dom.stub.php new file mode 100644 index 0000000000000..952bb65b33fb1 --- /dev/null +++ b/ext/dom/php_dom.stub.php @@ -0,0 +1,411 @@ + Date: Sun, 12 Apr 2020 17:40:32 +0200 Subject: [PATCH 2/2] Address code review comments --- ext/dom/{dom_fe.h => domexception.h} | 6 +-- ext/dom/php_dom.c | 3 -- ext/dom/php_dom.h | 2 +- ext/dom/php_dom.stub.php | 22 +++++++++ ext/dom/php_dom_arginfo.h | 67 ++++++++++++++++++++++++++ ext/dom/xpath.stub.php | 25 ---------- ext/dom/xpath_arginfo.h | 70 ---------------------------- 7 files changed, 93 insertions(+), 102 deletions(-) rename ext/dom/{dom_fe.h => domexception.h} (96%) delete mode 100644 ext/dom/xpath.stub.php delete mode 100644 ext/dom/xpath_arginfo.h diff --git a/ext/dom/dom_fe.h b/ext/dom/domexception.h similarity index 96% rename from ext/dom/dom_fe.h rename to ext/dom/domexception.h index c350045565db2..d067bfc611dcf 100644 --- a/ext/dom/dom_fe.h +++ b/ext/dom/domexception.h @@ -15,8 +15,8 @@ +----------------------------------------------------------------------+ */ -#ifndef DOM_FE_H -#define DOM_FE_H +#ifndef DOM_EXCEPTION_H +#define DOM_EXCEPTION_H /* domexception errors */ typedef enum { @@ -46,4 +46,4 @@ typedef enum { VALIDATION_ERR = 16 } dom_exception_code; -#endif /* DOM_FE_H */ +#endif /* DOM_EXCEPTION_H */ diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index 77887badebe1e..c7b2103a0f5cb 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -27,9 +27,6 @@ #include "php_dom_arginfo.h" #include "dom_properties.h" #include "zend_interfaces.h" -#if defined(LIBXML_XPATH_ENABLED) -#include "xpath_arginfo.h" -#endif #include "ext/standard/info.h" #define PHP_XPATH 1 diff --git a/ext/dom/php_dom.h b/ext/dom/php_dom.h index e1058e849b74c..ec01196af7c8d 100644 --- a/ext/dom/php_dom.h +++ b/ext/dom/php_dom.h @@ -93,7 +93,7 @@ typedef struct { HashPosition pos; } php_dom_iterator; -#include "dom_fe.h" +#include "domexception.h" dom_object *dom_object_get_data(xmlNodePtr obj); dom_doc_propsptr dom_get_doc_props(php_libxml_ref_obj *document); diff --git a/ext/dom/php_dom.stub.php b/ext/dom/php_dom.stub.php index 952bb65b33fb1..8f1b3754714db 100644 --- a/ext/dom/php_dom.stub.php +++ b/ext/dom/php_dom.stub.php @@ -408,4 +408,26 @@ class DOMProcessingInstruction public function __construct(string $name, string $value = "") {} } +#if defined(LIBXML_XPATH_ENABLED) +class DOMXPath +{ + public function __construct(DOMDocument $doc, bool $registerNodeNS = true) {} + + /** @return mixed */ + public function evaluate(string $expr, ?DOMNode $context = null, bool $registerNodeNS = true) {} + + /** @return mixed */ + public function query(string $expr, ?DOMNode $context = null, bool $registerNodeNS = true) {} + + /** @return bool */ + public function registerNamespace(string $prefix, string $namespaceURI) {} + + /** + * @param string|array $restrict + * @return bool|null + */ + public function registerPhpFunctions($restrict = null) {} +} +#endif + function dom_import_simplexml(object $node): ?DOMElement {} diff --git a/ext/dom/php_dom_arginfo.h b/ext/dom/php_dom_arginfo.h index 3db8d36c6a4ad..e989301311531 100644 --- a/ext/dom/php_dom_arginfo.h +++ b/ext/dom/php_dom_arginfo.h @@ -407,6 +407,38 @@ ZEND_END_ARG_INFO() #define arginfo_class_DOMProcessingInstruction___construct arginfo_class_DOMAttr___construct +#if defined(LIBXML_XPATH_ENABLED) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMXPath___construct, 0, 0, 1) + ZEND_ARG_OBJ_INFO(0, doc, DOMDocument, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, registerNodeNS, _IS_BOOL, 0, "true") +ZEND_END_ARG_INFO() +#endif + +#if defined(LIBXML_XPATH_ENABLED) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMXPath_evaluate, 0, 0, 1) + ZEND_ARG_TYPE_INFO(0, expr, IS_STRING, 0) + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, context, DOMNode, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, registerNodeNS, _IS_BOOL, 0, "true") +ZEND_END_ARG_INFO() +#endif + +#if defined(LIBXML_XPATH_ENABLED) +#define arginfo_class_DOMXPath_query arginfo_class_DOMXPath_evaluate +#endif + +#if defined(LIBXML_XPATH_ENABLED) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMXPath_registerNamespace, 0, 0, 2) + ZEND_ARG_TYPE_INFO(0, prefix, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, namespaceURI, IS_STRING, 0) +ZEND_END_ARG_INFO() +#endif + +#if defined(LIBXML_XPATH_ENABLED) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOMXPath_registerPhpFunctions, 0, 0, 0) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, restrict, "null") +ZEND_END_ARG_INFO() +#endif + ZEND_FUNCTION(dom_import_simplexml); ZEND_METHOD(DOMCdataSection, __construct); @@ -533,6 +565,21 @@ ZEND_METHOD(DOMNamedNodeMap, item); ZEND_METHOD(DOMNamedNodeMap, count); ZEND_METHOD(DOMEntityReference, __construct); ZEND_METHOD(DOMProcessingInstruction, __construct); +#if defined(LIBXML_XPATH_ENABLED) +ZEND_METHOD(DOMXPath, __construct); +#endif +#if defined(LIBXML_XPATH_ENABLED) +ZEND_METHOD(DOMXPath, evaluate); +#endif +#if defined(LIBXML_XPATH_ENABLED) +ZEND_METHOD(DOMXPath, query); +#endif +#if defined(LIBXML_XPATH_ENABLED) +ZEND_METHOD(DOMXPath, registerNamespace); +#endif +#if defined(LIBXML_XPATH_ENABLED) +ZEND_METHOD(DOMXPath, registerPhpFunctions); +#endif static const zend_function_entry ext_functions[] = { @@ -770,3 +817,23 @@ static const zend_function_entry class_DOMProcessingInstruction_methods[] = { ZEND_ME(DOMProcessingInstruction, __construct, arginfo_class_DOMProcessingInstruction___construct, ZEND_ACC_PUBLIC) ZEND_FE_END }; + + +static const zend_function_entry class_DOMXPath_methods[] = { +#if defined(LIBXML_XPATH_ENABLED) + ZEND_ME(DOMXPath, __construct, arginfo_class_DOMXPath___construct, ZEND_ACC_PUBLIC) +#endif +#if defined(LIBXML_XPATH_ENABLED) + ZEND_ME(DOMXPath, evaluate, arginfo_class_DOMXPath_evaluate, ZEND_ACC_PUBLIC) +#endif +#if defined(LIBXML_XPATH_ENABLED) + ZEND_ME(DOMXPath, query, arginfo_class_DOMXPath_query, ZEND_ACC_PUBLIC) +#endif +#if defined(LIBXML_XPATH_ENABLED) + ZEND_ME(DOMXPath, registerNamespace, arginfo_class_DOMXPath_registerNamespace, ZEND_ACC_PUBLIC) +#endif +#if defined(LIBXML_XPATH_ENABLED) + ZEND_ME(DOMXPath, registerPhpFunctions, arginfo_class_DOMXPath_registerPhpFunctions, ZEND_ACC_PUBLIC) +#endif + ZEND_FE_END +}; diff --git a/ext/dom/xpath.stub.php b/ext/dom/xpath.stub.php deleted file mode 100644 index 72883e58a3714..0000000000000 --- a/ext/dom/xpath.stub.php +++ /dev/null @@ -1,25 +0,0 @@ -