diff --git a/UPGRADING b/UPGRADING index 93e7a7d53be..cbfd9769d0e 100644 --- a/UPGRADING +++ b/UPGRADING @@ -332,6 +332,11 @@ PHP 8.1 UPGRADE NOTES RFC: https://wiki.php.net/rfc/implicit-float-int-deprecate . returning a non-array from __sleep will raise a warning +- Date: + . The date_sunrise() and date_sunset() functions have been deprecated in + favor of date_sun_info(). + RFC: https://wiki.php.net/rfc/deprecations_php_8_1 + - MySQLi: . The mysqli_driver::$driver_version property has been deprecated. The driver version is meaningless as it hasn't been updated in more than a decade. Use diff --git a/ext/date/php_date.stub.php b/ext/date/php_date.stub.php index f17acf1e7eb..744b5e5f4b1 100644 --- a/ext/date/php_date.stub.php +++ b/ext/date/php_date.stub.php @@ -102,11 +102,13 @@ function date_default_timezone_set(string $timezoneId): bool {} function date_default_timezone_get(): string {} +/** @deprecated */ function date_sunrise( int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, ?float $latitude = null, ?float $longitude = null, ?float $zenith = null, ?float $utcOffset = null): string|int|float|false {} +/** @deprecated */ function date_sunset( int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, ?float $latitude = null, ?float $longitude = null, ?float $zenith = null, diff --git a/ext/date/php_date_arginfo.h b/ext/date/php_date_arginfo.h index 095fc486b78..2aea1c5e349 100644 --- a/ext/date/php_date_arginfo.h +++ b/ext/date/php_date_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: e8bc76a5db3a225746daffe29c0b8404cf971452 */ + * Stub hash: fbec11a67d5cc04667a012f25894f0d9e18833a6 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_strtotime, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, datetime, IS_STRING, 0) @@ -597,8 +597,8 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(date_interval_format, arginfo_date_interval_format) ZEND_FE(date_default_timezone_set, arginfo_date_default_timezone_set) ZEND_FE(date_default_timezone_get, arginfo_date_default_timezone_get) - ZEND_FE(date_sunrise, arginfo_date_sunrise) - ZEND_FE(date_sunset, arginfo_date_sunset) + ZEND_DEP_FE(date_sunrise, arginfo_date_sunrise) + ZEND_DEP_FE(date_sunset, arginfo_date_sunset) ZEND_FE(date_sun_info, arginfo_date_sun_info) ZEND_FE_END }; diff --git a/ext/date/tests/date_sunrise_and_sunset_basic.phpt b/ext/date/tests/date_sunrise_and_sunset_basic.phpt index c1606578eed..2a2e88cc60a 100644 --- a/ext/date/tests/date_sunrise_and_sunset_basic.phpt +++ b/ext/date/tests/date_sunrise_and_sunset_basic.phpt @@ -24,7 +24,15 @@ var_dump(gettype(date_sunset(time()))); ?> --EXPECTF-- Basic test for date_sunrise() and date_sunset() + +Deprecated: Function date_sunrise() is deprecated in %s on line %d %s %s %d %d, sunrise time : %d:%d + +Deprecated: Function date_sunset() is deprecated in %s on line %d %s %s %d %d, sunset time : %d:%d + +Deprecated: Function date_sunrise() is deprecated in %s on line %d string(6) "string" + +Deprecated: Function date_sunset() is deprecated in %s on line %d string(6) "string" diff --git a/ext/date/tests/date_sunrise_and_sunset_error.phpt b/ext/date/tests/date_sunrise_and_sunset_error.phpt index 45054390176..3e859940c16 100644 --- a/ext/date/tests/date_sunrise_and_sunset_error.phpt +++ b/ext/date/tests/date_sunrise_and_sunset_error.phpt @@ -16,6 +16,9 @@ try { } ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Function date_sunrise() is deprecated in %s on line %d date_sunrise(): Argument #2 ($returnFormat) must be one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING, or SUNFUNCS_RET_DOUBLE + +Deprecated: Function date_sunset() is deprecated in %s on line %d date_sunset(): Argument #2 ($returnFormat) must be one of SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING, or SUNFUNCS_RET_DOUBLE diff --git a/ext/date/tests/date_sunrise_variation7.phpt b/ext/date/tests/date_sunrise_variation7.phpt index 1535738bc78..31046112a28 100644 --- a/ext/date/tests/date_sunrise_variation7.phpt +++ b/ext/date/tests/date_sunrise_variation7.phpt @@ -1,5 +1,7 @@ --TEST-- Test date_sunrise() function : usage variation - Checking sunrise for consecutive days in specific timezone +--INI-- +error_reporting=E_ALL&~E_DEPRECATED --FILE--