1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Deprecate date_sunrise() and date_sunset()

date_sunrise() and date_sunset() are deprecated in favor of
date_sun_info().

Part of https://wiki.php.net/rfc/deprecations_php_8_1.
This commit is contained in:
Nikita Popov
2021-07-08 11:09:50 +02:00
parent 7bbc85f16a
commit 5bb83b3778
10 changed files with 31 additions and 4 deletions

View File

@@ -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

View File

@@ -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,

View File

@@ -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
};

View File

@@ -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"

View File

@@ -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

View File

@@ -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--
<?php
echo "*** Testing date_sunrise() : usage variation ***\n";

View File

@@ -1,5 +1,7 @@
--TEST--
Test date_sunrise() function : usage variation - Checking with North and South poles when Sun is up and down all day
--INI--
error_reporting=E_ALL&~E_DEPRECATED
--FILE--
<?php
echo "*** Testing date_sunrise() : usage variation ***\n";

View File

@@ -1,5 +1,7 @@
--TEST--
Test date_sunset() function : usage variation - Checking sunrise for consecutive days in specific timezone
--INI--
error_reporting=E_ALL&~E_DEPRECATED
--FILE--
<?php
echo "*** Testing date_sunset() : usage variation ***\n";

View File

@@ -1,5 +1,7 @@
--TEST--
Test date_sunset() function : usage variation - Checking with North and South poles when Sun is up and down all day
--INI--
error_reporting=E_ALL&~E_DEPRECATED
--FILE--
<?php
echo "*** Testing date_sunset() : usage variation ***\n";

View File

@@ -2,6 +2,7 @@
date_sunrise() and date_sunset() functions
--INI--
precision=13
error_reporting=E_ALL&~E_DEPRECATED
--FILE--
<?php
date_default_timezone_set('Asia/Jerusalem');