diff options
| author | Florian MARGAINE <florian@margaine.com> | 2014-09-22 23:35:29 +0200 |
|---|---|---|
| committer | Derick Rethans <github@derickrethans.nl> | 2014-10-04 15:58:24 +0100 |
| commit | 046c345de508dff769cfcf4a448a4a5a4f009294 (patch) | |
| tree | 93660c239af0386ad284d2f015cb4684a09e0bb9 | |
| parent | 0407bdf252004cce08e383bc0f4aa0bbc69c9a25 (diff) | |
| download | php-git-046c345de508dff769cfcf4a448a4a5a4f009294.tar.gz | |
DateTimeZone::getOffset() now accepts a DateTimeInterface
Fixes #68062
| -rw-r--r-- | ext/date/php_date.c | 8 | ||||
| -rw-r--r-- | ext/date/tests/68062.phpt | 13 | ||||
| -rw-r--r-- | ext/date/tests/DateTimeZone_getOffset_variation1.phpt | 56 | ||||
| -rw-r--r-- | ext/date/tests/timezone_offset_get_error.phpt | 6 | ||||
| -rw-r--r-- | ext/date/tests/timezone_offset_get_variation2.phpt | 56 |
5 files changed, 76 insertions, 63 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 92e9480a43..bbfd9b61f6 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -326,7 +326,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_offset_get, 0, 0, 2) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_method_offset_get, 0, 0, 1) - ZEND_ARG_INFO(0, datetime) + ZEND_ARG_INFO(0, object) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_transitions_get, 0, 0, 1) @@ -3341,7 +3341,7 @@ PHP_FUNCTION(timezone_name_from_abbr) } /* }}} */ -/* {{{ proto long timezone_offset_get(DateTimeZone object, DateTime object) +/* {{{ proto long timezone_offset_get(DateTimeZone object, DateTimeInterface object) Returns the timezone offset. */ PHP_FUNCTION(timezone_offset_get) @@ -3351,13 +3351,13 @@ PHP_FUNCTION(timezone_offset_get) php_date_obj *dateobj; timelib_time_offset *offset; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_timezone, &dateobject, date_ce_date) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_timezone, &dateobject, date_ce_interface) == FAILURE) { RETURN_FALSE; } tzobj = (php_timezone_obj *) zend_object_store_get_object(object TSRMLS_CC); DATE_CHECK_INITIALIZED(tzobj->initialized, DateTimeZone); dateobj = (php_date_obj *) zend_object_store_get_object(dateobject TSRMLS_CC); - DATE_CHECK_INITIALIZED(dateobj->time, DateTime); + DATE_CHECK_INITIALIZED(dateobj->time, DateTimeInterface); switch (tzobj->type) { case TIMELIB_ZONETYPE_ID: diff --git a/ext/date/tests/68062.phpt b/ext/date/tests/68062.phpt new file mode 100644 index 0000000000..ce2105abae --- /dev/null +++ b/ext/date/tests/68062.phpt @@ -0,0 +1,13 @@ +--TEST-- +DateTimeZone::getOffset() accepts a DateTimeInterface object +--FILE-- +<?php + +$tz = new DateTimeZone('Europe/London'); +$dt = new DateTimeImmutable('2014-09-20', $tz); + +echo $tz->getOffset($dt); +echo $tz->getOffset(1); +--EXPECTF-- +3600 +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, integer given in %s diff --git a/ext/date/tests/DateTimeZone_getOffset_variation1.phpt b/ext/date/tests/DateTimeZone_getOffset_variation1.phpt index a86d5e10bb..ecd99d5bc3 100644 --- a/ext/date/tests/DateTimeZone_getOffset_variation1.phpt +++ b/ext/date/tests/DateTimeZone_getOffset_variation1.phpt @@ -112,141 +112,141 @@ fclose( $file_handle ); -- int 0 -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, integer given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d bool(false) -- int 1 -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, integer given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d bool(false) -- int 12345 -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, integer given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d bool(false) -- int -12345 -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, integer given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d bool(false) -- float 10.5 -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, double given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, double given in %s on line %d bool(false) -- float -10.5 -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, double given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, double given in %s on line %d bool(false) -- float .5 -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, double given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, double given in %s on line %d bool(false) -- empty array -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, array given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, array given in %s on line %d bool(false) -- int indexed array -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, array given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, array given in %s on line %d bool(false) -- associative array -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, array given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, array given in %s on line %d bool(false) -- nested arrays -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, array given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, array given in %s on line %d bool(false) -- uppercase NULL -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, null given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given in %s on line %d bool(false) -- lowercase null -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, null given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given in %s on line %d bool(false) -- lowercase true -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, boolean given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d bool(false) -- lowercase false -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, boolean given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d bool(false) -- uppercase TRUE -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, boolean given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d bool(false) -- uppercase FALSE -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, boolean given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d bool(false) -- empty string DQ -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, string given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d bool(false) -- empty string SQ -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, string given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d bool(false) -- string DQ -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, string given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d bool(false) -- string SQ -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, string given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d bool(false) -- mixed case string -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, string given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d bool(false) -- heredoc -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, string given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d bool(false) -- instance of classWithToString -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, object given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, object given in %s on line %d bool(false) -- instance of classWithoutToString -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, object given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, object given in %s on line %d bool(false) -- undefined var -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, null given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given in %s on line %d bool(false) -- unset var -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, null given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given in %s on line %d bool(false) -- resource -- -Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, resource given in %s on line %d +Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, resource given in %s on line %d bool(false) ===DONE=== diff --git a/ext/date/tests/timezone_offset_get_error.phpt b/ext/date/tests/timezone_offset_get_error.phpt index b8ca2c1c15..c9fa25ce97 100644 --- a/ext/date/tests/timezone_offset_get_error.phpt +++ b/ext/date/tests/timezone_offset_get_error.phpt @@ -73,12 +73,12 @@ bool(false) -- Testing timezone_offset_get() function with an invalid values for $datetime argument -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, object given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, object given in %s on line %d bool(false) -Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, integer given in %s on line %d bool(false) -Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, null given in %s on line %d bool(false) ===DONE=== diff --git a/ext/date/tests/timezone_offset_get_variation2.phpt b/ext/date/tests/timezone_offset_get_variation2.phpt index 93311f3a6b..c83b697498 100644 --- a/ext/date/tests/timezone_offset_get_variation2.phpt +++ b/ext/date/tests/timezone_offset_get_variation2.phpt @@ -112,141 +112,141 @@ fclose( $file_handle ); -- int 0 -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, integer given in %s on line %d bool(false) -- int 1 -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, integer given in %s on line %d bool(false) -- int 12345 -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, integer given in %s on line %d bool(false) -- int -12345 -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, integer given in %s on line %d bool(false) -- float 10.5 -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, double given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, double given in %s on line %d bool(false) -- float -10.5 -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, double given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, double given in %s on line %d bool(false) -- float .5 -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, double given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, double given in %s on line %d bool(false) -- empty array -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, array given in %s on line %d bool(false) -- int indexed array -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, array given in %s on line %d bool(false) -- associative array -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, array given in %s on line %d bool(false) -- nested arrays -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, array given in %s on line %d bool(false) -- uppercase NULL -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, null given in %s on line %d bool(false) -- lowercase null -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, null given in %s on line %d bool(false) -- lowercase true -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, boolean given in %s on line %d bool(false) -- lowercase false -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, boolean given in %s on line %d bool(false) -- uppercase TRUE -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, boolean given in %s on line %d bool(false) -- uppercase FALSE -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, boolean given in %s on line %d bool(false) -- empty string DQ -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, string given in %s on line %d bool(false) -- empty string SQ -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, string given in %s on line %d bool(false) -- string DQ -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, string given in %s on line %d bool(false) -- string SQ -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, string given in %s on line %d bool(false) -- mixed case string -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, string given in %s on line %d bool(false) -- heredoc -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, string given in %s on line %d bool(false) -- instance of classWithToString -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, object given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, object given in %s on line %d bool(false) -- instance of classWithoutToString -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, object given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, object given in %s on line %d bool(false) -- undefined var -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, null given in %s on line %d bool(false) -- unset var -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, null given in %s on line %d bool(false) -- resource -- -Warning: timezone_offset_get() expects parameter 2 to be DateTime, resource given in %s on line %d +Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, resource given in %s on line %d bool(false) ===DONE=== |
