From ed5da19d10ab2bd06deb12d3b98ea8dca17f8507 Mon Sep 17 00:00:00 2001 From: Mark van Driel Date: Mon, 2 Mar 2015 12:08:11 +0100 Subject: [PATCH] Fixed return type of toQuarter in CakeTime and TimeHelper --- lib/Cake/Test/Case/Utility/CakeTimeTest.php | 6 +++--- lib/Cake/Utility/CakeTime.php | 4 ++-- lib/Cake/View/Helper/TimeHelper.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/CakeTimeTest.php b/lib/Cake/Test/Case/Utility/CakeTimeTest.php index a76ffb6b0..54fcc789b 100644 --- a/lib/Cake/Test/Case/Utility/CakeTimeTest.php +++ b/lib/Cake/Test/Case/Utility/CakeTimeTest.php @@ -72,13 +72,13 @@ class CakeTimeTest extends CakeTestCase { */ public function testToQuarter() { $result = $this->Time->toQuarter('2007-12-25'); - $this->assertEquals(4, $result); + $this->assertSame(4, $result); $result = $this->Time->toQuarter('2007-9-25'); - $this->assertEquals(3, $result); + $this->assertSame(3, $result); $result = $this->Time->toQuarter('2007-3-25'); - $this->assertEquals(1, $result); + $this->assertSame(1, $result); $result = $this->Time->toQuarter('2007-3-25', true); $this->assertEquals(array('2007-01-01', '2007-03-31'), $result); diff --git a/lib/Cake/Utility/CakeTime.php b/lib/Cake/Utility/CakeTime.php index 38c22196a..b22082320 100644 --- a/lib/Cake/Utility/CakeTime.php +++ b/lib/Cake/Utility/CakeTime.php @@ -575,12 +575,12 @@ class CakeTime { * * @param int|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object * @param bool $range if true returns a range in Y-m-d format - * @return mixed 1, 2, 3, or 4 quarter of year or array if $range true + * @return int|array 1, 2, 3, or 4 quarter of year or array if $range true * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::toQuarter */ public static function toQuarter($dateString, $range = false) { $time = self::fromString($dateString); - $date = ceil(date('m', $time) / 3); + $date = (int)ceil(date('m', $time) / 3); if ($range === false) { return $date; } diff --git a/lib/Cake/View/Helper/TimeHelper.php b/lib/Cake/View/Helper/TimeHelper.php index 45ce699bd..5e91705bd 100644 --- a/lib/Cake/View/Helper/TimeHelper.php +++ b/lib/Cake/View/Helper/TimeHelper.php @@ -316,7 +316,7 @@ class TimeHelper extends AppHelper { * * @param int|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object * @param bool $range if true returns a range in Y-m-d format - * @return mixed 1, 2, 3, or 4 quarter of year or array if $range true + * @return int|array 1, 2, 3, or 4 quarter of year or array if $range true * @see CakeTime::toQuarter() * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting */