From 122d759618a42bff105971b923fbbb5be02e34b9 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 2 Apr 2015 18:52:32 +0200 Subject: Always throw TypeException on throwing zpp failures Introduces a ZEND_PARSE_PARAMS_THROW flag for zpp, which forces to report FAILURE errors using a TypeException instead of a Warning, like it would happen in strict mode. Adds a zend_parse_parameters_throw() convenience function, which invokes zpp with this flag. Converts all cases I could identify, where we currently have throwing zpp usage in constructors and replaces them with this API. Error handling is still replaced to EH_THROW in some cases to handle other, domain-specific errors in constructors. --- ext/dom/document.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'ext/dom/document.c') 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) { -- cgit v1.2.1