summaryrefslogtreecommitdiff
path: root/ext/intl/resourcebundle/resourcebundle_class.c
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2015-04-02 18:52:32 +0200
committerNikita Popov <nikic@php.net>2015-04-06 11:27:34 +0200
commit122d759618a42bff105971b923fbbb5be02e34b9 (patch)
treefd4487414ffa3f120c77b19b9eb7dc409659c57e /ext/intl/resourcebundle/resourcebundle_class.c
parent884b0365dbe718f667d048dbc3d1cd9d9f12ab84 (diff)
downloadphp-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/intl/resourcebundle/resourcebundle_class.c')
-rw-r--r--ext/intl/resourcebundle/resourcebundle_class.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c
index d8d1aa0d9c..a42556f746 100644
--- a/ext/intl/resourcebundle/resourcebundle_class.c
+++ b/ext/intl/resourcebundle/resourcebundle_class.c
@@ -75,20 +75,21 @@ static zend_object *ResourceBundle_object_create( zend_class_entry *ce )
/* }}} */
/* {{{ ResourceBundle_ctor */
-static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS)
+static void resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_constructor)
{
const char *bundlename;
size_t bundlename_len = 0;
const char *locale;
size_t locale_len = 0;
zend_bool fallback = 1;
+ int zpp_flags = is_constructor ? ZEND_PARSE_PARAMS_THROW : 0;
zval *object = return_value;
ResourceBundle_object *rb = Z_INTL_RESOURCEBUNDLE_P( object );
intl_error_reset( NULL );
- if( zend_parse_parameters( ZEND_NUM_ARGS(), "s!s!|b",
+ if( zend_parse_parameters_ex( zpp_flags, ZEND_NUM_ARGS(), "s!s!|b",
&locale, &locale_len, &bundlename, &bundlename_len, &fallback ) == FAILURE )
{
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
@@ -144,7 +145,7 @@ PHP_METHOD( ResourceBundle, __construct )
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
return_value = getThis();
- resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
if (!EG(exception)) {
zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0);
@@ -160,7 +161,7 @@ proto ResourceBundle resourcebundle_create( string $locale [, string $bundlename
PHP_FUNCTION( resourcebundle_create )
{
object_init_ex( return_value, ResourceBundle_ce_ptr );
- resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
RETURN_NULL();
}