From d3fb0f0bdb9f48ea79f4fe857443a128b0894ebd Mon Sep 17 00:00:00 2001 From: Kharhamel Date: Mon, 29 Aug 2022 09:28:02 +0200 Subject: [PATCH] deprecated mktime and regenerated the files --- deprecated/datetime.php | 62 ++++++++++++++ deprecated/functionsList.php | 1 + generated/datetime.php | 152 +++++++++++++++++------------------ generated/functionsList.php | 1 - rector-migrate.php | 1 - 5 files changed, 135 insertions(+), 82 deletions(-) diff --git a/deprecated/datetime.php b/deprecated/datetime.php index 1bcb3227..012b0f7c 100644 --- a/deprecated/datetime.php +++ b/deprecated/datetime.php @@ -34,3 +34,65 @@ function gmdate(string $format, int $timestamp = null): string } return $result; } + +/** + * Returns the Unix timestamp corresponding to the arguments + * given. This timestamp is a long integer containing the number of + * seconds between the Unix Epoch (January 1 1970 00:00:00 GMT) and the time + * specified. + * + * Arguments may be left out in order from right to left; any + * arguments thus omitted will be set to the current value according + * to the local date and time. + * + * @param int $hour The number of the hour relative to the start of the day determined by + * month, day and year. + * Negative values reference the hour before midnight of the day in question. + * Values greater than 23 reference the appropriate hour in the following day(s). + * @param int $minute The number of the minute relative to the start of the hour. + * Negative values reference the minute in the previous hour. + * Values greater than 59 reference the appropriate minute in the following hour(s). + * @param int $second The number of seconds relative to the start of the minute. + * Negative values reference the second in the previous minute. + * Values greater than 59 reference the appropriate second in the following minute(s). + * @param int $month The number of the month relative to the end of the previous year. + * Values 1 to 12 reference the normal calendar months of the year in question. + * Values less than 1 (including negative values) reference the months in the previous year in reverse order, so 0 is December, -1 is November, etc. + * Values greater than 12 reference the appropriate month in the following year(s). + * @param int $day The number of the day relative to the end of the previous month. + * Values 1 to 28, 29, 30 or 31 (depending upon the month) reference the normal days in the relevant month. + * Values less than 1 (including negative values) reference the days in the previous month, so 0 is the last day of the previous month, -1 is the day before that, etc. + * Values greater than the number of days in the relevant month reference the appropriate day in the following month(s). + * @param int $year The number of the year, may be a two or four digit value, + * with values between 0-69 mapping to 2000-2069 and 70-100 to + * 1970-2000. On systems where time_t is a 32bit signed integer, as + * most common today, the valid range for year + * is somewhere between 1901 and 2038. + * @return int mktime returns the Unix timestamp of the arguments + * given. + * If the arguments are invalid, the function returns FALSE. + * @throws DatetimeException + * @deprecated The Safe version of this function is no longer needed in PHP 8.0+ + * + */ +function mktime(int $hour, int $minute = null, int $second = null, int $month = null, int $day = null, int $year = null): int +{ + error_clear_last(); + if ($year !== null) { + $safeResult = \mktime($hour, $minute, $second, $month, $day, $year); + } elseif ($day !== null) { + $safeResult = \mktime($hour, $minute, $second, $month, $day); + } elseif ($month !== null) { + $safeResult = \mktime($hour, $minute, $second, $month); + } elseif ($second !== null) { + $safeResult = \mktime($hour, $minute, $second); + } elseif ($minute !== null) { + $safeResult = \mktime($hour, $minute); + } else { + $safeResult = \mktime($hour); + } + if ($safeResult === false) { + throw DatetimeException::createFromPhpError(); + } + return $safeResult; +} diff --git a/deprecated/functionsList.php b/deprecated/functionsList.php index b75d7abb..e2088910 100644 --- a/deprecated/functionsList.php +++ b/deprecated/functionsList.php @@ -43,6 +43,7 @@ 'imagepsslantfont', 'krsort', 'ksort', + 'mktime', 'mssql_bind', 'mssql_close', 'mssql_connect', diff --git a/generated/datetime.php b/generated/datetime.php index 25206709..1f45b553 100644 --- a/generated/datetime.php +++ b/generated/datetime.php @@ -7,9 +7,39 @@ /** * Returns associative array with detailed info about given date/time. * - * @param string $format Format accepted by DateTime::createFromFormat. + * @param string $format Format accepted by DateTimeImmutable::createFromFormat. * @param string $datetime String representing the date/time. * @return array{year: int|false, month: int|false, day: int|false, hour: int|false, minute: int|false, second: int|false, fraction: float|false, warning_count: int, warnings: string[], error_count: int, errors: string[], is_localtime: bool, zone_type: int|bool, zone: int|bool, is_dst: bool, tz_abbr: string, tz_id: string, relative: array{year: int, month: int, day: int, hour: int, minute: int, second: int, weekday: int, weekdays: int, first_day_of_month: bool, last_day_of_month: bool}}|null Returns associative array with detailed info about given date/time. + * + * The returned array has keys for year, + * month, day, hour, + * minute, second, + * fraction, and is_localtime. + * + * If is_localtime is present then + * zone_type indicates the type of timezone. For type + * 1 (UTC offset) the zone, + * is_dst fields are added; for type 2 + * (abbreviation) the fields tz_abbr, + * is_dst are added; and for type 3 + * (timezone identifier) the tz_abbr, + * tz_id are added. + * + * The array includes warning_count and + * warnings fields. The first one indicate how many + * warnings there were. + * The keys of elements warnings array indicate the + * position in the given datetime where the warning + * occurred, with the string value describing the warning itself. An example + * below shows such a warning. + * + * The array also contains error_count and + * errors fields. The first one indicate how many errors + * were found. + * The keys of elements errors array indicate the + * position in the given datetime where the error + * occurred, with the string value describing the error itself. An example + * below shows such an error. * @throws DatetimeException * */ @@ -45,6 +75,43 @@ function date_parse_from_format(string $format, string $datetime): ?array * DateTimeImmutable::__construct. * @return array{year: int|false, month: int|false, day: int|false, hour: int|false, minute: int|false, second: int|false, fraction: float|false, warning_count: int, warnings: string[], error_count: int, errors: string[], is_localtime: bool, zone_type: int|bool, zone: int|bool, is_dst: bool, tz_abbr: string, tz_id: string, relative: array{year: int, month: int, day: int, hour: int, minute: int, second: int, weekday: int, weekdays: int, first_day_of_month: bool, last_day_of_month: bool}}|null Returns array with information about the parsed date/time * on success. + * + * The returned array has keys for year, + * month, day, hour, + * minute, second, + * fraction, and is_localtime. + * + * If is_localtime is present then + * zone_type indicates the type of timezone. For type + * 1 (UTC offset) the zone, + * is_dst fields are added; for type 2 + * (abbreviation) the fields tz_abbr, + * is_dst are added; and for type 3 + * (timezone identifier) the tz_abbr, + * tz_id are added. + * + * If relative time elements are present in the + * datetime string such as +3 days, + * the then returned array includes a nested array with the key + * relative. This array then contains the keys + * year, month, day, + * hour, minute, + * second, and if necessary weekday, and + * weekdays, depending on the string that was passed in. + * + * The array includes warning_count and + * warnings fields. The first one indicate how many + * warnings there were. + * The keys of elements warnings array indicate the + * position in the given datetime where the warning + * occurred, with the string value describing the warning itself. + * + * The array also contains error_count and + * errors fields. The first one indicate how many errors + * were found. + * The keys of elements errors array indicate the + * position in the given datetime where the error + * occurred, with the string value describing the error itself. * @throws DatetimeException * */ @@ -98,7 +165,8 @@ function date_parse(string $datetime): ?array * civil_twilight_begin * * - * The start of the civil dawn (zenith angle = 96°). It ends at sunrise. + * The start of the civil dawn (zenith angle = 96°). It ends at + * sunrise. * * * @@ -106,7 +174,8 @@ function date_parse(string $datetime): ?array * civil_twilight_end * * - * The end of the civil dusk (zenith angle = 96°). It starts at sunset. + * The end of the civil dusk (zenith angle = 96°). It starts at + * sunset. * * * @@ -377,11 +446,6 @@ function date_sunset(int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, fl * if no timestamp is given. In other words, timestamp * is optional and defaults to the value of time. * - * Unix timestamps do not handle timezones. Use the - * DateTimeImmutable class, and its - * DateTimeInterface::format formatting method to - * format date/time information with a timezone attached. - * * @param string $format Format accepted by DateTimeInterface::format. * @param int $timestamp The optional timestamp parameter is an * int Unix timestamp that defaults to the current @@ -630,83 +694,11 @@ function idate(string $format, int $timestamp = null): int } -/** - * Returns the Unix timestamp corresponding to the arguments - * given. This timestamp is a long integer containing the number of - * seconds between the Unix Epoch (January 1 1970 00:00:00 GMT) and the time - * specified. - * - * Arguments may be left out in order from right to left; any - * arguments thus omitted will be set to the current value according - * to the local date and time. - * - * @param int $hour The number of the hour relative to the start of the day determined by - * month, day and year. - * Negative values reference the hour before midnight of the day in question. - * Values greater than 23 reference the appropriate hour in the following day(s). - * @param int $minute The number of the minute relative to the start of the hour. - * Negative values reference the minute in the previous hour. - * Values greater than 59 reference the appropriate minute in the following hour(s). - * @param int $second The number of seconds relative to the start of the minute. - * Negative values reference the second in the previous minute. - * Values greater than 59 reference the appropriate second in the following minute(s). - * @param int $month The number of the month relative to the end of the previous year. - * Values 1 to 12 reference the normal calendar months of the year in question. - * Values less than 1 (including negative values) reference the months in the previous year in reverse order, so 0 is December, -1 is November, etc. - * Values greater than 12 reference the appropriate month in the following year(s). - * @param int $day The number of the day relative to the end of the previous month. - * Values 1 to 28, 29, 30 or 31 (depending upon the month) reference the normal days in the relevant month. - * Values less than 1 (including negative values) reference the days in the previous month, so 0 is the last day of the previous month, -1 is the day before that, etc. - * Values greater than the number of days in the relevant month reference the appropriate day in the following month(s). - * @param int $year The number of the year, may be a two or four digit value, - * with values between 0-69 mapping to 2000-2069 and 70-100 to - * 1970-2000. On systems where time_t is a 32bit signed integer, as - * most common today, the valid range for year - * is somewhere between 1901 and 2038. - * @return int mktime returns the Unix timestamp of the arguments - * given. - * If the arguments are invalid, the function returns FALSE. - * @throws DatetimeException - * - */ -function mktime(int $hour, int $minute = null, int $second = null, int $month = null, int $day = null, int $year = null): int -{ - error_clear_last(); - if ($year !== null) { - $safeResult = \mktime($hour, $minute, $second, $month, $day, $year); - } elseif ($day !== null) { - $safeResult = \mktime($hour, $minute, $second, $month, $day); - } elseif ($month !== null) { - $safeResult = \mktime($hour, $minute, $second, $month); - } elseif ($second !== null) { - $safeResult = \mktime($hour, $minute, $second); - } elseif ($minute !== null) { - $safeResult = \mktime($hour, $minute); - } else { - $safeResult = \mktime($hour); - } - if ($safeResult === false) { - throw DatetimeException::createFromPhpError(); - } - return $safeResult; -} - - /** * Format the time and/or date according to locale settings. Month and weekday * names and other language-dependent strings respect the current locale set * with setlocale. * - * Not all conversion specifiers may be supported by your C library, in which - * case they will not be supported by PHP's strftime. - * Additionally, not all platforms support negative timestamps, so your - * date range may be limited to no earlier than the Unix epoch. This means that - * %e, %T, %R and, %D (and possibly others) - as well as dates prior to - * Jan 1, 1970 - will not work on Windows, some Linux - * distributions, and a few other operating systems. For Windows systems, a - * complete overview of supported conversion specifiers can be found at - * MSDN. - * * @param string $format * The following characters are recognized in the * format parameter string diff --git a/generated/functionsList.php b/generated/functionsList.php index 536f1a8a..60fbea9a 100644 --- a/generated/functionsList.php +++ b/generated/functionsList.php @@ -520,7 +520,6 @@ 'md5_file', 'mime_content_type', 'mkdir', - 'mktime', 'msg_get_queue', 'msg_queue_exists', 'msg_receive', diff --git a/rector-migrate.php b/rector-migrate.php index fd38eb91..a7c7b475 100644 --- a/rector-migrate.php +++ b/rector-migrate.php @@ -527,7 +527,6 @@ 'md5_file' => 'Safe\md5_file', 'mime_content_type' => 'Safe\mime_content_type', 'mkdir' => 'Safe\mkdir', - 'mktime' => 'Safe\mktime', 'msg_get_queue' => 'Safe\msg_get_queue', 'msg_queue_exists' => 'Safe\msg_queue_exists', 'msg_receive' => 'Safe\msg_receive',