]> granicus.if.org Git - php/commitdiff
DateTimeZone::getOffset() now accepts a DateTimeInterface
authorFlorian MARGAINE <florian@margaine.com>
Sat, 20 Sep 2014 21:16:39 +0000 (23:16 +0200)
committerDerick Rethans <github@derickrethans.nl>
Sat, 4 Oct 2014 15:06:04 +0000 (16:06 +0100)
Fixes #68062

Should be backported to PHP-5.6 and PHP-5.5.

Conflicts:
ext/date/tests/bug67118.phpt

ext/date/php_date.c
ext/date/tests/014.phpt
ext/date/tests/68062.phpt [new file with mode: 0644]
ext/date/tests/DateTimeZone_getOffset_variation1.phpt
ext/date/tests/bug67118.phpt
ext/date/tests/timezone_offset_get_error.phpt
ext/date/tests/timezone_offset_get_variation1.phpt
ext/date/tests/timezone_offset_get_variation2.phpt

index 360c6d3f67c36793301bc95b0205fe176120fc83..f2ced7bd595b6db5a5676ff1c5c1901ca48ea0a0 100644 (file)
@@ -325,12 +325,12 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_name_from_abbr, 0, 0, 1)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_offset_get, 0, 0, 2)
-       ZEND_ARG_INFO(0, object)
-       ZEND_ARG_INFO(0, datetime)
+       ZEND_ARG_OBJ_INFO(0, object, DateTimeZone, 0)
+       ZEND_ARG_OBJ_INFO(0, datetime, DateTimeInterface, 0)
 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)
@@ -3799,7 +3799,7 @@ PHP_FUNCTION(timezone_name_from_abbr)
 }
 /* }}} */
 
-/* {{{ proto long timezone_offset_get(DateTimeZone object, DateTime object)
+/* {{{ proto long timezone_offset_get(DateTimeZone object, DateTimeInterface datetime)
    Returns the timezone offset.
 */
 PHP_FUNCTION(timezone_offset_get)
@@ -3809,13 +3809,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 = Z_PHPTIMEZONE_P(object);
        DATE_CHECK_INITIALIZED(tzobj->initialized, DateTimeZone);
        dateobj = Z_PHPDATE_P(dateobject);
