Skip to content

Commit cd2e060

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: ext/intl: Fix argument position for uninitialized calendar arguments
2 parents 755f4e6 + 87efb35 commit cd2e060

2 files changed

Lines changed: 39 additions & 3 deletions

File tree

ext/intl/calendar/calendar_methods.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ static void _php_intlcal_before_after(
373373

374374
when_co = Z_INTL_CALENDAR_P(when_object);
375375
if (when_co->ucal == NULL) {
376-
zend_argument_error(NULL, 2, "is uninitialized");
376+
zend_argument_error(NULL, hasThis() ? 1 : 2, "is uninitialized");
377377
RETURN_THROWS();
378378
}
379379

@@ -796,7 +796,7 @@ U_CFUNC PHP_FUNCTION(intlcal_is_equivalent_to)
796796

797797
other_co = Z_INTL_CALENDAR_P(other_object);
798798
if (other_co->ucal == NULL) {
799-
zend_argument_error(NULL, 2, "is uninitialized");
799+
zend_argument_error(NULL, hasThis() ? 1 : 2, "is uninitialized");
800800
RETURN_THROWS();
801801
}
802802

@@ -933,7 +933,7 @@ U_CFUNC PHP_FUNCTION(intlcal_equals)
933933
CALENDAR_METHOD_FETCH_OBJECT;
934934
other_co = Z_INTL_CALENDAR_P(other_object);
935935
if (other_co->ucal == NULL) {
936-
zend_argument_error(NULL, 2, "is uninitialized");
936+
zend_argument_error(NULL, hasThis() ? 1 : 2, "is uninitialized");
937937
RETURN_THROWS();
938938
}
939939

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
IntlCalendar methods report the correct argument position for uninitialized calendar arguments
3+
--EXTENSIONS--
4+
intl
5+
--FILE--
6+
<?php
7+
8+
$calendar = IntlGregorianCalendar::createFromDate(2024, 0, 1);
9+
$uninitialized = (new ReflectionClass(IntlGregorianCalendar::class))->newInstanceWithoutConstructor();
10+
11+
foreach (['equals', 'before', 'after', 'isEquivalentTo'] as $method) {
12+
try {
13+
$calendar->$method($uninitialized);
14+
} catch (Error $e) {
15+
echo $method, ': ', $e->getMessage(), PHP_EOL;
16+
}
17+
}
18+
19+
foreach (['intlcal_equals', 'intlcal_before', 'intlcal_after', 'intlcal_is_equivalent_to'] as $function) {
20+
try {
21+
$function($calendar, $uninitialized);
22+
} catch (Error $e) {
23+
echo $function, ': ', $e->getMessage(), PHP_EOL;
24+
}
25+
}
26+
27+
?>
28+
--EXPECT--
29+
equals: IntlCalendar::equals(): Argument #1 ($other) is uninitialized
30+
before: IntlCalendar::before(): Argument #1 ($other) is uninitialized
31+
after: IntlCalendar::after(): Argument #1 ($other) is uninitialized
32+
isEquivalentTo: IntlCalendar::isEquivalentTo(): Argument #1 ($other) is uninitialized
33+
intlcal_equals: intlcal_equals(): Argument #2 ($other) is uninitialized
34+
intlcal_before: intlcal_before(): Argument #2 ($other) is uninitialized
35+
intlcal_after: intlcal_after(): Argument #2 ($other) is uninitialized
36+
intlcal_is_equivalent_to: intlcal_is_equivalent_to(): Argument #2 ($other) is uninitialized

0 commit comments

Comments
 (0)