Skip to content

Commit b287611

Browse files
authored
Update return types of transliterator_get_error_code(), transliterator_get_error_message(), TransLiterator::getErrorCode(), and TransLiterator::getErrorMessage() (#18470)
Returning false is impossible.
1 parent 156d034 commit b287611

File tree

6 files changed

+14
-15
lines changed

6 files changed

+14
-15
lines changed

UPGRADING

+4-1
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,15 @@ PHP 8.5 UPGRADE NOTES
221221
- Intl:
222222
. IntlDateFormatter::setTimeZone()/datefmt_set_timezone()
223223
throws an IntlException on uninitialised classes/clone failures.
224-
225224
. grapheme_extract() properly assigns $next value when skipping over
226225
invalid starting bytes. Previously there were cases where it would
227226
point to the start of the grapheme boundary instead of the end.
228227
. Locale:: methods throw a ValueError when locale inputs contain null
229228
bytes.
229+
. transliterator_get_error_code(), transliterator_get_error_message()
230+
TransLiterator::getErrorCode(), and TransLiterator::getErrorMessage()
231+
have dropped the false from the return type union. Returning false
232+
was actually never possible.
230233

231234
- libxml:
232235
. libxml_set_external_entity_loader() now has a formal return type of true.

ext/intl/php_intl.stub.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,6 @@ function transliterator_create_inverse(Transliterator $transliterator): ?Transli
637637

638638
function transliterator_transliterate(Transliterator|string $transliterator, string $string, int $start = 0, int $end = -1): string|false {}
639639

640-
function transliterator_get_error_code(Transliterator $transliterator): int|false {}
640+
function transliterator_get_error_code(Transliterator $transliterator): int {}
641641

642-
function transliterator_get_error_message(Transliterator $transliterator): string|false {}
642+
function transliterator_get_error_message(Transliterator $transliterator): string {}

ext/intl/php_intl_arginfo.h

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/intl/transliterator/transliterator.stub.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ public function transliterate(string $string, int $start = 0, int $end = -1): st
4949
* @tentative-return-type
5050
* @alias transliterator_get_error_code
5151
*/
52-
public function getErrorCode(): int|false {}
52+
public function getErrorCode(): int {}
5353

5454
/**
5555
* @tentative-return-type
5656
* @alias transliterator_get_error_message
5757
*/
58-
public function getErrorMessage(): string|false {}
58+
public function getErrorMessage(): string {}
5959
}

ext/intl/transliterator/transliterator_arginfo.h

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/intl/transliterator/transliterator_methods.c

-4
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,6 @@ PHP_FUNCTION( transliterator_get_error_code )
437437

438438
/* Fetch the object (without resetting its last error code ). */
439439
to = Z_INTL_TRANSLITERATOR_P( object );
440-
if (to == NULL )
441-
RETURN_FALSE;
442440

443441
RETURN_LONG( (zend_long) TRANSLITERATOR_ERROR_CODE( to ) );
444442
}
@@ -460,8 +458,6 @@ PHP_FUNCTION( transliterator_get_error_message )
460458

461459
/* Fetch the object (without resetting its last error code ). */
462460
to = Z_INTL_TRANSLITERATOR_P( object );
463-
if (to == NULL )
464-
RETURN_FALSE;
465461

466462
/* Return last error message. */
467463
message = intl_error_get_message( TRANSLITERATOR_ERROR_P( to ) );

0 commit comments

Comments
 (0)