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/spl/spl_array.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'ext/spl/spl_array.c') 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); - } /* }}} */ -- cgit v1.2.1