From e00812d3f8d35c00ab122bec84ce82b7bb13f1e6 Mon Sep 17 00:00:00 2001 From: Bryan Crowe Date: Mon, 23 Sep 2013 21:06:38 -0400 Subject: [PATCH 01/12] Updated doc block readability in bootstrap.php --- app/Config/bootstrap.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Config/bootstrap.php b/app/Config/bootstrap.php index d5330d838..0f3e3b5a0 100644 --- a/app/Config/bootstrap.php +++ b/app/Config/bootstrap.php @@ -54,7 +54,7 @@ Cache::config('default', array('engine' => 'File')); */ /** - * Custom Inflector rules, can be set to correctly pluralize or singularize table, model, controller names or whatever other + * Custom Inflector rules can be set to correctly pluralize or singularize table, model, controller names or whatever other * string is passed to the inflection functions * * Inflector::rules('singular', array('rules' => array(), 'irregular' => array(), 'uninflected' => array())); @@ -64,7 +64,7 @@ Cache::config('default', array('engine' => 'File')); /** * Plugins need to be loaded manually, you can either load them one by one or all of them in a single call - * Uncomment one of the lines below, as you need. make sure you read the documentation on CakePlugin to use more + * Uncomment one of the lines below, as you need. Make sure you read the documentation on CakePlugin to use more * advanced ways of loading plugins * * CakePlugin::loadAll(); // Loads all plugins at once @@ -73,7 +73,7 @@ Cache::config('default', array('engine' => 'File')); */ /** - * You can attach event listeners to the request lifecycle as Dispatcher Filter . By Default CakePHP bundles two filters: + * You can attach event listeners to the request lifecycle as Dispatcher Filter. By default CakePHP bundles two filters: * * - AssetDispatcher filter will serve your asset files (css, images, js, etc) from your themes and plugins * - CacheDispatcher filter will read the Cache.check configure variable and try to serve cached content generated from controllers From 1393325ad175decadb82ee5f708d4a70dab7d612 Mon Sep 17 00:00:00 2001 From: Bryan Crowe Date: Mon, 23 Sep 2013 21:37:27 -0400 Subject: [PATCH 02/12] Use instanceof instead of is_a() in Controller.php --- lib/Cake/Controller/Controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index 13d36328c..eb54a385a 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -940,7 +940,7 @@ class Controller extends Object implements CakeEventListener { $models = ClassRegistry::keys(); foreach ($models as $currentModel) { $currentObject = ClassRegistry::getObject($currentModel); - if (is_a($currentObject, 'Model')) { + if ($currentObject instanceof Model) { $className = get_class($currentObject); list($plugin) = pluginSplit(App::location($className)); $this->request->params['models'][$currentObject->alias] = compact('plugin', 'className'); From 653aed7701a6021d20df6361ce7c02131ed3726a Mon Sep 17 00:00:00 2001 From: euromark Date: Tue, 24 Sep 2013 22:57:51 +0200 Subject: [PATCH 03/12] is_a() to instance of - completes PR 1669 --- lib/Cake/Console/Command/Task/TestTask.php | 4 ++-- lib/Cake/Model/AclNode.php | 2 +- lib/Cake/Model/Datasource/DboSource.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Console/Command/Task/TestTask.php b/lib/Cake/Console/Command/Task/TestTask.php index 5350918ed..14776d278 100644 --- a/lib/Cake/Console/Command/Task/TestTask.php +++ b/lib/Cake/Console/Command/Task/TestTask.php @@ -374,9 +374,9 @@ class TestTask extends BakeTask { */ public function generateFixtureList($subject) { $this->_fixtures = array(); - if (is_a($subject, 'Model')) { + if ($subject instanceof Model) { $this->_processModel($subject); - } elseif (is_a($subject, 'Controller')) { + } elseif ($subject instanceof Controller) { $this->_processController($subject); } return array_values($this->_fixtures); diff --git a/lib/Cake/Model/AclNode.php b/lib/Cake/Model/AclNode.php index 63bf3959c..9f60c24b9 100644 --- a/lib/Cake/Model/AclNode.php +++ b/lib/Cake/Model/AclNode.php @@ -121,7 +121,7 @@ class AclNode extends Model { ) { return false; } - } elseif (is_object($ref) && is_a($ref, 'Model')) { + } elseif (is_object($ref) && $ref instanceof Model) { $ref = array('model' => $ref->name, 'foreign_key' => $ref->id); } elseif (is_array($ref) && !(isset($ref['model']) && isset($ref['foreign_key']))) { $name = key($ref); diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 51927be30..0d2dd162d 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -2961,7 +2961,7 @@ class DboSource extends DataSource { * @return string */ public function createSchema($schema, $tableName = null) { - if (!is_a($schema, 'CakeSchema')) { + if (!$schema instanceof CakeSchema) { trigger_error(__d('cake_dev', 'Invalid schema object'), E_USER_WARNING); return null; } From 7d7954ce181b26a399ea4e09b2eb8bf13d90b226 Mon Sep 17 00:00:00 2001 From: Bryan Crowe Date: Tue, 24 Sep 2013 21:08:06 -0400 Subject: [PATCH 04/12] Replaced all is_a() calls with instanceof operator --- lib/Cake/Model/Datasource/DboSource.php | 2 +- .../Case/Console/Command/SchemaShellTest.php | 2 +- .../Test/Case/Controller/ControllerTest.php | 6 ++-- lib/Cake/Test/Case/Routing/RouterTest.php | 2 +- .../Test/Case/Utility/ClassRegistryTest.php | 30 +++++++++---------- lib/Cake/Utility/ClassRegistry.php | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 0d2dd162d..159d5a811 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -861,7 +861,7 @@ class DboSource extends DataSource { * @return boolean True if the result is valid else false */ public function hasResult() { - return is_a($this->_result, 'PDOStatement'); + return $this->_result instanceof PDOStatement; } /** diff --git a/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php b/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php index a78c0fbdd..e702e4b16 100644 --- a/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php +++ b/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php @@ -137,7 +137,7 @@ class SchemaShellTest extends CakeTestCase { public function testStartup() { $this->Shell->startup(); $this->assertTrue(isset($this->Shell->Schema)); - $this->assertTrue(is_a($this->Shell->Schema, 'CakeSchema')); + $this->assertTrue($this->Shell->Schema instanceof CakeSchema); $this->assertEquals(Inflector::camelize(Inflector::slug(APP_DIR)), $this->Shell->Schema->name); $this->assertEquals('schema.php', $this->Shell->Schema->file); diff --git a/lib/Cake/Test/Case/Controller/ControllerTest.php b/lib/Cake/Test/Case/Controller/ControllerTest.php index 18fccf49e..63ed922d0 100644 --- a/lib/Cake/Test/Case/Controller/ControllerTest.php +++ b/lib/Cake/Test/Case/Controller/ControllerTest.php @@ -482,8 +482,8 @@ class ControllerTest extends CakeTestCase { $Controller = new Controller($request); $Controller->uses = array('ControllerPost', 'ControllerComment'); $Controller->constructClasses(); - $this->assertTrue(is_a($Controller->ControllerPost, 'ControllerPost')); - $this->assertTrue(is_a($Controller->ControllerComment, 'ControllerComment')); + $this->assertTrue($Controller->ControllerPost instanceof ControllerPost); + $this->assertTrue($Controller->ControllerComment instanceof ControllerComment); $this->assertEquals('Comment', $Controller->ControllerComment->name); @@ -497,7 +497,7 @@ class ControllerTest extends CakeTestCase { $Controller->constructClasses(); $this->assertTrue(isset($Controller->TestPluginPost)); - $this->assertTrue(is_a($Controller->TestPluginPost, 'TestPluginPost')); + $this->assertTrue($Controller->TestPluginPost instanceof TestPluginPost); } /** diff --git a/lib/Cake/Test/Case/Routing/RouterTest.php b/lib/Cake/Test/Case/Routing/RouterTest.php index 57e480978..f843bda03 100644 --- a/lib/Cake/Test/Case/Routing/RouterTest.php +++ b/lib/Cake/Test/Case/Routing/RouterTest.php @@ -2354,7 +2354,7 @@ class RouterTest extends CakeTestCase { array('controller' => 'posts', 'action' => 'view'), array('routeClass' => 'MockConnectedRoute', 'slug' => '[a-z_-]+') ); - $this->assertTrue(is_a($routes[0], 'MockConnectedRoute'), 'Incorrect class used. %s'); + $this->assertTrue($routes[0] instanceof MockConnectedRoute, 'Incorrect class used. %s'); $expected = array('controller' => 'posts', 'action' => 'view', 'slug' => 'test'); $routes[0]->expects($this->any()) ->method('parse') diff --git a/lib/Cake/Test/Case/Utility/ClassRegistryTest.php b/lib/Cake/Test/Case/Utility/ClassRegistryTest.php index ff751fe96..df656f652 100644 --- a/lib/Cake/Test/Case/Utility/ClassRegistryTest.php +++ b/lib/Cake/Test/Case/Utility/ClassRegistryTest.php @@ -136,7 +136,7 @@ class ClassRegistryTest extends CakeTestCase { */ public function testAddModel() { $Tag = ClassRegistry::init('RegisterArticleTag'); - $this->assertTrue(is_a($Tag, 'RegisterArticleTag')); + $this->assertTrue($Tag instanceof RegisterArticleTag); $TagCopy = ClassRegistry::isKeySet('RegisterArticleTag'); $this->assertTrue($TagCopy); @@ -145,11 +145,11 @@ class ClassRegistryTest extends CakeTestCase { $TagCopy = ClassRegistry::getObject('RegisterArticleTag'); - $this->assertTrue(is_a($TagCopy, 'RegisterArticleTag')); + $this->assertTrue($TagCopy instanceof RegisterArticleTag); $this->assertSame($Tag, $TagCopy); $NewTag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag')); - $this->assertTrue(is_a($Tag, 'RegisterArticleTag')); + $this->assertTrue($Tag instanceof RegisterArticleTag); $NewTagCopy = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag')); @@ -166,17 +166,17 @@ class ClassRegistryTest extends CakeTestCase { $this->assertTrue($TagCopy->name === 'SomeOtherName'); $User = ClassRegistry::init(array('class' => 'RegisterUser', 'alias' => 'User', 'table' => false)); - $this->assertTrue(is_a($User, 'AppModel')); + $this->assertTrue($User instanceof AppModel); $UserCopy = ClassRegistry::init(array('class' => 'RegisterUser', 'alias' => 'User', 'table' => false)); - $this->assertTrue(is_a($UserCopy, 'AppModel')); + $this->assertTrue($UserCopy instanceof AppModel); $this->assertEquals($User, $UserCopy); $Category = ClassRegistry::init(array('class' => 'RegisterCategory')); - $this->assertTrue(is_a($Category, 'RegisterCategory')); + $this->assertTrue($Category instanceof RegisterCategory); $ParentCategory = ClassRegistry::init(array('class' => 'RegisterCategory', 'alias' => 'ParentCategory')); - $this->assertTrue(is_a($ParentCategory, 'RegisterCategory')); + $this->assertTrue($ParentCategory instanceof RegisterCategory); $this->assertNotSame($Category, $ParentCategory); $this->assertNotEquals($Category->alias, $ParentCategory->alias); @@ -193,12 +193,12 @@ class ClassRegistryTest extends CakeTestCase { ClassRegistry::init('RegisterArticleTag'); $ArticleTag = ClassRegistry::getObject('RegisterArticleTag'); - $this->assertTrue(is_a($ArticleTag, 'RegisterArticleTag')); + $this->assertTrue($ArticleTag instanceof RegisterArticleTag); ClassRegistry::flush(); $NoArticleTag = ClassRegistry::isKeySet('RegisterArticleTag'); $this->assertFalse($NoArticleTag); - $this->assertTrue(is_a($ArticleTag, 'RegisterArticleTag')); + $this->assertTrue($ArticleTag instanceof RegisterArticleTag); } /** @@ -233,13 +233,13 @@ class ClassRegistryTest extends CakeTestCase { $this->assertTrue($Tag); $Article = ClassRegistry::getObject('Article'); - $this->assertTrue(is_a($Article, 'RegisterArticle')); + $this->assertTrue($Article instanceof RegisterArticle); $Featured = ClassRegistry::getObject('Featured'); - $this->assertTrue(is_a($Featured, 'RegisterArticleFeatured')); + $this->assertTrue($Featured instanceof RegisterArticleFeatured); $Tag = ClassRegistry::getObject('Tag'); - $this->assertTrue(is_a($Tag, 'RegisterArticleTag')); + $this->assertTrue($Tag instanceof RegisterArticleTag); } /** @@ -254,15 +254,15 @@ class ClassRegistryTest extends CakeTestCase { //Faking a plugin CakePlugin::load('RegistryPlugin', array('path' => '/fake/path')); $TestRegistryPluginModel = ClassRegistry::init('RegistryPlugin.TestRegistryPluginModel'); - $this->assertTrue(is_a($TestRegistryPluginModel, 'TestRegistryPluginModel')); + $this->assertTrue($TestRegistryPluginModel instanceof TestRegistryPluginModel); $this->assertEquals('something_', $TestRegistryPluginModel->tablePrefix); $PluginUser = ClassRegistry::init(array('class' => 'RegistryPlugin.RegisterUser', 'alias' => 'RegistryPluginUser', 'table' => false)); - $this->assertTrue(is_a($PluginUser, 'RegistryPluginAppModel')); + $this->assertTrue($PluginUser instanceof RegistryPluginAppModel); $PluginUserCopy = ClassRegistry::getObject('RegistryPluginUser'); - $this->assertTrue(is_a($PluginUserCopy, 'RegistryPluginAppModel')); + $this->assertTrue($PluginUserCopy instanceof RegistryPluginAppModel); $this->assertSame($PluginUser, $PluginUserCopy); CakePlugin::unload(); } diff --git a/lib/Cake/Utility/ClassRegistry.php b/lib/Cake/Utility/ClassRegistry.php index 3b2a3dc02..fb57f7feb 100644 --- a/lib/Cake/Utility/ClassRegistry.php +++ b/lib/Cake/Utility/ClassRegistry.php @@ -311,7 +311,7 @@ class ClassRegistry { $duplicate = false; if ($this->isKeySet($alias)) { $model = $this->getObject($alias); - if (is_object($model) && (is_a($model, $class) || $model->alias === $class)) { + if (is_object($model) && ($model instanceof $class || $model->alias === $class)) { $duplicate = $model; } unset($model); From 9a1170cd2b54b7baf03b048a91cba6d2befbe9de Mon Sep 17 00:00:00 2001 From: Bryan Crowe Date: Tue, 24 Sep 2013 22:10:36 -0400 Subject: [PATCH 05/12] Replaced true asserations with instanceOf asserations in test cases --- .../Case/Console/Command/SchemaShellTest.php | 2 +- .../Test/Case/Controller/ControllerTest.php | 6 ++-- lib/Cake/Test/Case/Routing/RouterTest.php | 2 +- .../Test/Case/Utility/ClassRegistryTest.php | 30 +++++++++---------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php b/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php index e702e4b16..512d9b1bf 100644 --- a/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php +++ b/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php @@ -137,7 +137,7 @@ class SchemaShellTest extends CakeTestCase { public function testStartup() { $this->Shell->startup(); $this->assertTrue(isset($this->Shell->Schema)); - $this->assertTrue($this->Shell->Schema instanceof CakeSchema); + $this->assertInstanceOf('CakeSchema', $this->Shell->Schema); $this->assertEquals(Inflector::camelize(Inflector::slug(APP_DIR)), $this->Shell->Schema->name); $this->assertEquals('schema.php', $this->Shell->Schema->file); diff --git a/lib/Cake/Test/Case/Controller/ControllerTest.php b/lib/Cake/Test/Case/Controller/ControllerTest.php index 63ed922d0..071a1f85e 100644 --- a/lib/Cake/Test/Case/Controller/ControllerTest.php +++ b/lib/Cake/Test/Case/Controller/ControllerTest.php @@ -482,8 +482,8 @@ class ControllerTest extends CakeTestCase { $Controller = new Controller($request); $Controller->uses = array('ControllerPost', 'ControllerComment'); $Controller->constructClasses(); - $this->assertTrue($Controller->ControllerPost instanceof ControllerPost); - $this->assertTrue($Controller->ControllerComment instanceof ControllerComment); + $this->assertInstanceOf('ControllerPost', $Controller->ControllerPost); + $this->assertInstanceOf('ControllerComment', $Controller->ControllerComment); $this->assertEquals('Comment', $Controller->ControllerComment->name); @@ -497,7 +497,7 @@ class ControllerTest extends CakeTestCase { $Controller->constructClasses(); $this->assertTrue(isset($Controller->TestPluginPost)); - $this->assertTrue($Controller->TestPluginPost instanceof TestPluginPost); + $this->assertInstanceOf('TestPluginPost', $Controller->TestPluginPost); } /** diff --git a/lib/Cake/Test/Case/Routing/RouterTest.php b/lib/Cake/Test/Case/Routing/RouterTest.php index f843bda03..f5a84c2df 100644 --- a/lib/Cake/Test/Case/Routing/RouterTest.php +++ b/lib/Cake/Test/Case/Routing/RouterTest.php @@ -2354,7 +2354,7 @@ class RouterTest extends CakeTestCase { array('controller' => 'posts', 'action' => 'view'), array('routeClass' => 'MockConnectedRoute', 'slug' => '[a-z_-]+') ); - $this->assertTrue($routes[0] instanceof MockConnectedRoute, 'Incorrect class used. %s'); + $this->assertInstanceOf('MockConnectedRoute', $routes[0], 'Incorrect class used. %s'); $expected = array('controller' => 'posts', 'action' => 'view', 'slug' => 'test'); $routes[0]->expects($this->any()) ->method('parse') diff --git a/lib/Cake/Test/Case/Utility/ClassRegistryTest.php b/lib/Cake/Test/Case/Utility/ClassRegistryTest.php index df656f652..7fa1ea818 100644 --- a/lib/Cake/Test/Case/Utility/ClassRegistryTest.php +++ b/lib/Cake/Test/Case/Utility/ClassRegistryTest.php @@ -136,7 +136,7 @@ class ClassRegistryTest extends CakeTestCase { */ public function testAddModel() { $Tag = ClassRegistry::init('RegisterArticleTag'); - $this->assertTrue($Tag instanceof RegisterArticleTag); + $this->assertInstanceOf('RegisterArticleTag', $Tag); $TagCopy = ClassRegistry::isKeySet('RegisterArticleTag'); $this->assertTrue($TagCopy); @@ -145,11 +145,11 @@ class ClassRegistryTest extends CakeTestCase { $TagCopy = ClassRegistry::getObject('RegisterArticleTag'); - $this->assertTrue($TagCopy instanceof RegisterArticleTag); + $this->assertInstanceOf('RegisterArticleTag', $TagCopy); $this->assertSame($Tag, $TagCopy); $NewTag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag')); - $this->assertTrue($Tag instanceof RegisterArticleTag); + $this->assertInstanceOf('RegisterArticleTag', $Tag); $NewTagCopy = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag')); @@ -166,17 +166,17 @@ class ClassRegistryTest extends CakeTestCase { $this->assertTrue($TagCopy->name === 'SomeOtherName'); $User = ClassRegistry::init(array('class' => 'RegisterUser', 'alias' => 'User', 'table' => false)); - $this->assertTrue($User instanceof AppModel); + $this->assertInstanceOf('AppModel', $User); $UserCopy = ClassRegistry::init(array('class' => 'RegisterUser', 'alias' => 'User', 'table' => false)); - $this->assertTrue($UserCopy instanceof AppModel); + $this->assertInstanceOf('AppModel', $UserCopy); $this->assertEquals($User, $UserCopy); $Category = ClassRegistry::init(array('class' => 'RegisterCategory')); - $this->assertTrue($Category instanceof RegisterCategory); + $this->assertTrue('RegisterCategory', $Category); $ParentCategory = ClassRegistry::init(array('class' => 'RegisterCategory', 'alias' => 'ParentCategory')); - $this->assertTrue($ParentCategory instanceof RegisterCategory); + $this->assertInstanceOf('RegisterCategory', $ParentCategory); $this->assertNotSame($Category, $ParentCategory); $this->assertNotEquals($Category->alias, $ParentCategory->alias); @@ -193,12 +193,12 @@ class ClassRegistryTest extends CakeTestCase { ClassRegistry::init('RegisterArticleTag'); $ArticleTag = ClassRegistry::getObject('RegisterArticleTag'); - $this->assertTrue($ArticleTag instanceof RegisterArticleTag); + $this->assertInstanceOf('RegisterArticleTag', $ArticleTag); ClassRegistry::flush(); $NoArticleTag = ClassRegistry::isKeySet('RegisterArticleTag'); $this->assertFalse($NoArticleTag); - $this->assertTrue($ArticleTag instanceof RegisterArticleTag); + $this->assertTrue('RegisterArticleTag', $ArticleTag); } /** @@ -233,13 +233,13 @@ class ClassRegistryTest extends CakeTestCase { $this->assertTrue($Tag); $Article = ClassRegistry::getObject('Article'); - $this->assertTrue($Article instanceof RegisterArticle); + $this->assertInstanceOf('RegisterArticle', $Article); $Featured = ClassRegistry::getObject('Featured'); - $this->assertTrue($Featured instanceof RegisterArticleFeatured); + $this->assertInstanceOf('RegisterArticleFeatured', $Featured); $Tag = ClassRegistry::getObject('Tag'); - $this->assertTrue($Tag instanceof RegisterArticleTag); + $this->assertInstanceOf('RegisterArticleTag', $Tag); } /** @@ -254,15 +254,15 @@ class ClassRegistryTest extends CakeTestCase { //Faking a plugin CakePlugin::load('RegistryPlugin', array('path' => '/fake/path')); $TestRegistryPluginModel = ClassRegistry::init('RegistryPlugin.TestRegistryPluginModel'); - $this->assertTrue($TestRegistryPluginModel instanceof TestRegistryPluginModel); + $this->assertInstanceOf('TestRegistryPluginModel', $TestRegistryPluginModel); $this->assertEquals('something_', $TestRegistryPluginModel->tablePrefix); $PluginUser = ClassRegistry::init(array('class' => 'RegistryPlugin.RegisterUser', 'alias' => 'RegistryPluginUser', 'table' => false)); - $this->assertTrue($PluginUser instanceof RegistryPluginAppModel); + $this->assertInstanceOf('RegistryPluginAppModel', $PluginUser); $PluginUserCopy = ClassRegistry::getObject('RegistryPluginUser'); - $this->assertTrue($PluginUserCopy instanceof RegistryPluginAppModel); + $this->assertInstanceOf('RegistryPluginAppModel', $PluginUserCopy); $this->assertSame($PluginUser, $PluginUserCopy); CakePlugin::unload(); } From 3e05ab897c8539a2a43534e99ad13820c6cbb8d8 Mon Sep 17 00:00:00 2001 From: Bryan Crowe Date: Tue, 24 Sep 2013 22:12:51 -0400 Subject: [PATCH 06/12] Missed a couple instanceOf asserations --- lib/Cake/Test/Case/Utility/ClassRegistryTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/ClassRegistryTest.php b/lib/Cake/Test/Case/Utility/ClassRegistryTest.php index 7fa1ea818..d358d790e 100644 --- a/lib/Cake/Test/Case/Utility/ClassRegistryTest.php +++ b/lib/Cake/Test/Case/Utility/ClassRegistryTest.php @@ -173,7 +173,7 @@ class ClassRegistryTest extends CakeTestCase { $this->assertEquals($User, $UserCopy); $Category = ClassRegistry::init(array('class' => 'RegisterCategory')); - $this->assertTrue('RegisterCategory', $Category); + $this->assertInstanceOf('RegisterCategory', $Category); $ParentCategory = ClassRegistry::init(array('class' => 'RegisterCategory', 'alias' => 'ParentCategory')); $this->assertInstanceOf('RegisterCategory', $ParentCategory); @@ -198,7 +198,7 @@ class ClassRegistryTest extends CakeTestCase { $NoArticleTag = ClassRegistry::isKeySet('RegisterArticleTag'); $this->assertFalse($NoArticleTag); - $this->assertTrue('RegisterArticleTag', $ArticleTag); + $this->assertInstanceOf('RegisterArticleTag', $ArticleTag); } /** From 2455af09c54a41a5d10f27040be9b313d6d35872 Mon Sep 17 00:00:00 2001 From: euromark Date: Wed, 25 Sep 2013 14:01:35 +0200 Subject: [PATCH 07/12] Resolves ticket #4100 --- .../Test/Case/View/Helper/FormHelperTest.php | 34 +++++++++++++++++++ lib/Cake/View/Helper/FormHelper.php | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 2ffdfcdbe..97dd8a0ae 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -3978,6 +3978,40 @@ class FormHelperTest extends CakeTestCase { '/div' ); $this->assertTags($result, $expected); + + $result = $this->Form->input('Model.field', array( + 'type' => 'radio', + 'options' => array( + 1 => 'A', + 2 => 'B', + 3 => 'C' + ), + 'disabled' => array(1) + )); + + $expected = array( + 'div' => array('class' => 'input radio'), + 'fieldset' => array(), + 'legend' => array(), + 'Field', + '/legend', + array('input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'id' => 'ModelField_', 'value' => '')), + array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'id' => 'ModelField1', 'disabled' => 'disabled', 'value' => '1')), + array('label' => array('for' => 'ModelField1')), + 'A', + '/label', + array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'id' => 'ModelField2', 'value' => '2')), + array('label' => array('for' => 'ModelField2')), + 'B', + '/label', + array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'id' => 'ModelField3', 'value' => '3')), + array('label' => array('for' => 'ModelField3')), + 'C', + '/label', + '/fieldset', + '/div' + ); + $this->assertTags($result, $expected); } /** diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 542655709..377728b8f 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -1506,7 +1506,7 @@ class FormHelper extends AppHelper { } foreach ($options as $optValue => $optTitle) { - $optionsHere = array('value' => $optValue); + $optionsHere = array('value' => $optValue, 'disabled' => false); if (isset($value) && strval($optValue) === strval($value)) { $optionsHere['checked'] = 'checked'; From 39bc8dff9729d917788f201471e59f8472e1c545 Mon Sep 17 00:00:00 2001 From: ber clausen Date: Wed, 25 Sep 2013 09:12:49 -0300 Subject: [PATCH 08/12] Wrong signature. --- lib/Cake/Model/Datasource/DataSource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Model/Datasource/DataSource.php b/lib/Cake/Model/Datasource/DataSource.php index 52ffbed9a..ceda8a4c8 100644 --- a/lib/Cake/Model/Datasource/DataSource.php +++ b/lib/Cake/Model/Datasource/DataSource.php @@ -232,7 +232,7 @@ class DataSource extends Object { * @param mixed $conditions The conditions to use for deleting. * @return boolean Success */ - public function delete(Model $model, $id = null) { + public function delete(Model $model, $conditions = null) { return false; } From 0ae69aace90c9219437839270b9db9605f39df65 Mon Sep 17 00:00:00 2001 From: euromark Date: Wed, 25 Sep 2013 19:40:14 +0200 Subject: [PATCH 09/12] App::import to App::uses --- lib/Cake/Console/Command/Task/TestTask.php | 2 +- lib/Cake/Network/Email/CakeEmail.php | 3 +-- lib/Cake/Utility/Sanitize.php | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Console/Command/Task/TestTask.php b/lib/Cake/Console/Command/Task/TestTask.php index 14776d278..3b8babf1f 100644 --- a/lib/Cake/Console/Command/Task/TestTask.php +++ b/lib/Cake/Console/Command/Task/TestTask.php @@ -279,7 +279,7 @@ class TestTask extends BakeTask { */ public function buildTestSubject($type, $class) { ClassRegistry::flush(); - App::import($type, $class); + App::uses($class, $type); $class = $this->getRealClassName($type, $class); if (strtolower($type) === 'model') { $instance = ClassRegistry::init($class); diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index 1b5f59f21..f0da7182f 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -24,7 +24,6 @@ App::uses('AbstractTransport', 'Network/Email'); App::uses('File', 'Utility'); App::uses('String', 'Utility'); App::uses('View', 'View'); -App::import('I18n', 'Multibyte'); /** * Cake e-mail class. @@ -980,7 +979,7 @@ class CakeEmail { * 'contentDisposition' => false * )); * }}} - * + * * Attach a file from string and specify additional properties: * * {{{ diff --git a/lib/Cake/Utility/Sanitize.php b/lib/Cake/Utility/Sanitize.php index 20f3a147d..5f8da1bbf 100644 --- a/lib/Cake/Utility/Sanitize.php +++ b/lib/Cake/Utility/Sanitize.php @@ -20,7 +20,7 @@ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ -App::import('Model', 'ConnectionManager'); +App::uses('ConnectionManager', 'Model'); /** * Data Sanitization. From 915b51b2391c4901604fb8ec21518ddcd757e1b3 Mon Sep 17 00:00:00 2001 From: Bryan Crowe Date: Wed, 25 Sep 2013 22:46:38 -0400 Subject: [PATCH 10/12] Updated JavaScript casing and JsHelper references in doc blocks --- app/Config/core.php | 4 ++-- lib/Cake/Console/Templates/skel/Config/core.php | 4 ++-- lib/Cake/Controller/Component/CookieComponent.php | 2 +- lib/Cake/Controller/Controller.php | 2 +- .../Test/Case/Controller/ControllerMergeVarsTest.php | 4 ++-- lib/Cake/Test/Case/View/Helper/JsHelperTest.php | 2 +- lib/Cake/View/Helper/HtmlHelper.php | 2 +- lib/Cake/View/Helper/JqueryEngineHelper.php | 8 ++++---- lib/Cake/View/Helper/JsBaseEngineHelper.php | 12 ++++++------ lib/Cake/View/Helper/MootoolsEngineHelper.php | 4 ++-- lib/Cake/View/Helper/PrototypeEngineHelper.php | 6 +++--- 11 files changed, 25 insertions(+), 25 deletions(-) diff --git a/app/Config/core.php b/app/Config/core.php index 99b3d744f..f6c16ff02 100644 --- a/app/Config/core.php +++ b/app/Config/core.php @@ -97,7 +97,7 @@ * /app/webroot/.htaccess * * And uncomment the App.baseUrl below. But keep in mind - * that plugin assets such as images, CSS and Javascript files + * that plugin assets such as images, CSS and JavaScript files * will not work without url rewriting! * To work around this issue you should either symlink or copy * the plugin assets into you app's webroot directory. This is @@ -254,7 +254,7 @@ * Plug in your own custom JavaScript compressor by dropping a script in your webroot to handle the * output, and setting the config below to the name of the script. * - * To use, prefix your JavaScript link URLs with '/cjs/' instead of '/js/' or use JavaScriptHelper::link(). + * To use, prefix your JavaScript link URLs with '/cjs/' instead of '/js/' or use JsHelper::link(). */ //Configure::write('Asset.filter.js', 'custom_javascript_output_filter.php'); diff --git a/lib/Cake/Console/Templates/skel/Config/core.php b/lib/Cake/Console/Templates/skel/Config/core.php index 012af933a..b867453ae 100644 --- a/lib/Cake/Console/Templates/skel/Config/core.php +++ b/lib/Cake/Console/Templates/skel/Config/core.php @@ -88,7 +88,7 @@ * /app/webroot/.htaccess * * And uncomment the App.baseUrl below. But keep in mind - * that plugin assets such as images, CSS and Javascript files + * that plugin assets such as images, CSS and JavaScript files * will not work without URL rewriting! * To work around this issue you should either symlink or copy * the plugin assets into you app's webroot directory. This is @@ -245,7 +245,7 @@ * Plug in your own custom JavaScript compressor by dropping a script in your webroot to handle the * output, and setting the config below to the name of the script. * - * To use, prefix your JavaScript link URLs with '/cjs/' instead of '/js/' or use JavaScriptHelper::link(). + * To use, prefix your JavaScript link URLs with '/cjs/' instead of '/js/' or use JsHelper::link(). */ //Configure::write('Asset.filter.js', 'custom_javascript_output_filter.php'); diff --git a/lib/Cake/Controller/Component/CookieComponent.php b/lib/Cake/Controller/Component/CookieComponent.php index e2831783d..4259f7e9f 100644 --- a/lib/Cake/Controller/Component/CookieComponent.php +++ b/lib/Cake/Controller/Component/CookieComponent.php @@ -112,7 +112,7 @@ class CookieComponent extends Component { * HTTP only cookie * * Set to true to make HTTP only cookies. Cookies that are HTTP only - * are not accessible in Javascript. + * are not accessible in JavaScript. * * @var boolean */ diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index eb54a385a..15ce9ff32 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -88,7 +88,7 @@ class Controller extends Object implements CakeEventListener { * An array containing the names of helpers this controller uses. The array elements should * not contain the "Helper" part of the classname. * - * Example: `public $helpers = array('Html', 'Javascript', 'Time', 'Ajax');` + * Example: `public $helpers = array('Html', 'JavaScript', 'Time', 'Ajax');` * * @var mixed A single name as a string or a list of names as an array. * @link http://book.cakephp.org/2.0/en/controllers.html#components-helpers-and-uses diff --git a/lib/Cake/Test/Case/Controller/ControllerMergeVarsTest.php b/lib/Cake/Test/Case/Controller/ControllerMergeVarsTest.php index c41165a12..1a34c3ef6 100644 --- a/lib/Cake/Test/Case/Controller/ControllerMergeVarsTest.php +++ b/lib/Cake/Test/Case/Controller/ControllerMergeVarsTest.php @@ -94,7 +94,7 @@ class MergeVarPluginAppController extends MergeVarsAppController { * * @var array */ - public $helpers = array('Javascript'); + public $helpers = array('JavaScript'); /** * parent for mergeVars @@ -205,7 +205,7 @@ class ControllerMergeVarsTest extends CakeTestCase { $expected = array( 'MergeVar' => array('format' => 'html', 'terse'), - 'Javascript' => null + 'JavaScript' => null ); $this->assertEquals($expected, $Controller->helpers, 'Helpers are unexpected.'); diff --git a/lib/Cake/Test/Case/View/Helper/JsHelperTest.php b/lib/Cake/Test/Case/View/Helper/JsHelperTest.php index 9171db832..95279c903 100644 --- a/lib/Cake/Test/Case/View/Helper/JsHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/JsHelperTest.php @@ -699,7 +699,7 @@ class JsHelperTest extends CakeTestCase { } /** - * test set()'ing variables to the Javascript buffer and controlling the output var name. + * test set()'ing variables to the JavaScript buffer and controlling the output var name. * * @return void */ diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index 7a704c108..79d7147cc 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -618,7 +618,7 @@ class HtmlHelper extends AppHelper { } /** - * End a Buffered section of Javascript capturing. + * End a Buffered section of JavaScript capturing. * Generates a script tag inline or in `$scripts_for_layout` depending on the settings * used when the scriptBlock was started * diff --git a/lib/Cake/View/Helper/JqueryEngineHelper.php b/lib/Cake/View/Helper/JqueryEngineHelper.php index b72144a0c..fe5bc77e5 100644 --- a/lib/Cake/View/Helper/JqueryEngineHelper.php +++ b/lib/Cake/View/Helper/JqueryEngineHelper.php @@ -2,7 +2,7 @@ /** * jQuery Engine Helper for JsHelper * - * Provides jQuery specific Javascript for JsHelper. + * Provides jQuery specific JavaScript for JsHelper. * * Implements the JsHelper interface for jQuery. All $options arrays * support all options found in the JsHelper, as well as those in the jQuery @@ -30,7 +30,7 @@ App::uses('JsBaseEngineHelper', 'View/Helper'); /** * jQuery Engine Helper for JsHelper * - * Provides jQuery specific Javascript for JsHelper. + * Provides jQuery specific JavaScript for JsHelper. * * Implements the JsHelper interface for jQuery. All $options arrays * support all options found in the JsHelper, as well as those in the jQuery @@ -167,7 +167,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper { * - 'stop' - Whether you want the event to stopped. (defaults true) * * @param string $type Type of event to bind to the current dom id - * @param string $callback The Javascript function you wish to trigger or the function literal + * @param string $callback The JavaScript function you wish to trigger or the function literal * @param array $options Options for the event. * @return string completed event handler */ @@ -340,7 +340,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper { /** * Serialize a form attached to $selector. If the current selection is not an input or - * form, errors will be created in the Javascript. + * form, errors will be created in the JavaScript. * * @param array $options Options for the serialization * @return string completed form serialization script. diff --git a/lib/Cake/View/Helper/JsBaseEngineHelper.php b/lib/Cake/View/Helper/JsBaseEngineHelper.php index a7afce88c..29aeba971 100644 --- a/lib/Cake/View/Helper/JsBaseEngineHelper.php +++ b/lib/Cake/View/Helper/JsBaseEngineHelper.php @@ -57,7 +57,7 @@ abstract class JsBaseEngineHelper extends AppHelper { protected $_callbackArguments = array(); /** - * Create an `alert()` message in Javascript + * Create an `alert()` message in JavaScript * * @param string $message Message you want to alter. * @return string completed alert() @@ -68,7 +68,7 @@ abstract class JsBaseEngineHelper extends AppHelper { /** * Redirects to an URL. Creates a window.location modification snippet - * that can be used to trigger 'redirects' from Javascript. + * that can be used to trigger 'redirects' from JavaScript. * * @param string|array $url URL * @return string completed redirect in javascript @@ -101,7 +101,7 @@ abstract class JsBaseEngineHelper extends AppHelper { } /** - * Create a `prompt()` Javascript function + * Create a `prompt()` JavaScript function * * @param string $message Message you want to prompt. * @param string $default Default message @@ -297,7 +297,7 @@ abstract class JsBaseEngineHelper extends AppHelper { * - `stop` - Whether you want the event to stopped. (defaults to true) * * @param string $type Type of event to bind to the current dom id - * @param string $callback The Javascript function you wish to trigger or the function literal + * @param string $callback The JavaScript function you wish to trigger or the function literal * @param array $options Options for the event. * @return string completed event handler */ @@ -363,7 +363,7 @@ abstract class JsBaseEngineHelper extends AppHelper { * - `type` - Data type for response. 'json' and 'html' are supported. Default is html for most libraries. * - `evalScripts` - Whether or not