diff options
Diffstat (limited to 'ext/dom')
-rw-r--r-- | ext/dom/attr.c | 8 | ||||
-rw-r--r-- | ext/dom/cdatasection.c | 8 | ||||
-rw-r--r-- | ext/dom/comment.c | 8 | ||||
-rw-r--r-- | ext/dom/document.c | 8 | ||||
-rw-r--r-- | ext/dom/documentfragment.c | 8 | ||||
-rw-r--r-- | ext/dom/element.c | 8 | ||||
-rw-r--r-- | ext/dom/entityreference.c | 9 | ||||
-rw-r--r-- | ext/dom/processinginstruction.c | 9 | ||||
-rw-r--r-- | ext/dom/tests/DOMAttr_construct_error_001.phpt | 12 | ||||
-rw-r--r-- | ext/dom/tests/DOMCDATASection_construct_error_001.phpt | 10 | ||||
-rw-r--r-- | ext/dom/tests/DOMComment_construct_error_001.phpt | 12 | ||||
-rw-r--r-- | ext/dom/tests/DOMDocumentFragment_construct_error_001.phpt | 12 | ||||
-rw-r--r-- | ext/dom/text.c | 8 | ||||
-rw-r--r-- | ext/dom/xpath.c | 8 |
14 files changed, 41 insertions, 87 deletions
diff --git a/ext/dom/attr.c b/ext/dom/attr.c index 05bfc54232..1ecf6610b7 100644 --- a/ext/dom/attr.c +++ b/ext/dom/attr.c @@ -55,21 +55,17 @@ const zend_function_entry php_dom_attr_class_functions[] = { /* {{{ proto void DOMAttr::__construct(string name, [string value]); */ PHP_METHOD(domattr, __construct) { - zval *id; + zval *id = getThis(); xmlAttrPtr nodep = NULL; xmlNodePtr oldnode = NULL; dom_object *intern; char *name, *value = NULL; size_t name_len, value_len, name_valid; - zend_error_handling error_handling; - zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling); - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os|s", &id, dom_attr_class_entry, &name, &name_len, &value, &value_len) == FAILURE) { - zend_restore_error_handling(&error_handling); + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|s", &name, &name_len, &value, &value_len) == FAILURE) { return; } - zend_restore_error_handling(&error_handling); intern = Z_DOMOBJ_P(id); name_valid = xmlValidateName((xmlChar *) name, 0); diff --git a/ext/dom/cdatasection.c b/ext/dom/cdatasection.c index 5bdc5ba11b..e6b7e33bce 100644 --- a/ext/dom/cdatasection.c +++ b/ext/dom/cdatasection.c @@ -50,20 +50,16 @@ const zend_function_entry php_dom_cdatasection_class_functions[] = { PHP_METHOD(domcdatasection, __construct) { - zval *id; + zval *id = getThis(); xmlNodePtr nodep = NULL, oldnode = NULL; dom_object *intern; char *value = NULL; size_t value_len; - zend_error_handling error_handling; - zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling); - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &id, dom_cdatasection_class_entry, &value, &value_len) == FAILURE) { - zend_restore_error_handling(&error_handling); + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &value, &value_len) == FAILURE) { return; } - zend_restore_error_handling(&error_handling); nodep = xmlNewCDataBlock(NULL, (xmlChar *) value, value_len); if (!nodep) { diff --git a/ext/dom/comment.c b/ext/dom/comment.c index 01ed295e47..4dc016ae3b 100644 --- a/ext/dom/comment.c +++ b/ext/dom/comment.c @@ -50,20 +50,16 @@ const zend_function_entry php_dom_comment_class_functions[] = { PHP_METHOD(domcomment, __construct) { - zval *id; + zval *id = getThis(); xmlNodePtr nodep = NULL, oldnode = NULL; dom_object *intern; char *value = NULL; size_t value_len; - zend_error_handling error_handling; - zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling); - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|s", &id, dom_comment_class_entry, &value, &value_len) == FAILURE) { - zend_restore_error_handling(&error_handling); + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "|s", &value, &value_len) == FAILURE) { return; } - zend_restore_error_handling(&error_handling); nodep = xmlNewComment((xmlChar *) value); if (!nodep) { diff --git a/ext/dom/document.c b/ext/dom/document.c index bcd81c0d9b..92d5fb5d33 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -1253,21 +1253,17 @@ PHP_FUNCTION(dom_document_rename_node) PHP_METHOD(domdocument, __construct) { - zval *id; + zval *id = getThis(); xmlDoc *docp = NULL, *olddoc; dom_object *intern; char *encoding, *version = NULL; size_t encoding_len = 0, version_len = 0; int refcount; - zend_error_handling error_handling; - zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling); - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|ss", &id, dom_document_class_entry, &version, &version_len, &encoding, &encoding_len) == FAILURE) { - zend_restore_error_handling(&error_handling); + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "|ss", &version, &version_len, &encoding, &encoding_len) == FAILURE) { return; } - zend_restore_error_handling(&error_handling); docp = xmlNewDoc((xmlChar *) version); if (!docp) { diff --git a/ext/dom/documentfragment.c b/ext/dom/documentfragment.c index 31d3065f50..9cf0fd5423 100644 --- a/ext/dom/documentfragment.c +++ b/ext/dom/documentfragment.c @@ -53,18 +53,14 @@ const zend_function_entry php_dom_documentfragment_class_functions[] = { PHP_METHOD(domdocumentfragment, __construct) { - zval *id; + zval *id = getThis(); xmlNodePtr nodep = NULL, oldnode = NULL; dom_object *intern; - zend_error_handling error_handling; - zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling); - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &id, dom_documentfragment_class_entry) == FAILURE) { - zend_restore_error_handling(&error_handling); + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "") == FAILURE) { return; } - zend_restore_error_handling(&error_handling); nodep = xmlNewDocFragment(NULL); if (!nodep) { diff --git a/ext/dom/element.c b/ext/dom/element.c index b05237ff39..4af6c9accf 100644 --- a/ext/dom/element.c +++ b/ext/dom/element.c @@ -154,7 +154,7 @@ const zend_function_entry php_dom_element_class_functions[] = { /* {{{ */ PHP_METHOD(domelement, __construct) { - zval *id; + zval *id = getThis(); xmlNodePtr nodep = NULL, oldnode = NULL; dom_object *intern; char *name, *value = NULL, *uri = NULL; @@ -163,14 +163,10 @@ PHP_METHOD(domelement, __construct) size_t name_len, value_len = 0, uri_len = 0; int name_valid; xmlNsPtr nsptr = NULL; - zend_error_handling error_handling; - zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling); - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os|s!s", &id, dom_element_class_entry, &name, &name_len, &value, &value_len, &uri, &uri_len) == FAILURE) { - zend_restore_error_handling(&error_handling); + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|s!s", &name, &name_len, &value, &value_len, &uri, &uri_len) == FAILURE) { return; } - zend_restore_error_handling(&error_handling); name_valid = xmlValidateName((xmlChar *) name, 0); if (name_valid != 0) { diff --git a/ext/dom/entityreference.c b/ext/dom/entityreference.c index 20eff5c72d..a3e3eaea0f 100644 --- a/ext/dom/entityreference.c +++ b/ext/dom/entityreference.c @@ -48,22 +48,17 @@ const zend_function_entry php_dom_entityreference_class_functions[] = { /* {{{ proto void DOMEntityReference::__construct(string name); */ PHP_METHOD(domentityreference, __construct) { - zval *id; + zval *id = getThis(); xmlNode *node; xmlNodePtr oldnode = NULL; dom_object *intern; char *name; size_t name_len, name_valid; - zend_error_handling error_handling; - zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling); - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &id, dom_entityreference_class_entry, &name, &name_len) == FAILURE) { - zend_restore_error_handling(&error_handling); + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &name, &name_len) == FAILURE) { return; } - zend_restore_error_handling(&error_handling); - name_valid = xmlValidateName((xmlChar *) name, 0); if (name_valid != 0) { php_dom_throw_error(INVALID_CHARACTER_ERR, 1); diff --git a/ext/dom/processinginstruction.c b/ext/dom/processinginstruction.c index 7b18096fab..38b934d011 100644 --- a/ext/dom/processinginstruction.c +++ b/ext/dom/processinginstruction.c @@ -50,22 +50,17 @@ const zend_function_entry php_dom_processinginstruction_class_functions[] = { /* {{{ proto void DOMProcessingInstruction::__construct(string name, [string value]); */ PHP_METHOD(domprocessinginstruction, __construct) { - zval *id; + zval *id = getThis(); xmlNodePtr nodep = NULL, oldnode = NULL; dom_object *intern; char *name, *value = NULL; size_t name_len, value_len; int name_valid; - zend_error_handling error_handling; - zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling); - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os|s", &id, dom_processinginstruction_class_entry, &name, &name_len, &value, &value_len) == FAILURE) { - zend_restore_error_handling(&error_handling); + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|s", &name, &name_len, &value, &value_len) == FAILURE) { return; } - zend_restore_error_handling(&error_handling); - name_valid = xmlValidateName((xmlChar *) name, 0); if (name_valid != 0) { php_dom_throw_error(INVALID_CHARACTER_ERR, 1); diff --git a/ext/dom/tests/DOMAttr_construct_error_001.phpt b/ext/dom/tests/DOMAttr_construct_error_001.phpt index 08734ca473..53780c3321 100644 --- a/ext/dom/tests/DOMAttr_construct_error_001.phpt +++ b/ext/dom/tests/DOMAttr_construct_error_001.phpt @@ -7,11 +7,11 @@ Josh Sweeney <jsweeney@alt-invest.net> <?php require_once('skipif.inc'); ?> --FILE-- <?php -$attr = new DOMAttr(); +try { + $attr = new DOMAttr(); +} catch (TypeException $e) { + echo $e->getMessage(), "\n"; +} ?> --EXPECTF-- -Fatal error: Uncaught exception 'DOMException' with message 'DOMAttr::__construct() expects at least 1 parameter, 0 given' in %s:%d -Stack trace: -#0 %s(%d): DOMAttr->__construct() -#1 {main} - thrown in %s on line %d +DOMAttr::__construct() expects at least 1 parameter, 0 given diff --git a/ext/dom/tests/DOMCDATASection_construct_error_001.phpt b/ext/dom/tests/DOMCDATASection_construct_error_001.phpt index 4db2130ba8..2be1e5204f 100644 --- a/ext/dom/tests/DOMCDATASection_construct_error_001.phpt +++ b/ext/dom/tests/DOMCDATASection_construct_error_001.phpt @@ -7,15 +7,11 @@ Nic Rosental nicrosental@gmail.com <?php require_once('skipif.inc'); ?> --FILE-- <?php - try - { + try { $section = new DOMCDataSection(); - - } - catch (Exception $e) - { + } catch (TypeException $e) { echo $e->getMessage(); } ?> --EXPECT-- -DOMCdataSection::__construct() expects exactly 1 parameter, 0 given
\ No newline at end of file +DOMCdataSection::__construct() expects exactly 1 parameter, 0 given diff --git a/ext/dom/tests/DOMComment_construct_error_001.phpt b/ext/dom/tests/DOMComment_construct_error_001.phpt index 89142fe6f6..e2f0b19a72 100644 --- a/ext/dom/tests/DOMComment_construct_error_001.phpt +++ b/ext/dom/tests/DOMComment_construct_error_001.phpt @@ -7,11 +7,11 @@ Eric Lee Stewart <ericleestewart@gmail.com> <?php require_once('skipif.inc'); ?> --FILE-- <?php -$comment = new DOMComment("comment1", "comment2"); +try { + $comment = new DOMComment("comment1", "comment2"); +} catch (TypeException $e) { + echo $e->getMessage(), "\n"; +} ?> --EXPECTF-- -Fatal error: Uncaught exception 'DOMException' with message 'DOMComment::__construct() expects at most 1 parameter, 2 given' in %s:%d -Stack trace: -#0 %s(%d): DOMComment->__construct('comment1', 'comment2') -#1 {main} - thrown in %s on line %d
\ No newline at end of file +DOMComment::__construct() expects at most 1 parameter, 2 given diff --git a/ext/dom/tests/DOMDocumentFragment_construct_error_001.phpt b/ext/dom/tests/DOMDocumentFragment_construct_error_001.phpt index 91173c4b7c..d9376a3251 100644 --- a/ext/dom/tests/DOMDocumentFragment_construct_error_001.phpt +++ b/ext/dom/tests/DOMDocumentFragment_construct_error_001.phpt @@ -7,11 +7,11 @@ Eric Lee Stewart <ericleestewart@gmail.com> <?php require_once('skipif.inc'); ?> --FILE-- <?php -$fragment = new DOMDocumentFragment("root"); +try { + $fragment = new DOMDocumentFragment("root"); +} catch (TypeException $e) { + echo $e->getMessage(), "\n"; +} ?> --EXPECTF-- -Fatal error: Uncaught exception 'DOMException' with message 'DOMDocumentFragment::__construct() expects exactly 0 parameters, 1 given' in %s:%d -Stack trace: -#0 %s(%d): DOMDocumentFragment->__construct('root') -#1 {main} - thrown in %s on line %d
\ No newline at end of file +DOMDocumentFragment::__construct() expects exactly 0 parameters, 1 given diff --git a/ext/dom/text.c b/ext/dom/text.c index 50e8f89f54..f857163ce1 100644 --- a/ext/dom/text.c +++ b/ext/dom/text.c @@ -65,20 +65,16 @@ const zend_function_entry php_dom_text_class_functions[] = { PHP_METHOD(domtext, __construct) { - zval *id; + zval *id = getThis(); xmlNodePtr nodep = NULL, oldnode = NULL; dom_object *intern; char *value = NULL; size_t value_len; - zend_error_handling error_handling; - zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling); - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|s", &id, dom_text_class_entry, &value, &value_len) == FAILURE) { - zend_restore_error_handling(&error_handling); + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "|s", &value, &value_len) == FAILURE) { return; } - zend_restore_error_handling(&error_handling); nodep = xmlNewText((xmlChar *) value); if (!nodep) { diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c index 1fb6574695..58155c1aa9 100644 --- a/ext/dom/xpath.c +++ b/ext/dom/xpath.c @@ -253,20 +253,16 @@ static void dom_xpath_ext_function_object_php(xmlXPathParserContextPtr ctxt, int /* {{{ proto void DOMXPath::__construct(DOMDocument doc) U */ PHP_METHOD(domxpath, __construct) { - zval *id, *doc; + zval *id = getThis(), *doc; xmlDocPtr docp = NULL; dom_object *docobj; dom_xpath_object *intern; xmlXPathContextPtr ctx, oldctx; - zend_error_handling error_handling; - zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling); - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &id, dom_xpath_class_entry, &doc, dom_document_class_entry) == FAILURE) { - zend_restore_error_handling(&error_handling); + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "O", &doc, dom_document_class_entry) == FAILURE) { return; } - zend_restore_error_handling(&error_handling); DOM_GET_OBJ(docp, doc, xmlDocPtr, docobj); ctx = xmlXPathNewContext(docp); |