diff options
author | Nikita Popov <nikic@php.net> | 2015-04-02 18:52:32 +0200 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2015-04-06 11:27:34 +0200 |
commit | 122d759618a42bff105971b923fbbb5be02e34b9 (patch) | |
tree | fd4487414ffa3f120c77b19b9eb7dc409659c57e /ext/spl/spl_array.c | |
parent | 884b0365dbe718f667d048dbc3d1cd9d9f12ab84 (diff) | |
download | php-git-122d759618a42bff105971b923fbbb5be02e34b9.tar.gz |
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.
Diffstat (limited to 'ext/spl/spl_array.c')
-rw-r--r-- | ext/spl/spl_array.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 5e62bad6e4..a919d4bb5e 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -1220,21 +1220,17 @@ SPL_METHOD(Array, __construct) zval *array; zend_long ar_flags = 0; zend_class_entry *ce_get_iterator = spl_ce_Iterator; - zend_error_handling error_handling; if (ZEND_NUM_ARGS() == 0) { return; /* nothing to do */ } - zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling); - - intern = Z_SPLARRAY_P(object); - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|lC", &array, &ar_flags, &ce_get_iterator) == FAILURE) { - zend_restore_error_handling(&error_handling); + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "z|lC", &array, &ar_flags, &ce_get_iterator) == FAILURE) { return; } + intern = Z_SPLARRAY_P(object); + if (ZEND_NUM_ARGS() > 2) { intern->ce_get_iterator = ce_get_iterator; } @@ -1242,9 +1238,6 @@ SPL_METHOD(Array, __construct) ar_flags &= ~SPL_ARRAY_INT_MASK; spl_array_set_array(object, intern, array, ar_flags, ZEND_NUM_ARGS() == 1); - - zend_restore_error_handling(&error_handling); - } /* }}} */ |