Commit 27d593e546c for php.net
commit 27d593e546c86a3aebe02b926d06f4e5dd7dd71f
Author: “LamentXU123” <108666168+LamentXU123@users.noreply.github.com>
Date: Mon May 18 17:58:02 2026 +0800
ext/intl: Fix argument position for uninitialized calendar arguments
close GH-22079
diff --git a/NEWS b/NEWS
index 0dd41914ed4..04593f1ce82 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,11 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.4.23
+- Intl:
+ . Fix incorrect argument positions for uninitialized calendar arguments in
+ IntlCalendar::equals(), ::before(), ::after(), and ::isEquivalentTo().
+ (Weilin Du)
+
04 Jun 2026, PHP 8.4.22
diff --git a/ext/intl/calendar/calendar_methods.cpp b/ext/intl/calendar/calendar_methods.cpp
index 61408375c86..680a01b24c0 100644
--- a/ext/intl/calendar/calendar_methods.cpp
+++ b/ext/intl/calendar/calendar_methods.cpp
@@ -345,7 +345,7 @@ static void _php_intlcal_before_after(
when_co = Z_INTL_CALENDAR_P(when_object);
if (when_co->ucal == NULL) {
- zend_argument_error(NULL, 2, "is uninitialized");
+ zend_argument_error(NULL, hasThis() ? 1 : 2, "is uninitialized");
RETURN_THROWS();
}
@@ -774,7 +774,7 @@ U_CFUNC PHP_FUNCTION(intlcal_is_equivalent_to)
other_co = Z_INTL_CALENDAR_P(other_object);
if (other_co->ucal == NULL) {
- zend_argument_error(NULL, 2, "is uninitialized");
+ zend_argument_error(NULL, hasThis() ? 1 : 2, "is uninitialized");
RETURN_THROWS();
}
@@ -912,7 +912,7 @@ U_CFUNC PHP_FUNCTION(intlcal_equals)
CALENDAR_METHOD_FETCH_OBJECT;
other_co = Z_INTL_CALENDAR_P(other_object);
if (other_co->ucal == NULL) {
- zend_argument_error(NULL, 2, "is uninitialized");
+ zend_argument_error(NULL, hasThis() ? 1 : 2, "is uninitialized");
RETURN_THROWS();
}
diff --git a/ext/intl/tests/calendar_uninitialized_argument_position.phpt b/ext/intl/tests/calendar_uninitialized_argument_position.phpt
new file mode 100644
index 00000000000..f9236718054
--- /dev/null
+++ b/ext/intl/tests/calendar_uninitialized_argument_position.phpt
@@ -0,0 +1,36 @@
+--TEST--
+IntlCalendar methods report the correct argument position for uninitialized calendar arguments
+--EXTENSIONS--
+intl
+--FILE--
+<?php
+
+$calendar = IntlGregorianCalendar::createFromDate(2024, 0, 1);
+$uninitialized = (new ReflectionClass(IntlGregorianCalendar::class))->newInstanceWithoutConstructor();
+
+foreach (['equals', 'before', 'after', 'isEquivalentTo'] as $method) {
+ try {
+ $calendar->$method($uninitialized);
+ } catch (Error $e) {
+ echo $method, ': ', $e->getMessage(), PHP_EOL;
+ }
+}
+
+foreach (['intlcal_equals', 'intlcal_before', 'intlcal_after', 'intlcal_is_equivalent_to'] as $function) {
+ try {
+ $function($calendar, $uninitialized);
+ } catch (Error $e) {
+ echo $function, ': ', $e->getMessage(), PHP_EOL;
+ }
+}
+
+?>
+--EXPECT--
+equals: IntlCalendar::equals(): Argument #1 ($other) is uninitialized
+before: IntlCalendar::before(): Argument #1 ($other) is uninitialized
+after: IntlCalendar::after(): Argument #1 ($other) is uninitialized
+isEquivalentTo: IntlCalendar::isEquivalentTo(): Argument #1 ($other) is uninitialized
+intlcal_equals: intlcal_equals(): Argument #2 ($other) is uninitialized
+intlcal_before: intlcal_before(): Argument #2 ($other) is uninitialized
+intlcal_after: intlcal_after(): Argument #2 ($other) is uninitialized
+intlcal_is_equivalent_to: intlcal_is_equivalent_to(): Argument #2 ($other) is uninitialized