-       DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
+       DATE_CHECK_INITIALIZED(dateobj->time, DateTimeInterface);
 
        switch (tzobj->type) {
                case TIMELIB_ZONETYPE_ID:
index 3adb32c96599fcff67fd22e25233b53a8e1d7703..1580f1ae70fc27e55edae3357ff4fd4033644829 100644 (file)
@@ -37,6 +37,4 @@ Warning: timezone_offset_get() expects exactly 2 parameters, 0 given in %s on li
 bool(false)
 int(0)
 
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, object given in %s on line %d
-bool(false)
-Done
+Catchable fatal error: Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, instance of DateTime given in %s
diff --git a/ext/date/tests/68062.phpt b/ext/date/tests/68062.phpt
new file mode 100644 (file)
index 0000000..ce2105a
--- /dev/null
@@ -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
index a86d5e10bbdd26545d8b8756c715bdd5cd2a852f..ecd99d5bc36110cff5ce91ae9d36a17cea8fbc66 100644 (file)
@@ -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===
index 332142856e42b707fd106fc165f9c294c52a30ef..7b5d6a7328656ec2047e49aa114b8df6213b7df1 100644 (file)
@@ -23,5 +23,6 @@ class mydt extends datetime
 new mydt("Funktionsansvarig rĂ„dgivning och juridik", "UTC");
 ?>
 --EXPECTF--
+
 Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in %s on line %d
 Bad date
index b8ca2c1c15b543b3965d9742d18de626f5926477..9e9daacf8484d2e74fdb775be07979f21c7318e7 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-Test timezone_offset_get() function : error conditions 
+Test timezone_offset_get() function : error conditions
 --FILE--
 <?php
 /* Prototype  : int timezone_offset_get  ( DateTimeZone $object  , DateTime $datetime  )
@@ -7,12 +7,20 @@ Test timezone_offset_get() function : error conditions
  * Source code: ext/date/php_date.c
  * Alias to functions: DateTimeZone::getOffset
  */
-//Set the default time zone 
+
+//Set the default time zone
 date_default_timezone_set("GMT");
 $tz = timezone_open("Europe/London");
 $date = date_create("GMT");
+
+set_error_handler('err');
+
+function err($errno, $errstr) {
+       if ($errno === E_RECOVERABLE_ERROR) {
+               var_dump($errstr);
+       }
+}
+
 echo "*** Testing timezone_offset_get() : error conditions ***\n";
 
 echo "\n-- Testing timezone_offset_get() function with zero arguments --\n";
@@ -27,7 +35,7 @@ var_dump( timezone_offset_get($tz, $date, $extra_arg) );
 
 echo "\n-- Testing timezone_offset_get() function with an invalid values for \$object argument --\n";
 $invalid_obj = new stdClass();
-var_dump( timezone_offset_get($invalid_obj, $date) );  
+var_dump( timezone_offset_get($invalid_obj, $date) );
 $invalid_obj = 10;
 var_dump( timezone_offset_get($invalid_obj, $date) );
 $invalid_obj = null;
@@ -35,50 +43,38 @@ var_dump( timezone_offset_get($invalid_obj, $date) );
 
 echo "\n-- Testing timezone_offset_get() function with an invalid values for \$datetime argument --\n";
 $invalid_obj = new stdClass();
-var_dump( timezone_offset_get($tz, $invalid_obj) );  
+var_dump( timezone_offset_get($tz, $invalid_obj) );
 $invalid_obj = 10;
 var_dump( timezone_offset_get($tz, $invalid_obj) );
 $invalid_obj = null;
-var_dump( timezone_offset_get($tz, $invalid_obj) );  
+var_dump( timezone_offset_get($tz, $invalid_obj) );
 ?>
 ===DONE===
 --EXPECTF--
 *** Testing timezone_offset_get() : error conditions ***
 
 -- Testing timezone_offset_get() function with zero arguments --
-
-Warning: timezone_offset_get() expects exactly 2 parameters, 0 given in %s on line %d
 bool(false)
 
 -- Testing timezone_offset_get() function with less than expected no. of arguments --
-
-Warning: timezone_offset_get() expects exactly 2 parameters, 1 given in %s on line %d
 bool(false)
 
 -- Testing timezone_offset_get() function with more than expected no. of arguments --
-
-Warning: timezone_offset_get() expects exactly 2 parameters, 3 given in %s on line %d
 bool(false)
 
 -- Testing timezone_offset_get() function with an invalid values for $object argument --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, object given in %s on line %d
+string(%d) "Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, instance of stdClass given"
 bool(false)
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, integer given in %s on line %d
+string(%d) "Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, integer given"
 bool(false)
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d
+string(%d) "Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, null given"
 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
+string(%d) "Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, instance of stdClass given"
 bool(false)
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d
+string(%d) "Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, integer given"
 bool(false)
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d
+string(%d) "Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, null given"
 bool(false)
 ===DONE===
index 5fd5e8b27098f4a45d8c15587a5b09c08566e090..01013ab5cdd81b08b68b978c8c1c5afe6c162909 100644 (file)
@@ -13,6 +13,14 @@ echo "*** Testing timezone_offset_get() : usage variation -  unexpected values t
 //Set the default time zone 
 date_default_timezone_set("Europe/London");
 
+set_error_handler('handler');
+
+function handler($errno, $errstr) {
+       if ($errno === E_RECOVERABLE_ERROR) {
+               echo $errstr . "\n";
+       }
+}
+
 //get an unset variable
 $unset_var = 10;
 unset ($unset_var);
@@ -111,142 +119,114 @@ fclose( $file_handle );
 *** Testing timezone_offset_get() : usage variation -  unexpected values to first argument $object***
 
 -- int 0 --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, integer given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, integer given
 bool(false)
 
 -- int 1 --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, integer given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, integer given
 bool(false)
 
 -- int 12345 --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, integer given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, integer given
 bool(false)
 
 -- int -12345 --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, integer given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, integer given
 bool(false)
 
 -- float 10.5 --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, double given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, double given
 bool(false)
 
 -- float -10.5 --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, double given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, double given
 bool(false)
 
 -- float .5 --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, double given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, double given
 bool(false)
 
 -- empty array --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, array given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, array given
 bool(false)
 
 -- int indexed array --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, array given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, array given
 bool(false)
 
 -- associative array --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, array given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, array given
 bool(false)
 
 -- nested arrays --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, array given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, array given
 bool(false)
 
 -- uppercase NULL --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, null given
 bool(false)
 
 -- lowercase null --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, null given
 bool(false)
 
 -- lowercase true --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, boolean given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, boolean given
 bool(false)
 
 -- lowercase false --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, boolean given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, boolean given
 bool(false)
 
 -- uppercase TRUE --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, boolean given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, boolean given
 bool(false)
 
 -- uppercase FALSE --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, boolean given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, boolean given
 bool(false)
 
 -- empty string DQ --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, string given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, string given
 bool(false)
 
 -- empty string SQ --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, string given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, string given
 bool(false)
 
 -- string DQ --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, string given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, string given
 bool(false)
 
 -- string SQ --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, string given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, string given
 bool(false)
 
 -- mixed case string --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, string given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, string given
 bool(false)
 
 -- heredoc --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, string given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, string given
 bool(false)
 
 -- instance of classWithToString --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, object given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, instance of classWithToString given
 bool(false)
 
 -- instance of classWithoutToString --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, object given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, instance of classWithoutToString given
 bool(false)
 
 -- undefined var --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, null given
 bool(false)
 
 -- unset var --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, null given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, null given
 bool(false)
 
 -- resource --
-
-Warning: timezone_offset_get() expects parameter 1 to be DateTimeZone, resource given in %s on line %d
+Argument 1 passed to timezone_offset_get() must be an instance of DateTimeZone, resource given
 bool(false)
 ===DONE===
index 93311f3a6b960fd1c2145c49304f42b774ed6dca..98e109351485b9965841c5cf86f6019138afeaea 100644 (file)
@@ -13,6 +13,14 @@ echo "*** Testing timezone_offset_get() : usage variation -  unexpected values t
 //Set the default time zone 
 date_default_timezone_set("Europe/London");
 
+set_error_handler('handler');
+
+function handler($errno, $errstr) {
+       if ($errno === E_RECOVERABLE_ERROR) {
+               echo $errstr . "\n";
+       }
+}
+
 //get an unset variable
 $unset_var = 10;
 unset ($unset_var);
@@ -111,142 +119,114 @@ fclose( $file_handle );
 *** Testing timezone_offset_get() : usage variation -  unexpected values to second argument $datetime***
 
 -- int 0 --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, integer given
 bool(false)
 
 -- int 1 --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, integer given
 bool(false)
 
 -- int 12345 --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, integer given
 bool(false)
 
 -- int -12345 --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, integer given
 bool(false)
 
 -- float 10.5 --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, double given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, double given
 bool(false)
 
 -- float -10.5 --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, double given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, double given
 bool(false)
 
 -- float .5 --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, double given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, double given
 bool(false)
 
 -- empty array --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, array given
 bool(false)
 
 -- int indexed array --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, array given
 bool(false)
 
 -- associative array --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, array given
 bool(false)
 
 -- nested arrays --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, array given
 bool(false)
 
 -- uppercase NULL --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, null given
 bool(false)
 
 -- lowercase null --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, null given
 bool(false)
 
 -- lowercase true --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, boolean given
 bool(false)
 
 -- lowercase false --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, boolean given
 bool(false)
 
 -- uppercase TRUE --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, boolean given
 bool(false)
 
 -- uppercase FALSE --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, boolean given
 bool(false)
 
 -- empty string DQ --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, string given
 bool(false)
 
 -- empty string SQ --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, string given
 bool(false)
 
 -- string DQ --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, string given
 bool(false)
 
 -- string SQ --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, string given
 bool(false)
 
 -- mixed case string --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, string given
 bool(false)
 
 -- heredoc --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, string given
 bool(false)
 
 -- instance of classWithToString --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, object given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, instance of classWithToString given
 bool(false)
 
 -- instance of classWithoutToString --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, object given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, instance of classWithoutToString given
 bool(false)
 
 -- undefined var --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, null given
 bool(false)
 
 -- unset var --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, null given
 bool(false)
 
 -- resource --
-
-Warning: timezone_offset_get() expects parameter 2 to be DateTime, resource given in %s on line %d
+Argument 2 passed to timezone_offset_get() must implement interface DateTimeInterface, resource given
 bool(false)
 ===DONE===