From 19645fa7439f6e219edba2c441c465f7a54174ac Mon Sep 17 00:00:00 2001 From: Hideki Kinjyo Date: Sat, 30 Dec 2017 17:57:41 +0900 Subject: [PATCH] Fix phpstan --- src/ORM/Behavior/TimestampBehavior.php | 5 +++-- tests/TestCase/ORM/Behavior/TimestampBehaviorTest.php | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ORM/Behavior/TimestampBehavior.php b/src/ORM/Behavior/TimestampBehavior.php index 1c0da13f6ac..58ba19ba43c 100644 --- a/src/ORM/Behavior/TimestampBehavior.php +++ b/src/ORM/Behavior/TimestampBehavior.php @@ -136,8 +136,9 @@ public function implementedEvents() */ public function timestamp(DateTimeInterface $ts = null, $refreshTimestamp = false) { - $class = Type::build('datetime') - ->getDateTimeClassName(); + /** @var \Cake\Database\Type\DateTimeType $type */ + $type = Type::build('datetime'); + $class = $type->getDateTimeClassName(); if ($ts) { if ($this->_config['refreshTimestamp']) { diff --git a/tests/TestCase/ORM/Behavior/TimestampBehaviorTest.php b/tests/TestCase/ORM/Behavior/TimestampBehaviorTest.php index 5c2019fc972..dc0f6d60b8e 100644 --- a/tests/TestCase/ORM/Behavior/TimestampBehaviorTest.php +++ b/tests/TestCase/ORM/Behavior/TimestampBehaviorTest.php @@ -306,8 +306,10 @@ public function testGetTimestampFollowingDatetimeClassSetting() { $table = $this->getMockBuilder('Cake\ORM\Table')->getMock(); $behavior = new TimestampBehavior($table); + /** @var \Cake\Database\Type\DateTimeType $type */ + $type = Type::build('datetime'); - Type::build('datetime')->useImmutable(); + $type->useImmutable(); $return = $behavior->timestamp(null, true); $this->assertInstanceOf( FrozenTime::class, @@ -315,7 +317,7 @@ public function testGetTimestampFollowingDatetimeClassSetting() 'Should return a immutable datetime object' ); - Type::build('datetime')->useMutable(); + $type->useMutable(); $return = $behavior->timestamp(null, true); $this->assertInstanceOf( Time::class,