]> granicus.if.org Git - php/commitdiff
Use new param API in date
authorSara Golemon <pollita@php.net>
Wed, 28 Dec 2016 17:44:20 +0000 (09:44 -0800)
committerSara Golemon <pollita@php.net>
Wed, 28 Dec 2016 18:04:35 +0000 (10:04 -0800)
Left the zend_parse_parameters_throw() uses along because
throwing isn't currently supported by the new API.
Also left the complex parsing in DatePeriod::__construct alone
because the macros don't really stack all that well.

ext/date/php_date.c

index cbe6e91347ceb8c4efd29e2e99ce8cbf182ec020..5120df13f747c60f2f0cae9742b81913848133cf 100644 (file)
@@ -1241,18 +1241,20 @@ static zend_string *date_format(char *format, size_t format_len, timelib_time *t
 
 static void php_date(INTERNAL_FUNCTION_PARAMETERS, int localtime)
 {
-       char   *format;
-       size_t     format_len;
+       zend_string *format;
        zend_long    ts;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &format, &format_len, &ts) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_STR(format)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(ts)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
+
        if (ZEND_NUM_ARGS() == 1) {
                ts = time(NULL);
        }
 
-       RETURN_STR(php_format_date(format, format_len, ts, localtime));
+       RETURN_STR(php_format_date(ZSTR_VAL(format), ZSTR_LEN(format), ts, localtime));
 }
 /* }}} */
 
@@ -1397,16 +1399,17 @@ PHP_FUNCTION(gmdate)
    Format a local time/date as integer */
 PHP_FUNCTION(idate)
 {
-       char   *format;
-       size_t     format_len;
+       zend_string *format;
        zend_long    ts = 0;
        int ret;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &format, &format_len, &ts) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_STR(format)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(ts)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
-       if (format_len != 1) {
+       if (ZSTR_LEN(format) != 1) {
                php_error_docref(NULL, E_WARNING, "idate format is one char");
                RETURN_FALSE;
        }
@@ -1415,7 +1418,7 @@ PHP_FUNCTION(idate)
                ts = time(NULL);
        }
 
-       ret = php_idate(format[0], ts, 0);
+       ret = php_idate(ZSTR_VAL(format)[0], ts, 0);
        if (ret == -1) {
                php_error_docref(NULL, E_WARNING, "Unrecognized date format token.");
                RETURN_FALSE;
@@ -1465,17 +1468,18 @@ PHPAPI zend_long php_parse_date(char *string, zend_long *now)
    Convert string representation of date and time to a timestamp */
 PHP_FUNCTION(strtotime)
 {
-       char *times;
-       size_t   time_len;
+       zend_string *times;
        int error1, error2;
        struct timelib_error_container *error;
        zend_long preset_ts = 0, ts;
        timelib_time *t, *now;
        timelib_tzinfo *tzi;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &times, &time_len, &preset_ts) == FAILURE || !time_len) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_STR(times)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(preset_ts)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        tzi = get_timezone_info();
 
@@ -1485,7 +1489,8 @@ PHP_FUNCTION(strtotime)
        timelib_unixtime2local(now,
                (ZEND_NUM_ARGS() == 2) ? (timelib_sll) preset_ts : (timelib_sll) time(NULL));
 
