Commit 6f1f4656a19 for php.net

commit 6f1f4656a196c46a9dfb0a70df1997b45dec1716
Author: Weilin Du <108666168+LamentXU123@users.noreply.github.com>
Date:   Tue May 12 13:13:59 2026 +0800

    ext/intl: Throw ValueError for invalid break iterator locale type (#21997)

diff --git a/NEWS b/NEWS
index 8974665955f..821dc09ad3a 100644
--- a/NEWS
+++ b/NEWS
@@ -66,6 +66,8 @@ PHP                                                                        NEWS
   . Added grapheme_strrev (Yuya Hamada)
   . Passing a non-stringable object as a time zone to Intl time zone
     argument handling now raises TypeError instead of Error. (Weilin Du)
+  . IntlBreakIterator::getLocale() now raises ValueError for invalid locale
+    types. (Weilin Du)

 - JSON:
   . Enriched JSON last error / exception message with error location.
diff --git a/UPGRADING b/UPGRADING
index 5837f7ac62f..37abc121a07 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -37,6 +37,9 @@ PHP 8.6 UPGRADE NOTES
 - Intl:
   . Passing a non-stringable object as a time zone to Intl APIs that accept
     time zone objects or strings now raises a TypeError instead of an Error.
+  . IntlBreakIterator::getLocale() now raises a ValueError when the type is
+    neither Locale::ACTUAL_LOCALE nor Locale::VALID_LOCALE instead of
+    returning false.

 - PCNTL:
   . pcntl_alarm() now raises a ValueError if the seconds argument is
diff --git a/ext/intl/breakiterator/breakiterator_methods.cpp b/ext/intl/breakiterator/breakiterator_methods.cpp
index 972cd28cf38..66a35e65ac6 100644
--- a/ext/intl/breakiterator/breakiterator_methods.cpp
+++ b/ext/intl/breakiterator/breakiterator_methods.cpp
@@ -297,11 +297,9 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, getLocale)
 		Z_PARAM_LONG(locale_type)
 	ZEND_PARSE_PARAMETERS_END();

-	/* TODO: Change to ValueError? */
 	if (locale_type != ULOC_ACTUAL_LOCALE && locale_type != ULOC_VALID_LOCALE) {
-		intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
-			"invalid locale type");
-		RETURN_FALSE;
+		zend_argument_value_error(1, "must be either Locale::ACTUAL_LOCALE or Locale::VALID_LOCALE");
+		RETURN_THROWS();
 	}

 	BREAKITER_METHOD_FETCH_OBJECT;
diff --git a/ext/intl/tests/breakiter_getLocale_error.phpt b/ext/intl/tests/breakiter_getLocale_error.phpt
new file mode 100644
index 00000000000..07d57dbc426
--- /dev/null
+++ b/ext/intl/tests/breakiter_getLocale_error.phpt
@@ -0,0 +1,25 @@
+--TEST--
+IntlBreakIterator::getLocale(): bad arguments
+--EXTENSIONS--
+intl
+--FILE--
+<?php
+
+$bi = IntlBreakIterator::createSentenceInstance('pt');
+
+try {
+	$bi->getLocale(2);
+} catch (Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+
+try {
+	$bi->getLocale(-1);
+} catch (Throwable $e) {
+	echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+
+?>
+--EXPECT--
+ValueError: IntlBreakIterator::getLocale(): Argument #1 ($type) must be either Locale::ACTUAL_LOCALE or Locale::VALID_LOCALE
+ValueError: IntlBreakIterator::getLocale(): Argument #1 ($type) must be either Locale::ACTUAL_LOCALE or Locale::VALID_LOCALE