From 1c50784ae7175cea91a669c887eca46572bdab23 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 8 Jul 2021 12:05:49 +0200 Subject: [PATCH] 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. --- UPGRADING | 5 +++++ ext/intl/calendar/calendar_methods.cpp | 1 + ext/intl/tests/calendar_isEquivalentTo_basic.phpt | 4 ++-- ext/intl/tests/calendar_roll_variation1.phpt | 7 +++++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/UPGRADING b/UPGRADING index 288afe7db71..fbb536dd6bb 100644 --- a/UPGRADING +++ b/UPGRADING @@ -337,6 +337,11 @@ PHP 8.1 UPGRADE NOTES favor of date_sun_info(). RFC: https://wiki.php.net/rfc/deprecations_php_8_1 +- Intl: + . Calling IntlCalendar::roll() with bool argument is deprecated. Pass 1 and -1 + instead of true and false respectively. + RFC: https://wiki.php.net/rfc/deprecations_php_8_1 + - Mbstring: . Calling mb_check_encoding() without an argument is deprecated. RFC: https://wiki.php.net/rfc/deprecations_php_8_1 diff --git a/ext/intl/calendar/calendar_methods.cpp b/ext/intl/calendar/calendar_methods.cpp index e846f416bd8..4f1b52654bb 100644 --- a/ext/intl/calendar/calendar_methods.cpp +++ b/ext/intl/calendar/calendar_methods.cpp @@ -424,6 +424,7 @@ U_CFUNC PHP_FUNCTION(intlcal_roll) if (Z_TYPE_P(zvalue) == IS_FALSE || Z_TYPE_P(zvalue) == IS_TRUE) { value = Z_TYPE_P(zvalue) == IS_TRUE ? 1 : -1; + php_error_docref(NULL, E_DEPRECATED, "Passing bool is deprecated, use 1 or -1 instead"); } else { value = zval_get_long(zvalue); ZEND_VALUE_ERROR_OUT_OF_BOUND_VALUE(value, 3); diff --git a/ext/intl/tests/calendar_isEquivalentTo_basic.phpt b/ext/intl/tests/calendar_isEquivalentTo_basic.phpt index e88d5e4164b..e9c0a6ec575 100644 --- a/ext/intl/tests/calendar_isEquivalentTo_basic.phpt +++ b/ext/intl/tests/calendar_isEquivalentTo_basic.phpt @@ -11,7 +11,7 @@ $intlcal1 = IntlCalendar::createInstance('Europe/Amsterdam'); $intlcal2 = IntlCalendar::createInstance('Europe/Lisbon'); $intlcal3 = IntlCalendar::createInstance('Europe/Amsterdam', "nl_NL@calendar=islamic"); $intlcal4 = IntlCalendar::createInstance('Europe/Amsterdam'); -$intlcal4->roll(IntlCalendar::FIELD_MONTH, true); +$intlcal4->roll(IntlCalendar::FIELD_MONTH, 1); var_dump( "1 - 1", @@ -33,4 +33,4 @@ bool(false) string(5) "1 - 3" bool(false) string(5) "1 - 4" -bool(true) \ No newline at end of file +bool(true) diff --git a/ext/intl/tests/calendar_roll_variation1.phpt b/ext/intl/tests/calendar_roll_variation1.phpt index dcba3838a73..a7cceb94e59 100644 --- a/ext/intl/tests/calendar_roll_variation1.phpt +++ b/ext/intl/tests/calendar_roll_variation1.phpt @@ -19,10 +19,13 @@ var_dump($intlcal->get(IntlCalendar::FIELD_MONTH)); //1 (Feb) var_dump($intlcal->get(IntlCalendar::FIELD_DAY_OF_MONTH)); //28 ?> ---EXPECT-- +--EXPECTF-- +Deprecated: IntlCalendar::roll(): Passing bool is deprecated, use 1 or -1 instead in %s on line %d bool(true) int(1) int(29) + +Deprecated: intlcal_roll(): Passing bool is deprecated, use 1 or -1 instead in %s on line %d bool(true) int(1) -int(28) \ No newline at end of file +int(28)