summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-01-30 12:53:08 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-01-30 13:13:47 +0100
commit5a2787a02d56003e2e9731e2fad5b468180ec19a (patch)
tree88d29d694a491a0998e5cc1bb041f17b546ffc72
parent94ae35c9fbc34b26c514b2ba097e021744100f28 (diff)
downloadphp-git-5a2787a02d56003e2e9731e2fad5b468180ec19a.tar.gz
Require at least one arg for mktime/gmmktime
-rw-r--r--UPGRADING4
-rw-r--r--ext/date/php_date.c17
-rw-r--r--ext/date/tests/gmmktime_basic.phpt4
-rw-r--r--ext/date/tests/mktime_error.phpt4
4 files changed, 15 insertions, 14 deletions
diff --git a/UPGRADING b/UPGRADING
index 45a1780b32..85da44d04f 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -34,6 +34,10 @@ PHP 8.0 UPGRADE NOTES
. Removed ability to unbind $this from closures that were created from a
method, using Closure::fromCallable() or ReflectionMethod::getClosure().
+- Date:
+ . mktime() and gmmktime() now require at least one argument. time() can be
+ used to get the current timestamp.
+
- Filter:
. The FILTER_FLAG_SCHEME_REQUIRED and FILTER_FLAG_HOST_REQUIRED flags for the
FILTER_VALIDATE_URL filter have been removed. The scheme and host are (and
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 9d6cb5ffa3..2249adb12d 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -81,7 +81,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_strtotime, 0, 0, 1)
ZEND_ARG_INFO(0, now)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mktime, 0, 0, 0)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_mktime, 0, 0, 1)
ZEND_ARG_INFO(0, hour)
ZEND_ARG_INFO(0, min)
ZEND_ARG_INFO(0, sec)
@@ -90,7 +90,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_mktime, 0, 0, 0)
ZEND_ARG_INFO(0, year)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_gmmktime, 0, 0, 0)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_gmmktime, 0, 0, 1)
ZEND_ARG_INFO(0, hour)
ZEND_ARG_INFO(0, min)
ZEND_ARG_INFO(0, sec)
@@ -1531,9 +1531,9 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
zend_long ts, adjust_seconds = 0;
int error;
- ZEND_PARSE_PARAMETERS_START(0, 6)
- Z_PARAM_OPTIONAL
+ ZEND_PARSE_PARAMETERS_START(1, 6)
Z_PARAM_LONG(hou)
+ Z_PARAM_OPTIONAL
Z_PARAM_LONG(min)
Z_PARAM_LONG(sec)
Z_PARAM_LONG(mon)
@@ -1553,8 +1553,6 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
}
/* Fill in the new data */
switch (ZEND_NUM_ARGS()) {
- case 7:
- /* break intentionally missing */
case 6:
if (yea >= 0 && yea < 70) {
yea += 2000;
@@ -1578,8 +1576,7 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
case 1:
now->h = hou;
break;
- default:
- php_error_docref(NULL, E_DEPRECATED, "You should be using the time() function instead");
+ EMPTY_SWITCH_DEFAULT_CASE()
}
/* Update the timestamp */
if (gmt) {
@@ -1601,7 +1598,7 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
}
/* }}} */
-/* {{{ proto int mktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
+/* {{{ proto int mktime(int hour [, int min [, int sec [, int mon [, int day [, int year]]]]])
Get UNIX timestamp for a date */
PHP_FUNCTION(mktime)
{
@@ -1609,7 +1606,7 @@ PHP_FUNCTION(mktime)
}
/* }}} */
-/* {{{ proto int gmmktime([int hour [, int min [, int sec [, int mon [, int day [, int year]]]]]])
+/* {{{ proto int gmmktime(int hour [, int min [, int sec [, int mon [, int day [, int year]]]]])
Get UNIX timestamp for a GMT date */
PHP_FUNCTION(gmmktime)
{
diff --git a/ext/date/tests/gmmktime_basic.phpt b/ext/date/tests/gmmktime_basic.phpt
index cdb44f0c62..c125e353c4 100644
--- a/ext/date/tests/gmmktime_basic.phpt
+++ b/ext/date/tests/gmmktime_basic.phpt
@@ -30,6 +30,6 @@ var_dump( gmmktime() );
*** Testing gmmktime() : basic functionality ***
int(1218182888)
-Deprecated: gmmktime(): You should be using the time() function instead in %s on line %d
-int(%d)
+Warning: gmmktime() expects at least 1 parameter, 0 given in %s on line %d
+bool(false)
===DONE===
diff --git a/ext/date/tests/mktime_error.phpt b/ext/date/tests/mktime_error.phpt
index a24d189fb1..02e94a7d4d 100644
--- a/ext/date/tests/mktime_error.phpt
+++ b/ext/date/tests/mktime_error.phpt
@@ -33,8 +33,8 @@ var_dump( mktime($hour, $minute, $sec, $month, $day, $year, $extra_arg) );
-- Testing mktime() function with Zero arguments --
-Deprecated: mktime(): You should be using the time() function instead in %s on line %d
-int(%d)
+Warning: mktime() expects at least 1 parameter, 0 given in %s on line %d
+bool(false)
-- Testing mktime() function with more than expected no. of arguments --