Commit 9e68cf888ac for php.net

commit 9e68cf888ac8c8620349d684495c3c4ed52daabe
Author: Weilin Du <108666168+LamentXU123@users.noreply.github.com>
Date:   Fri Jun 12 22:55:03 2026 +0800

    ext/intl: Sync IntlTimeZone object errors for invalid display types

    Align IntlTimeZone::getDisplayName() object error handling for invalid display types with the corresponding IntlDateFormatter behavior, and add coverage for the invalid enum values.

    Closes GH-22270.

diff --git a/NEWS b/NEWS
index faeb27fdf6d..800423779d1 100644
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,8 @@ PHP                                                                        NEWS
   . Fix incorrect argument positions for uninitialized calendar arguments in
     IntlCalendar::equals(), ::before(), ::after(), and ::isEquivalentTo().
     (Weilin Du)
+  . Fixed IntlTimeZone::getDisplayName() to synchronize object error state
+    for invalid display types. (Weilin Du)
   . Fixed Spoofchecker restriction-level APIs to only be exposed with ICU 53
     and later. (Graham Campbell)

diff --git a/ext/intl/tests/timezone_getDisplayName_error.phpt b/ext/intl/tests/timezone_getDisplayName_error.phpt
index ce3ab2f7e76..8cecb40ecfe 100644
--- a/ext/intl/tests/timezone_getDisplayName_error.phpt
+++ b/ext/intl/tests/timezone_getDisplayName_error.phpt
@@ -8,12 +8,18 @@

 $tz = IntlTimeZone::createTimeZone('Europe/Lisbon');
 var_dump($tz->getDisplayName(false, -1));
+echo intl_get_error_message(), PHP_EOL;
+var_dump($tz->getErrorCode());
+echo $tz->getErrorMessage(), PHP_EOL;

 var_dump(intltz_get_display_name(null, IntlTimeZone::DISPLAY_SHORT, false, 'pt_PT'));
 ?>
 --EXPECTF--
 Warning: IntlTimeZone::getDisplayName(): wrong display type in %s on line %d
 bool(false)
+wrong display type: U_ILLEGAL_ARGUMENT_ERROR
+int(1)
+wrong display type: U_ILLEGAL_ARGUMENT_ERROR

 Fatal error: Uncaught TypeError: intltz_get_display_name(): Argument #1 ($timezone) must be of type IntlTimeZone, null given in %s:%d
 Stack trace:
diff --git a/ext/intl/timezone/timezone_methods.cpp b/ext/intl/timezone/timezone_methods.cpp
index ec7ad9942fd..e3aa958508c 100644
--- a/ext/intl/timezone/timezone_methods.cpp
+++ b/ext/intl/timezone/timezone_methods.cpp
@@ -513,13 +513,15 @@ U_CFUNC PHP_FUNCTION(intltz_get_display_name)
 		RETURN_THROWS();
 	}

+	TIMEZONE_METHOD_FETCH_OBJECT;
+
 	bool found = false;
 	for (int i = 0; !found && i < sizeof(display_types)/sizeof(*display_types); i++) {
 		if (display_types[i] == display_type)
 			found = true;
 	}
 	if (!found) {
-		intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
+		intl_errors_set(TIMEZONE_ERROR_P(to), U_ILLEGAL_ARGUMENT_ERROR,
 			"wrong display type", 0);
 		RETURN_FALSE;
 	}
@@ -528,8 +530,6 @@ U_CFUNC PHP_FUNCTION(intltz_get_display_name)
 		locale_str = intl_locale_get_default();
 	}

-	TIMEZONE_METHOD_FETCH_OBJECT;
-
 	UnicodeString result;
 	to->utimezone->getDisplayName((UBool)daylight, (TimeZone::EDisplayType)display_type,
 		Locale::createFromName(locale_str), result);