Skip to content

Commit 1c50784

Browse files
committed
Deprecate IntlCalendar::roll() with bool argument
Pass 1 instead of true and -1 instead of false. Part of https://wiki.php.net/rfc/deprecations_php_8_1.
1 parent 92f6e21 commit 1c50784

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

UPGRADING

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,11 @@ PHP 8.1 UPGRADE NOTES
337337
favor of date_sun_info().
338338
RFC: https://wiki.php.net/rfc/deprecations_php_8_1
339339

340+
- Intl:
341+
. Calling IntlCalendar::roll() with bool argument is deprecated. Pass 1 and -1
342+
instead of true and false respectively.
343+
RFC: https://wiki.php.net/rfc/deprecations_php_8_1
344+
340345
- Mbstring:
341346
. Calling mb_check_encoding() without an argument is deprecated.
342347
RFC: https://wiki.php.net/rfc/deprecations_php_8_1

ext/intl/calendar/calendar_methods.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ U_CFUNC PHP_FUNCTION(intlcal_roll)
424424

425425
if (Z_TYPE_P(zvalue) == IS_FALSE || Z_TYPE_P(zvalue) == IS_TRUE) {
426426
value = Z_TYPE_P(zvalue) == IS_TRUE ? 1 : -1;
427+
php_error_docref(NULL, E_DEPRECATED, "Passing bool is deprecated, use 1 or -1 instead");
427428
} else {
428429
value = zval_get_long(zvalue);
429430
ZEND_VALUE_ERROR_OUT_OF_BOUND_VALUE(value, 3);

ext/intl/tests/calendar_isEquivalentTo_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ $intlcal1 = IntlCalendar::createInstance('Europe/Amsterdam');
1111
$intlcal2 = IntlCalendar::createInstance('Europe/Lisbon');
1212
$intlcal3 = IntlCalendar::createInstance('Europe/Amsterdam', "nl_NL@calendar=islamic");
1313
$intlcal4 = IntlCalendar::createInstance('Europe/Amsterdam');
14-
$intlcal4->roll(IntlCalendar::FIELD_MONTH, true);
14+
$intlcal4->roll(IntlCalendar::FIELD_MONTH, 1);
1515

1616
var_dump(
1717
"1 - 1",
@@ -33,4 +33,4 @@ bool(false)
3333
string(5) "1 - 3"
3434
bool(false)
3535
string(5) "1 - 4"
36-
bool(true)
36+
bool(true)

ext/intl/tests/calendar_roll_variation1.phpt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ var_dump($intlcal->get(IntlCalendar::FIELD_MONTH)); //1 (Feb)
1919
var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); //28
2020

2121
?>
22-
--EXPECT--
22+
--EXPECTF--
23+
Deprecated: IntlCalendar::roll(): Passing bool is deprecated, use 1 or -1 instead in %s on line %d
2324
bool(true)
2425
int(1)
2526
int(29)
27+
28+
Deprecated: intlcal_roll(): Passing bool is deprecated, use 1 or -1 instead in %s on line %d
2629
bool(true)
2730
int(1)
28-
int(28)
31+
int(28)

0 commit comments

Comments
 (0)