From aa14c684978a977484e94ce3c6029c6ad2c3ff60 Mon Sep 17 00:00:00 2001 From: Koji Tanaka Date: Wed, 17 Jan 2018 03:35:00 +0900 Subject: [PATCH] Fix some count() Error in PHP 7.2 --- lib/Cake/Console/Command/Task/ControllerTask.php | 2 +- lib/Cake/Test/Case/Model/ConnectionManagerTest.php | 4 ++-- lib/Cake/Test/Case/Model/ModelWriteTest.php | 12 ++++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index 7515779f9..f843fc6d4 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -328,7 +328,7 @@ class ControllerTask extends BakeTask { * @param array $components Components to use in controller * @return string Baked controller */ - public function bake($controllerName, $actions = '', $helpers = null, $components = null) { + public function bake($controllerName, $actions = '', $helpers = array(), $components = array()) { $this->out("\n" . __d('cake_console', 'Baking controller class for %s...', $controllerName), 1, Shell::QUIET); $isScaffold = ($actions === 'scaffold') ? true : false; diff --git a/lib/Cake/Test/Case/Model/ConnectionManagerTest.php b/lib/Cake/Test/Case/Model/ConnectionManagerTest.php index abd7b5fa6..5181842ad 100644 --- a/lib/Cake/Test/Case/Model/ConnectionManagerTest.php +++ b/lib/Cake/Test/Case/Model/ConnectionManagerTest.php @@ -64,7 +64,7 @@ class ConnectionManagerTest extends CakeTestCase { ConnectionManager::create($name, $config); $connections = ConnectionManager::enumConnectionObjects(); - $this->assertTrue((bool)(count(array_keys($connections) >= 1))); + $this->assertTrue(count(array_keys($connections)) >= 1); $source = ConnectionManager::getDataSource('test_get_datasource'); $this->assertTrue(is_object($source)); @@ -239,7 +239,7 @@ class ConnectionManagerTest extends CakeTestCase { $name = 'test_created_connection'; $connections = ConnectionManager::enumConnectionObjects(); - $this->assertTrue((bool)(count(array_keys($connections) >= 1))); + $this->assertTrue(count(array_keys($connections)) >= 1); $source = ConnectionManager::getDataSource('test'); $this->assertTrue(is_object($source)); diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index 52f99908f..d0ea8fddd 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -3367,7 +3367,9 @@ class ModelWriteTest extends BaseModelTest { array( 'comment' => 'Article comment', 'user_id' => 1 - ))); + ) + ) + ); $Article = new Article(); $result = $Article->saveAll($data); $this->assertFalse(empty($result)); @@ -3376,7 +3378,7 @@ class ModelWriteTest extends BaseModelTest { $this->assertEquals(2, count($result['Tag'])); $this->assertEquals('tag1', $result['Tag'][0]['tag']); $this->assertEquals(1, count($result['Comment'])); - $this->assertEquals(1, count($result['Comment'][0]['comment'])); + $this->assertEquals('Article comment', $result['Comment'][0]['comment']); } /** @@ -5647,7 +5649,9 @@ class ModelWriteTest extends BaseModelTest { array( 'comment' => 'Article comment', 'user_id' => 1 - ))); + ) + ) + ); $Article = new Article(); $result = $Article->saveAssociated($data); $this->assertFalse(empty($result)); @@ -5656,7 +5660,7 @@ class ModelWriteTest extends BaseModelTest { $this->assertEquals(2, count($result['Tag'])); $this->assertEquals('tag1', $result['Tag'][0]['tag']); $this->assertEquals(1, count($result['Comment'])); - $this->assertEquals(1, count($result['Comment'][0]['comment'])); + $this->assertEquals('Article comment', $result['Comment'][0]['comment']); } /**