Allowing catching arg type deprecations in intl classes

Closes GH-8115
Closes GH-8117
This commit is contained in:
Ilija Tovilo 2022-02-18 13:23:57 +01:00
parent 723058c3bf
commit 925a30979c
No known key found for this signature in database
GPG key ID: A4F5D403F118200A
10 changed files with 136 additions and 39 deletions

View file

@ -30,7 +30,7 @@ using icu::DateTimePatternGenerator;
using icu::Locale;
using icu::StringPiece;
static zend_result dtpg_ctor(INTERNAL_FUNCTION_PARAMETERS)
static zend_result dtpg_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_handling, bool *error_handling_replaced)
{
char *locale_str;
size_t locale_len = 0;
@ -44,6 +44,11 @@ static zend_result dtpg_ctor(INTERNAL_FUNCTION_PARAMETERS)
Z_PARAM_STRING_OR_NULL(locale_str, locale_len)
ZEND_PARSE_PARAMETERS_END_EX(return FAILURE);
if (error_handling != NULL) {
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, error_handling);
*error_handling_replaced = 1;
}
DTPATTERNGEN_METHOD_FETCH_OBJECT_NO_CHECK;
if (dtpgo->dtpg != NULL) {
@ -74,7 +79,7 @@ static zend_result dtpg_ctor(INTERNAL_FUNCTION_PARAMETERS)
U_CFUNC PHP_METHOD( IntlDatePatternGenerator, create )
{
object_init_ex( return_value, IntlDatePatternGenerator_ce_ptr );
if (dtpg_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) {
if (dtpg_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, NULL, NULL) == FAILURE) {
zval_ptr_dtor(return_value);
RETURN_NULL();
}
@ -83,19 +88,21 @@ U_CFUNC PHP_METHOD( IntlDatePatternGenerator, create )
U_CFUNC PHP_METHOD( IntlDatePatternGenerator, __construct )
{
zend_error_handling error_handling;
bool error_handling_replaced = 0;
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
/* return_value param is being changed, therefore we will always return
* NULL here */
return_value = ZEND_THIS;
if (dtpg_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) {
if (dtpg_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, &error_handling, &error_handling_replaced) == FAILURE) {
if (!EG(exception)) {
zend_string *err = intl_error_get_message(NULL);
zend_throw_exception(IntlException_ce_ptr, ZSTR_VAL(err), intl_error_get_code(NULL));
zend_string_release_ex(err, 0);
}
}
zend_restore_error_handling(&error_handling);
if (error_handling_replaced) {
zend_restore_error_handling(&error_handling);
}
}