summaryrefslogtreecommitdiff
path: root/ext/intl/formatter/formatter_parse.c
diff options
context:
space:
mode:
authorMáté Kocsis <kocsismate@woohoolabs.com>2020-08-10 23:23:35 +0200
committerMáté Kocsis <kocsismate@woohoolabs.com>2020-09-07 19:46:55 +0200
commitfd0b39905c299c24941644f22947553e0e009dbf (patch)
tree56309b685aa0d7d74858bb2addcaf1c064237fc4 /ext/intl/formatter/formatter_parse.c
parent174dadf6b476a11c72646294700e62fe911366cb (diff)
downloadphp-git-fd0b39905c299c24941644f22947553e0e009dbf.tar.gz
Promote warnings to exceptions in ext/intl
Closes GH-5972
Diffstat (limited to 'ext/intl/formatter/formatter_parse.c')
-rw-r--r--ext/intl/formatter/formatter_parse.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/ext/intl/formatter/formatter_parse.c b/ext/intl/formatter/formatter_parse.c
index 3015adac05..9940cc5fe7 100644
--- a/ext/intl/formatter/formatter_parse.c
+++ b/ext/intl/formatter/formatter_parse.c
@@ -44,13 +44,13 @@ PHP_FUNCTION( numfmt_parse )
FORMATTER_METHOD_INIT_VARS;
/* Parse parameters. */
- if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "Os|lz!",
+ if (zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "Os|lz!",
&object, NumberFormatter_ce_ptr, &str, &str_len, &type, &zposition ) == FAILURE )
{
RETURN_THROWS();
}
- if(zposition) {
+ if (zposition) {
position = (int32_t) zval_get_long(zposition);
position_p = &position;
}
@@ -86,17 +86,20 @@ PHP_FUNCTION( numfmt_parse )
RETVAL_DOUBLE(val_double);
break;
default:
- php_error_docref(NULL, E_WARNING, "Unsupported format type " ZEND_LONG_FMT, type);
- RETVAL_FALSE;
- break;
+ zend_argument_value_error(3, "must be a NumberFormatter::TYPE_* constant");
+ goto cleanup;
+ }
+
+ if (zposition) {
+ ZEND_TRY_ASSIGN_REF_LONG(zposition, position);
}
+
+cleanup:
+
#if ICU_LOCALE_BUG && defined(LC_NUMERIC)
setlocale(LC_NUMERIC, oldlocale);
efree(oldlocale);
#endif
- if(zposition) {
- ZEND_TRY_ASSIGN_REF_LONG(zposition, position);
- }
if (sstr) {
efree(sstr);