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/phar/phar_object.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/phar/phar_object.c')
-rw-r--r-- | ext/phar/phar_object.c | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 861f94e763..8ef5b0f7ed 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1130,26 +1130,17 @@ PHP_METHOD(Phar, __construct) phar_archive_object *phar_obj; phar_archive_data *phar_data; zval *zobj = getThis(), arg1, arg2; - zend_error_handling zeh; - int rv; phar_obj = (phar_archive_object*)((char*)Z_OBJ_P(zobj) - Z_OBJ_P(zobj)->handlers->offset); is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - zend_replace_error_handling(EH_THROW, phar_ce_PharException, &zeh TSRMLS_CC); - rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format); - zend_restore_error_handling(&zeh TSRMLS_CC); - if (rv == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - zend_replace_error_handling(EH_THROW, phar_ce_PharException, &zeh TSRMLS_CC); - rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len); - zend_restore_error_handling(&zeh TSRMLS_CC); - if (rv == FAILURE) { - /* Exception was thrown already */ + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -4359,14 +4350,8 @@ PHP_METHOD(PharFileInfo, __construct) phar_entry_info *entry_info; phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - zend_error_handling zeh; - int rv; - zend_replace_error_handling(EH_THROW, phar_ce_PharException, &zeh TSRMLS_CC); - rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len); - zend_restore_error_handling(&zeh TSRMLS_CC); - - if (rv == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { return; } |