Skip to content

Commit 811245d

Browse files
committed
Calling IntlGregorianCalendar::__construct() with more than 2 arguments and intlgregcal_create_instance()
1 parent f4df37a commit 811245d

14 files changed

+50
-12
lines changed

UPGRADING

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ PHP 8.4 UPGRADE NOTES
150150
. Calling intlcal_set() as well as calling IntlCalendar::set() with
151151
more than 2 arguments is deprecated. Use either IntlCalendar::setDate()
152152
or IntlCalendar::setDateTime() instead.
153+
. Calling intlgregcal_create_instance() as well as calling
154+
IntlGregorianCalendar::__construct() with more than 2 arguments is
155+
deprecated. Use either IntlGregorianCalendar::createFromDate() or
156+
IntlGregorianCalendar::createFromDateTime() instead.
157+
153158
========================================
154159
5. Changed Functions
155160
========================================

ext/intl/calendar/gregoriancalendar_methods.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ static void _php_intlgregcal_constructor_body(
9191
int variant;
9292
intl_error_reset(NULL);
9393

94+
if (is_constructor && ZEND_NUM_ARGS() > 2) {
95+
zend_error(E_DEPRECATED, "Calling IntlGregorianCalendar::__construct() with more than 2 arguments is deprecated, "
96+
"use either IntlGregorianCalendar::createFromDate() or IntlGregorianCalendar::createFromDateTime() instead");
97+
if (UNEXPECTED(EG(exception))) {
98+
RETURN_THROWS();
99+
}
100+
}
101+
94102
// parameter number validation / variant determination
95103
if (ZEND_NUM_ARGS() > 6 ||
96104
zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {

ext/intl/php_intl.stub.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ function intlcal_get_error_message(IntlCalendar $calendar): string|false {}
278278
* @param int $hour
279279
* @param int $minute
280280
* @param int $second
281+
* @deprecated
281282
*/
282283
function intlgregcal_create_instance($timezoneOrYear = UNKNOWN, $localeOrMonth = UNKNOWN, $day = UNKNOWN, $hour = UNKNOWN, $minute = UNKNOWN, $second = UNKNOWN): ?IntlGregorianCalendar {}
283284

ext/intl/php_intl_arginfo.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/intl/tests/calendar_get_setSkippedWallTimeOption_basic.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ var_dump(
4242

4343

4444
?>
45-
--EXPECT--
45+
--EXPECTF--
46+
Deprecated: Calling IntlGregorianCalendar::__construct() with more than 2 arguments is deprecated, use either IntlGregorianCalendar::createFromDate() or IntlGregorianCalendar::createFromDateTime() instead in %s on line %d
4647
int(0)
4748
Should be 3h30
4849
int(3)

ext/intl/tests/calendar_roll_basic.phpt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); //1
2121

2222

2323
?>
24-
--EXPECT--
24+
--EXPECTF--
25+
Deprecated: Calling IntlGregorianCalendar::__construct() with more than 2 arguments is deprecated, use either IntlGregorianCalendar::createFromDate() or IntlGregorianCalendar::createFromDateTime() instead in %s on line %d
2526
bool(true)
2627
int(1)
2728
int(1)
29+
30+
Deprecated: Calling IntlGregorianCalendar::__construct() with more than 2 arguments is deprecated, use either IntlGregorianCalendar::createFromDate() or IntlGregorianCalendar::createFromDateTime() instead in %s on line %d
2831
bool(true)
2932
int(1)
30-
int(1)
33+
int(1)

ext/intl/tests/calendar_roll_variation1.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); //28
2020

2121
?>
2222
--EXPECTF--
23+
Deprecated: Calling IntlGregorianCalendar::__construct() with more than 2 arguments is deprecated, use either IntlGregorianCalendar::createFromDate() or IntlGregorianCalendar::createFromDateTime() instead in %s on line %d
24+
2325
Deprecated: IntlCalendar::roll(): Passing bool is deprecated, use 1 or -1 instead in %s on line %d
2426
bool(true)
2527
int(1)

ext/intl/tests/calendar_toDateTime_basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ $dt = $cal->toDateTime();
1515
var_dump($dt->format("c"), $dt->getTimeZone()->getName());
1616
?>
1717
--EXPECTF--
18-
Deprecated: Calling IntlGregorianCalendar::__construct() with more than 2 arguments is deprecated in %s on line %d
18+
Deprecated: Calling IntlGregorianCalendar::__construct() with more than 2 arguments is deprecated, use either IntlGregorianCalendar::createFromDate() or IntlGregorianCalendar::createFromDateTime() instead in %s on line %d
1919
string(25) "2012-05-17T17:35:36+01:00"
2020
string(13) "Europe/Lisbon"

ext/intl/tests/gregoriancalendar___construct_basic.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ var_dump($intlcal->getLocale(1));
3131

3232
var_dump($intlcal->getType());
3333
?>
34-
--EXPECT--
34+
--EXPECTF--
35+
Deprecated: Function intlgregcal_create_instance() is deprecated in %s on line %d
3536
string(16) "Europe/Amsterdam"
3637
string(5) "nl_NL"
3738
string(13) "Europe/Lisbon"
@@ -40,6 +41,8 @@ string(16) "Europe/Amsterdam"
4041
string(5) "pt_PT"
4142
string(13) "Europe/Lisbon"
4243
string(5) "pt_PT"
44+
45+
Deprecated: Calling IntlGregorianCalendar::__construct() with more than 2 arguments is deprecated, use either IntlGregorianCalendar::createFromDate() or IntlGregorianCalendar::createFromDateTime() instead in %s on line %d
4346
string(12) "Europe/Paris"
4447
string(5) "fr_CA"
4548
string(9) "gregorian"

ext/intl/tests/gregoriancalendar___construct_error.phpt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,19 @@ try {
3939
echo $e->getMessage(), "\n";
4040
}
4141
?>
42-
--EXPECT--
42+
--EXPECTF--
43+
Deprecated: Function intlgregcal_create_instance() is deprecated in %s on line %d
4344
Too many arguments
45+
46+
Deprecated: Function intlgregcal_create_instance() is deprecated in %s on line %d
4447
Too many arguments
48+
49+
Deprecated: Function intlgregcal_create_instance() is deprecated in %s on line %d
4550
No variant with 4 arguments (excluding trailing NULLs)
51+
52+
Deprecated: Calling IntlGregorianCalendar::__construct() with more than 2 arguments is deprecated, use either IntlGregorianCalendar::createFromDate() or IntlGregorianCalendar::createFromDateTime() instead in %s on line %d
4653
No variant with 4 arguments (excluding trailing NULLs)
54+
55+
Deprecated: Calling IntlGregorianCalendar::__construct() with more than 2 arguments is deprecated, use either IntlGregorianCalendar::createFromDate() or IntlGregorianCalendar::createFromDateTime() instead in %s on line %d
4756
IntlGregorianCalendar::__construct(): Argument #6 ($second) must be of type int, array given
4857
IntlGregorianCalendar object is already constructed

ext/intl/tests/gregoriancalendar___construct_variant1.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ var_dump($intlcal->getTime(), (float)strtotime('2012-02-29 16:07:08') * 1000);
1717

1818
var_dump($intlcal->getType());
1919
?>
20-
--EXPECT--
20+
--EXPECTF--
21+
Deprecated: Function intlgregcal_create_instance() is deprecated in %s on line %d
2122
string(16) "Europe/Amsterdam"
2223
float(1330527600000)
2324
float(1330527600000)
25+
26+
Deprecated: Calling IntlGregorianCalendar::__construct() with more than 2 arguments is deprecated, use either IntlGregorianCalendar::createFromDate() or IntlGregorianCalendar::createFromDateTime() instead in %s on line %d
2427
float(1330528028000)
2528
float(1330528028000)
2629
string(9) "gregorian"

ext/intl/tests/msgfmt_format_intlcalendar_variant2.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ echo "msgf2: ", $msgf->format(array($time, 'date')), " ",
2424
*/
2525

2626
?>
27-
--EXPECT--
27+
--EXPECTF--
28+
Deprecated: Calling IntlGregorianCalendar::__construct() with more than 2 arguments is deprecated, use either IntlGregorianCalendar::createFromDate() or IntlGregorianCalendar::createFromDateTime() instead in %s on line %d
2829
Quinta-feira, 17 de Maio de 2012 5:35:36 PM ptlis

ext/intl/tests/msgfmt_format_intlcalendar_variant3.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ echo "msgf2: ", $msgf->format(array($time, 'date')), " ",
2525
*/
2626

2727
?>
28-
--EXPECT--
28+
--EXPECTF--
29+
Deprecated: Calling IntlGregorianCalendar::__construct() with more than 2 arguments is deprecated, use either IntlGregorianCalendar::createFromDate() or IntlGregorianCalendar::createFromDateTime() instead in %s on line %d
2930
quinta-feira, 17 de Maio de 2012 5:35:36 da tarde ptlis

ext/intl/tests/msgfmt_format_intlcalendar_variant4.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ echo "msgf2: ", $msgf->format(array($time, 'date')), " ",
2929
*/
3030

3131
?>
32-
--EXPECT--
32+
--EXPECTF--
33+
Deprecated: Calling IntlGregorianCalendar::__construct() with more than 2 arguments is deprecated, use either IntlGregorianCalendar::createFromDate() or IntlGregorianCalendar::createFromDateTime() instead in %s on line %d
3334
quinta-feira, 17 de maio de 2012 5:35:36 da tarde ptlis

0 commit comments

Comments
 (0)