From 5dc995df375571489d9149fdccf258c0bd123317 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 14 Jul 2021 11:42:37 +0200 Subject: [PATCH] Eliminate null return value for Normalizer::normalize() One error condition was returning null instead of false. Adjust the implementation to look the same way as the exact same check a few lines below. --- ext/intl/normalizer/normalizer.stub.php | 2 +- ext/intl/normalizer/normalizer_arginfo.h | 4 ++-- ext/intl/normalizer/normalizer_normalize.c | 3 ++- ext/intl/php_intl.stub.php | 2 +- ext/intl/php_intl_arginfo.h | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ext/intl/normalizer/normalizer.stub.php b/ext/intl/normalizer/normalizer.stub.php index 9f931653381..75052535fc4 100644 --- a/ext/intl/normalizer/normalizer.stub.php +++ b/ext/intl/normalizer/normalizer.stub.php @@ -8,7 +8,7 @@ class Normalizer * @tentative-return-type * @alias normalizer_normalize */ - public static function normalize(string $string, int $form = Normalizer::FORM_C): string|false|null {} + public static function normalize(string $string, int $form = Normalizer::FORM_C): string|false {} /** * @tentative-return-type diff --git a/ext/intl/normalizer/normalizer_arginfo.h b/ext/intl/normalizer/normalizer_arginfo.h index 0f27b031b73..70262b0ffc9 100644 --- a/ext/intl/normalizer/normalizer_arginfo.h +++ b/ext/intl/normalizer/normalizer_arginfo.h @@ -1,7 +1,7 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: d2c622731e68d201a72f8c94094ec8263427b6de */ + * Stub hash: 71dd44d3b839789639c16a4b6d5b2e4f40703a74 */ -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_Normalizer_normalize, 0, 1, MAY_BE_STRING|MAY_BE_FALSE|MAY_BE_NULL) +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_Normalizer_normalize, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, form, IS_LONG, 0, "Normalizer::FORM_C") ZEND_END_ARG_INFO() diff --git a/ext/intl/normalizer/normalizer_normalize.c b/ext/intl/normalizer/normalizer_normalize.c index e16e2ef5d62..ee7b787b9ee 100644 --- a/ext/intl/normalizer/normalizer_normalize.c +++ b/ext/intl/normalizer/normalizer_normalize.c @@ -162,9 +162,10 @@ PHP_FUNCTION( normalizer_normalize ) * (U_STRING_NOT_TERMINATED_WARNING usually means that the input string is empty). */ if( U_FAILURE(status) && status != U_BUFFER_OVERFLOW_ERROR && status != U_STRING_NOT_TERMINATED_WARNING ) { + intl_error_set_custom_msg( NULL, "Error normalizing string", 0 ); efree( uret_buf ); efree( uinput ); - RETURN_NULL(); + RETURN_FALSE; } if ( size_needed > uret_len ) { diff --git a/ext/intl/php_intl.stub.php b/ext/intl/php_intl.stub.php index c711d000745..888a75afc0d 100644 --- a/ext/intl/php_intl.stub.php +++ b/ext/intl/php_intl.stub.php @@ -344,7 +344,7 @@ function msgfmt_get_error_message(MessageFormatter $formatter): string {} /* normalizer */ -function normalizer_normalize(string $string, int $form = Normalizer::FORM_C): string|false|null {} +function normalizer_normalize(string $string, int $form = Normalizer::FORM_C): string|false {} function normalizer_is_normalized(string $string, int $form = Normalizer::FORM_C): bool {} diff --git a/ext/intl/php_intl_arginfo.h b/ext/intl/php_intl_arginfo.h index ad4a83ba99a..41f8b160b49 100644 --- a/ext/intl/php_intl_arginfo.h +++ b/ext/intl/php_intl_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: ab16aedec569db2e2ba8d43c86549ef02d2392c4 */ + * Stub hash: 131ce191e92704737b4f20d19ddf53c181e590a6 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_intlcal_create_instance, 0, 0, IntlCalendar, 1) ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, timezone, "null") @@ -607,7 +607,7 @@ ZEND_END_ARG_INFO() #define arginfo_msgfmt_get_error_message arginfo_msgfmt_get_locale -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_normalizer_normalize, 0, 1, MAY_BE_STRING|MAY_BE_FALSE|MAY_BE_NULL) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_normalizer_normalize, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, form, IS_LONG, 0, "Normalizer::FORM_C") ZEND_END_ARG_INFO()