Skip to content

Commit

Permalink
Eliminate null return value for Normalizer::normalize()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nikic committed Jul 14, 2021
1 parent e1285c4 commit 5dc995d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ext/intl/normalizer/normalizer.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions ext/intl/normalizer/normalizer_arginfo.h
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
3 changes: 2 additions & 1 deletion ext/intl/normalizer/normalizer_normalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/php_intl.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

Expand Down
4 changes: 2 additions & 2 deletions ext/intl/php_intl_arginfo.h
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 5dc995d

Please sign in to comment.