]> granicus.if.org Git - php/commitdiff
Fixed bug #71053 (Type Hint about DateTime::diff does not match with informed)
authorReeze Xia <reeze@php.net>
Wed, 9 Dec 2015 03:35:39 +0000 (11:35 +0800)
committerReeze Xia <reeze@php.net>
Wed, 9 Dec 2015 03:40:47 +0000 (11:40 +0800)
NEWS
ext/date/php_date.c
ext/date/tests/bug71053.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 33bd38cc5525057525a2a9c2ecf2fd09aed205a3..aae08f26450b98e98504469cd332be0e1e3b09ad 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? Jan 2016 PHP 7.0.2
 
+- Date:
+  . Fixed bug #71053 (Type Hint about DateTime::diff does not match with
+    informed). (Reeze Xia)
+
 - Mbstring:
   . Fixed bug #71066 (mb_send_mail: Program terminated with signal SIGSEGV,
     Segmentation fault). (Laruence)
index 50c48eb43936cbd31f73c3b207dd44a0809a7a2b..b3125a9a5a129b19b20292ed9a24b07ce7b1b96b 100644 (file)
@@ -3579,9 +3579,9 @@ PHP_FUNCTION(date_diff)
        zval         *object1, *object2;
        php_date_obj *dateobj1, *dateobj2;
        php_interval_obj *interval;
-       zend_long          absolute = 0;
+       zend_bool absolute = 0;
 
-       if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO|l", &object1, date_ce_interface, &object2, date_ce_interface, &absolute) == FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO|b", &object1, date_ce_interface, &object2, date_ce_interface, &absolute) == FAILURE) {
                RETURN_FALSE;
        }
        dateobj1 = Z_PHPDATE_P(object1);
diff --git a/ext/date/tests/bug71053.phpt b/ext/date/tests/bug71053.phpt
new file mode 100644 (file)
index 0000000..2c86f9f
--- /dev/null
@@ -0,0 +1,13 @@
+--TEST--
+Bug #71053 (Type Hint about DateTime::diff does not match with informed)
+--FILE--
+<?php
+declare(strict_types=1);
+
+$date1 = new \DateTime();
+$date2 = clone $date1;
+
+var_dump(count($date1->diff($date2 , true)) > 0);
+?>
+--EXPECT--
+bool(true)