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.
This commit is contained in:
Nikita Popov 2015-04-02 18:52:32 +02:00
parent 884b0365db
commit 122d759618
88 changed files with 426 additions and 642 deletions

View file

@ -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);