-       t = timelib_strtotime(times, time_len, &error, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
+       t = timelib_strtotime(ZSTR_VAL(times), ZSTR_LEN(times), &error,
+               DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
        error1 = error->error_count;
        timelib_error_container_dtor(error);
        timelib_fill_holes(t, now, TIMELIB_NO_CLONE);
@@ -1512,9 +1517,16 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
        zend_long ts, adjust_seconds = 0;
        int error;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|llllll", &hou, &min, &sec, &mon, &day, &yea) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(0, 6)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(hou)
+               Z_PARAM_LONG(min)
+               Z_PARAM_LONG(sec)
+               Z_PARAM_LONG(mon)
+               Z_PARAM_LONG(day)
+               Z_PARAM_LONG(yea)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
+
        /* Initialize structure with current time */
        now = timelib_time_ctor();
        if (gmt) {
@@ -1597,9 +1609,11 @@ PHP_FUNCTION(checkdate)
 {
        zend_long m, d, y;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "lll", &m, &d, &y) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(3, 3)
+               Z_PARAM_LONG(m)
+               Z_PARAM_LONG(d)
+               Z_PARAM_LONG(y)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        if (y < 1 || y > 32767 || !timelib_valid_date(y, m, d)) {
                RETURN_FALSE;
@@ -1612,9 +1626,8 @@ PHP_FUNCTION(checkdate)
 /* {{{ php_strftime - (gm)strftime helper */
 PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
 {
-       char                *format;
-       size_t                  format_len;
-       zend_long                 timestamp = 0;
+       zend_string         *format;
+       zend_long            timestamp = 0;
        struct tm            ta;
        int                  max_reallocs = 5;
        size_t               buf_len = 256, real_len;
@@ -1625,11 +1638,13 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
 
        timestamp = (zend_long) time(NULL);
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &format, &format_len, &timestamp) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 2)
+               Z_PARAM_STR(format)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(timestamp)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
-       if (format_len == 0) {
+       if (ZSTR_LEN(format) == 0) {
                RETURN_FALSE;
        }
 
@@ -1675,7 +1690,7 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
           initial buffer is too small. See
           http://connect.microsoft.com/VisualStudio/feedback/details/759720/vs2012-strftime-crash-with-z-formatting-code */
        buf = zend_string_alloc(buf_len, 0);
-       while ((real_len = strftime(ZSTR_VAL(buf), buf_len, format, &ta)) == buf_len || real_len == 0) {
+       while ((real_len = strftime(ZSTR_VAL(buf), buf_len, ZSTR_VAL(format), &ta)) == buf_len || real_len == 0) {
                buf_len *= 2;
                buf = zend_string_extend(buf, buf_len, 0);
                if (!--max_reallocs) {
@@ -1738,9 +1753,11 @@ PHP_FUNCTION(localtime)
        timelib_tzinfo *tzi;
        timelib_time   *ts;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lb", &timestamp, &associative) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(0, 2)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(timestamp)
+               Z_PARAM_BOOL(associative)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        tzi = get_timezone_info();
        ts = timelib_time_ctor();
@@ -1784,9 +1801,10 @@ PHP_FUNCTION(getdate)
        timelib_tzinfo *tzi;
        timelib_time   *ts;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &timestamp) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(0, 1)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(timestamp)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        tzi = get_timezone_info();
        ts = timelib_time_ctor();
@@ -2655,9 +2673,11 @@ PHP_FUNCTION(date_create)
        char           *time_str = NULL;
        size_t          time_str_len = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|sO!", &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(0, 2)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_STRING(time_str, time_str_len)
+               Z_PARAM_OBJECT_OF_CLASS_EX(timezone_object, date_ce_timezone, 1, 0)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        php_date_instantiate(date_ce_date, return_value);
        if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, NULL, timezone_object, 0)) {
@@ -2676,9 +2696,11 @@ PHP_FUNCTION(date_create_immutable)
        char           *time_str = NULL;
        size_t          time_str_len = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|sO!", &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(0, 2)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_STRING(time_str, time_str_len)
+               Z_PARAM_OBJECT_OF_CLASS_EX(timezone_object, date_ce_timezone, 1, 0)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        php_date_instantiate(date_ce_immutable, return_value);
        if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, NULL, timezone_object, 0)) {
@@ -2695,11 +2717,14 @@ PHP_FUNCTION(date_create_from_format)
 {
        zval           *timezone_object = NULL;
        char           *time_str = NULL, *format_str = NULL;
-       size_t             time_str_len = 0, format_str_len = 0;
+       size_t          time_str_len = 0, format_str_len = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|O!", &format_str, &format_str_len, &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 3)
+               Z_PARAM_STRING(format_str, format_str_len)
+               Z_PARAM_STRING(time_str, time_str_len)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_OBJECT_OF_CLASS_EX(timezone_object, date_ce_timezone, 1, 0)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        php_date_instantiate(date_ce_date, return_value);
        if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, format_str, timezone_object, 0)) {
@@ -2718,9 +2743,12 @@ PHP_FUNCTION(date_create_immutable_from_format)
        char           *time_str = NULL, *format_str = NULL;
        size_t          time_str_len = 0, format_str_len = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|O!", &format_str, &format_str_len, &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 3)
+               Z_PARAM_STRING(format_str, format_str_len)
+               Z_PARAM_STRING(time_str, time_str_len)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_OBJECT_OF_CLASS_EX(timezone_object, date_ce_timezone, 1, 0)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        php_date_instantiate(date_ce_immutable, return_value);
        if (!php_date_initialize(Z_PHPDATE_P(return_value), time_str, time_str_len, format_str, timezone_object, 0)) {
@@ -2779,9 +2807,9 @@ PHP_METHOD(DateTimeImmutable, createFromMutable)
        php_date_obj *new_obj = NULL;
        php_date_obj *old_obj = NULL;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &datetime_object, date_ce_date) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_OBJECT_OF_CLASS(datetime_object, date_ce_date)
+       ZEND_PARSE_PARAMETERS_END();
 
        php_date_instantiate(date_ce_immutable, return_value);
        old_obj = Z_PHPDATE_P(datetime_object);
@@ -2857,9 +2885,9 @@ PHP_METHOD(DateTime, __set_state)
        zval             *array;
        HashTable        *myht;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "a", &array) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_ARRAY(array)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        myht = Z_ARRVAL_P(array);
 
@@ -2879,9 +2907,9 @@ PHP_METHOD(DateTimeImmutable, __set_state)
        zval             *array;
        HashTable        *myht;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "a", &array) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_ARRAY(array)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        myht = Z_ARRVAL_P(array);
 
@@ -3025,16 +3053,15 @@ void php_date_do_return_parsed_time(INTERNAL_FUNCTION_PARAMETERS, timelib_time *
 */
 PHP_FUNCTION(date_parse)
 {
-       char                           *date;
-       size_t                          date_len;
+       zend_string                    *date;
        struct timelib_error_container *error;
        timelib_time                   *parsed_time;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &date, &date_len) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_STR(date)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
-       parsed_time = timelib_strtotime(date, date_len, &error, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
+       parsed_time = timelib_strtotime(ZSTR_VAL(date), ZSTR_LEN(date), &error, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
        php_date_do_return_parsed_time(INTERNAL_FUNCTION_PARAM_PASSTHRU, parsed_time, error);
 }
 /* }}} */
@@ -3044,16 +3071,16 @@ PHP_FUNCTION(date_parse)
 */
 PHP_FUNCTION(date_parse_from_format)
 {
-       char                           *date, *format;
-       size_t                          date_len, format_len;
+       zend_string                    *date, *format;
        struct timelib_error_container *error;
        timelib_time                   *parsed_time;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &format, &format_len, &date, &date_len) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(2, 2)
+               Z_PARAM_STR(format)
+               Z_PARAM_STR(date)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
-       parsed_time = timelib_parse_from_format(format, date, date_len, &error, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
+       parsed_time = timelib_parse_from_format(ZSTR_VAL(format), ZSTR_VAL(date), ZSTR_LEN(date), &error, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
        php_date_do_return_parsed_time(INTERNAL_FUNCTION_PARAM_PASSTHRU, parsed_time, error);
 }
 /* }}} */
@@ -3720,15 +3747,15 @@ static int timezone_initialize(php_timezone_obj *tzobj, /*const*/ char *tz, size
 */
 PHP_FUNCTION(timezone_open)
 {
-       char *tz;
-       size_t tz_len;
+       zend_string *tz;
        php_timezone_obj *tzobj;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &tz, &tz_len) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_STR(tz)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
+
        tzobj = Z_PHPTIMEZONE_P(php_date_instantiate(date_ce_timezone, return_value));
-       if (SUCCESS != timezone_initialize(tzobj, tz, tz_len)) {
+       if (SUCCESS != timezone_initialize(tzobj, ZSTR_VAL(tz), ZSTR_LEN(tz))) {
                zval_ptr_dtor(return_value);
                RETURN_FALSE;
        }
@@ -3785,9 +3812,9 @@ PHP_METHOD(DateTimeZone, __set_state)
        zval             *array;
        HashTable        *myht;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "a", &array) == FAILURE) {
-               return;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_ARRAY(array)
+       ZEND_PARSE_PARAMETERS_END();
 
        myht = Z_ARRVAL_P(array);
 
@@ -3860,16 +3887,19 @@ PHP_FUNCTION(timezone_name_get)
 */
 PHP_FUNCTION(timezone_name_from_abbr)
 {
-       char    *abbr;
-       char    *tzid;
-       size_t      abbr_len;
+       zend_string  *abbr;
+       char         *tzid;
        zend_long     gmtoffset = -1;
        zend_long     isdst = -1;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|ll", &abbr, &abbr_len, &gmtoffset, &isdst) == FAILURE) {
-               RETURN_FALSE;
-       }
-       tzid = timelib_timezone_id_from_abbr(abbr, gmtoffset, isdst);
+       ZEND_PARSE_PARAMETERS_START(1, 3)
+               Z_PARAM_STR(abbr)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(gmtoffset)
+               Z_PARAM_LONG(isdst)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
+
+       tzid = timelib_timezone_id_from_abbr(ZSTR_VAL(abbr), gmtoffset, isdst);
 
        if (tzid) {
                RETURN_STRING(tzid);
@@ -4270,9 +4300,9 @@ PHP_METHOD(DateInterval, __set_state)
        zval             *array;
        HashTable        *myht;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "a", &array) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_ARRAY(array)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        myht = Z_ARRVAL_P(array);
 
@@ -4303,19 +4333,18 @@ PHP_METHOD(DateInterval, __wakeup)
 */
 PHP_FUNCTION(date_interval_create_from_date_string)
 {
-       char           *time_str = NULL;
-       size_t          time_str_len = 0;
+       zend_string    *time_str = NULL;
        timelib_time   *time;
        timelib_error_container *err = NULL;
        php_interval_obj *diobj;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &time_str, &time_str_len) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_STR(time_str)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        php_date_instantiate(date_ce_interval, return_value);
 
-       time = timelib_strtotime(time_str, time_str_len, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
+       time = timelib_strtotime(ZSTR_VAL(time_str), ZSTR_LEN(time_str), &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
        diobj = Z_PHPINTERVAL_P(return_value);
        diobj->diff = timelib_rel_time_clone(&time->relative);
        diobj->initialized = 1;
@@ -4633,9 +4662,11 @@ PHP_FUNCTION(timezone_identifiers_list)
        char                           *option = NULL;
        size_t                             option_len = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ls", &what, &option, &option_len) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(0, 2)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(what)
+               Z_PARAM_STRING(option, option_len)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        /* Extra validation */
        if (what == PHP_DATE_TIMEZONE_PER_COUNTRY && option_len != 2) {
@@ -4715,9 +4746,10 @@ PHP_FUNCTION(date_default_timezone_set)
        char *zone;
        size_t   zone_len;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &zone, &zone_len) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_STRING(zone, zone_len)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
+
        if (!timelib_timezone_id_is_valid(zone, DATE_TIMEZONEDB)) {
                php_error_docref(NULL, E_NOTICE, "Timezone ID '%s' is invalid", zone);
                RETURN_FALSE;
@@ -4756,9 +4788,15 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, int calc_su
        timelib_tzinfo *tzi;
        zend_string    *retstr;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|ldddd", &time, &retformat, &latitude, &longitude, &zenith, &gmt_offset) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 6)
+               Z_PARAM_LONG(time)
+               Z_PARAM_OPTIONAL
+               Z_PARAM_LONG(retformat)
+               Z_PARAM_DOUBLE(latitude)
+               Z_PARAM_DOUBLE(longitude)
+               Z_PARAM_DOUBLE(zenith)
+               Z_PARAM_DOUBLE(gmt_offset)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        switch (ZEND_NUM_ARGS()) {
                case 1:
@@ -4858,9 +4896,12 @@ PHP_FUNCTION(date_sun_info)
        int             dummy;
        double          ddummy;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "ldd", &time, &latitude, &longitude) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(3, 3)
+               Z_PARAM_LONG(time)
+               Z_PARAM_DOUBLE(latitude)
+               Z_PARAM_DOUBLE(longitude)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
+
        /* Initialize time struct */
        t = timelib_time_ctor();
        tzi = get_timezone_info();
@@ -5110,9 +5151,9 @@ PHP_METHOD(DatePeriod, __set_state)
        zval             *array;
        HashTable        *myht;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "a", &array) == FAILURE) {
-               RETURN_FALSE;
-       }
+       ZEND_PARSE_PARAMETERS_START(1, 1)
+               Z_PARAM_ARRAY(array)
+       ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
 
        myht = Z_ARRVAL_P(array);