From 111366d5c856e5cb27b60c50c11f6deb69344570 Mon Sep 17 00:00:00 2001 From: euromark Date: Tue, 12 Feb 2013 03:38:08 +0100 Subject: [PATCH] == to === and != to !== where applicable --- lib/Cake/Cache/Engine/MemcacheEngine.php | 4 +- lib/Cake/Configure/IniReader.php | 2 +- lib/Cake/Console/Command/AclShell.php | 6 +-- .../Console/Command/Task/ControllerTask.php | 20 +++---- .../Console/Command/Task/DbConfigTask.php | 18 +++---- lib/Cake/Console/Command/Task/ExtractTask.php | 20 +++---- lib/Cake/Console/Command/Task/FixtureTask.php | 14 ++--- lib/Cake/Console/Command/Task/ModelTask.php | 54 +++++++++---------- lib/Cake/Console/Command/Task/PluginTask.php | 2 +- lib/Cake/Console/Command/Task/TestTask.php | 26 ++++----- lib/Cake/Console/Command/Task/ViewTask.php | 12 ++--- lib/Cake/Console/Command/TestShell.php | 2 +- lib/Cake/Console/Command/TestsuiteShell.php | 6 +-- lib/Cake/Console/ConsoleOptionParser.php | 8 +-- lib/Cake/Console/ConsoleOutput.php | 2 +- lib/Cake/Console/Shell.php | 10 ++-- lib/Cake/Console/ShellDispatcher.php | 4 +- .../Templates/default/classes/model.ctp | 2 +- .../Console/Templates/skel/webroot/index.php | 2 +- .../Component/Auth/ControllerAuthorize.php | 2 +- .../Component/Auth/DigestAuthenticate.php | 4 +- .../Component/RequestHandlerComponent.php | 4 +- lib/Cake/Controller/Controller.php | 6 +-- lib/Cake/Controller/Scaffold.php | 6 +-- lib/Cake/Core/App.php | 8 +-- lib/Cake/Error/ErrorHandler.php | 2 +- lib/Cake/Error/ExceptionRenderer.php | 4 +- lib/Cake/I18n/I18n.php | 4 +- lib/Cake/I18n/Multibyte.php | 2 +- lib/Cake/Log/Engine/ConsoleLog.php | 2 +- lib/Cake/Log/Engine/FileLog.php | 2 +- .../Model/Behavior/ContainableBehavior.php | 8 +-- lib/Cake/Model/BehaviorCollection.php | 2 +- lib/Cake/Model/CakeSchema.php | 10 ++-- .../Model/Datasource/Database/Postgres.php | 28 +++++----- lib/Cake/Model/Datasource/Database/Sqlite.php | 6 +-- .../Model/Datasource/Database/Sqlserver.php | 20 +++---- lib/Cake/Model/Datasource/DboSource.php | 8 +-- lib/Cake/Model/Model.php | 10 ++-- lib/Cake/Model/Permission.php | 4 +- .../Model/Validator/CakeValidationRule.php | 2 +- lib/Cake/Network/CakeRequest.php | 10 ++-- lib/Cake/Network/CakeSocket.php | 2 +- lib/Cake/Network/Email/CakeEmail.php | 2 +- lib/Cake/Network/Http/HttpSocket.php | 6 +-- lib/Cake/Routing/Router.php | 8 +-- lib/Cake/Test/Case/BasicsTest.php | 4 +- lib/Cake/Test/Case/Cache/CacheTest.php | 2 +- .../Controller/Component/Acl/DbAclTest.php | 4 +- .../Component/PaginatorComponentTest.php | 6 +-- .../Test/Case/Controller/ControllerTest.php | 2 +- .../Test/Case/Log/Engine/ConsoleLogTest.php | 2 +- lib/Cake/Test/Case/Model/AclNodeTest.php | 4 +- .../Case/Model/BehaviorCollectionTest.php | 18 +++---- .../Model/Datasource/Database/MysqlTest.php | 2 +- lib/Cake/Test/Case/Model/models.php | 2 +- .../Test/Case/Network/CakeRequestTest.php | 2 +- lib/Cake/Test/Case/Routing/DispatcherTest.php | 4 +- lib/Cake/Test/Case/Routing/RouterTest.php | 2 +- lib/Cake/Test/Case/Utility/FileTest.php | 2 +- .../Lib/Cache/Engine/TestAppCacheEngine.php | 2 +- lib/Cake/TestSuite/CakeTestCase.php | 4 +- lib/Cake/TestSuite/ControllerTestCase.php | 6 +-- .../TestSuite/Coverage/HtmlCoverageReport.php | 6 +-- lib/Cake/Utility/CakeNumber.php | 6 +-- lib/Cake/Utility/CakeTime.php | 10 ++-- lib/Cake/Utility/Debugger.php | 10 ++-- lib/Cake/Utility/File.php | 2 +- lib/Cake/Utility/Folder.php | 6 +-- lib/Cake/Utility/Hash.php | 2 +- lib/Cake/Utility/Inflector.php | 2 +- lib/Cake/Utility/Security.php | 4 +- lib/Cake/Utility/String.php | 2 +- lib/Cake/Utility/Validation.php | 4 +- .../View/Elements/exception_stack_trace.ctp | 2 +- lib/Cake/View/Helper.php | 2 +- lib/Cake/View/Helper/CacheHelper.php | 2 +- lib/Cake/View/Helper/FormHelper.php | 22 ++++---- lib/Cake/View/Helper/HtmlHelper.php | 2 +- lib/Cake/View/Helper/JqueryEngineHelper.php | 4 +- lib/Cake/View/Helper/MootoolsEngineHelper.php | 8 +-- lib/Cake/View/Helper/PaginatorHelper.php | 6 +-- .../View/Helper/PrototypeEngineHelper.php | 12 ++--- lib/Cake/View/Helper/RssHelper.php | 2 +- lib/Cake/View/Helper/SessionHelper.php | 2 +- lib/Cake/View/ScaffoldView.php | 2 +- lib/Cake/View/Scaffolds/form.ctp | 2 +- lib/Cake/View/View.php | 2 +- lib/Cake/basics.php | 4 +- 89 files changed, 291 insertions(+), 291 deletions(-) diff --git a/lib/Cake/Cache/Engine/MemcacheEngine.php b/lib/Cake/Cache/Engine/MemcacheEngine.php index 674cbb4706e..788ff208dfe 100644 --- a/lib/Cake/Cache/Engine/MemcacheEngine.php +++ b/lib/Cake/Cache/Engine/MemcacheEngine.php @@ -106,10 +106,10 @@ public function init($settings = array()) { * @return array Array containing host, port */ protected function _parseServerString($server) { - if ($server[0] == 'u') { + if ($server[0] === 'u') { return array($server, 0); } - if (substr($server, 0, 1) == '[') { + if (substr($server, 0, 1) === '[') { $position = strpos($server, ']:'); if ($position !== false) { $position++; diff --git a/lib/Cake/Configure/IniReader.php b/lib/Cake/Configure/IniReader.php index d1a1e289ab6..f1485b16ee8 100644 --- a/lib/Cake/Configure/IniReader.php +++ b/lib/Cake/Configure/IniReader.php @@ -160,7 +160,7 @@ public function dump($key, $data) { $result = array(); foreach ($data as $k => $value) { $isSection = false; - if ($k[0] != '[') { + if ($k[0] !== '[') { $result[] = "[$k]"; $isSection = true; } diff --git a/lib/Cake/Console/Command/AclShell.php b/lib/Cake/Console/Command/AclShell.php index f16a31ecba8..8e3297c9be3 100644 --- a/lib/Cake/Console/Command/AclShell.php +++ b/lib/Cake/Console/Command/AclShell.php @@ -122,14 +122,14 @@ public function create() { $class = ucfirst($this->args[0]); $parent = $this->parseIdentifier($this->args[1]); - if (!empty($parent) && $parent != '/' && $parent != 'root') { + if (!empty($parent) && $parent !== '/' && $parent !== 'root') { $parent = $this->_getNodeId($class, $parent); } else { $parent = null; } $data = $this->parseIdentifier($this->args[2]); - if (is_string($data) && $data != '/') { + if (is_string($data) && $data !== '/') { $data = array('alias' => $data); } elseif (is_string($data)) { $this->error(__d('cake_console', '/ can not be used as an alias!') . __d('cake_console', " / is the root, please supply a sub alias")); @@ -604,7 +604,7 @@ protected function _dataVars($type = null) { } $vars = array(); $class = ucwords($type); - $vars['secondary_id'] = (strtolower($class) == 'aro') ? 'foreign_key' : 'object_id'; + $vars['secondary_id'] = (strtolower($class) === 'aro') ? 'foreign_key' : 'object_id'; $vars['data_name'] = $type; $vars['table_name'] = $type . 's'; $vars['class'] = $class; diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index 711365dcd6a..48a1ea1da0d 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -66,7 +66,7 @@ public function execute() { if (!isset($this->connection)) { $this->connection = 'default'; } - if (strtolower($this->args[0]) == 'all') { + if (strtolower($this->args[0]) === 'all') { return $this->all(); } @@ -162,13 +162,13 @@ protected function _interactive() { } $doItInteractive = $this->in(implode("\n", $question), array('y', 'n'), 'y'); - if (strtolower($doItInteractive) == 'y') { + if (strtolower($doItInteractive) === 'y') { $this->interactive = true; $useDynamicScaffold = $this->in( __d('cake_console', "Would you like to use dynamic scaffolding?"), array('y', 'n'), 'n' ); - if (strtolower($useDynamicScaffold) == 'y') { + if (strtolower($useDynamicScaffold) === 'y') { $wannaBakeCrud = 'n'; $actions = 'scaffold'; } else { @@ -185,12 +185,12 @@ protected function _interactive() { list($wannaBakeCrud, $wannaBakeAdminCrud) = $this->_askAboutMethods(); } - if (strtolower($wannaBakeCrud) == 'y') { - $actions = $this->bakeActions($controllerName, null, strtolower($wannaUseSession) == 'y'); + if (strtolower($wannaBakeCrud) === 'y') { + $actions = $this->bakeActions($controllerName, null, strtolower($wannaUseSession) === 'y'); } - if (strtolower($wannaBakeAdminCrud) == 'y') { + if (strtolower($wannaBakeAdminCrud) === 'y') { $admin = $this->Project->getPrefix(); - $actions .= $this->bakeActions($controllerName, $admin, strtolower($wannaUseSession) == 'y'); + $actions .= $this->bakeActions($controllerName, $admin, strtolower($wannaUseSession) === 'y'); } $baked = false; @@ -198,7 +198,7 @@ protected function _interactive() { $this->confirmController($controllerName, $useDynamicScaffold, $helpers, $components); $looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y','n'), 'y'); - if (strtolower($looksGood) == 'y') { + if (strtolower($looksGood) === 'y') { $baked = $this->bake($controllerName, $actions, $helpers, $components); if ($baked && $this->_checkUnitTest()) { $this->bakeTest($controllerName); @@ -229,7 +229,7 @@ public function confirmController($controllerName, $useDynamicScaffold, $helpers $this->hr(); $this->out(__d('cake_console', "Controller Name:\n\t%s", $controllerName)); - if (strtolower($useDynamicScaffold) == 'y') { + if (strtolower($useDynamicScaffold) === 'y') { $this->out("public \$scaffold;"); } @@ -386,7 +386,7 @@ public function doComponents() { protected function _doPropertyChoices($prompt, $example) { $proceed = $this->in($prompt, array('y','n'), 'n'); $property = array(); - if (strtolower($proceed) == 'y') { + if (strtolower($proceed) === 'y') { $propertyList = $this->in($example); $propertyListTrimmed = str_replace(' ', '', $propertyList); $property = explode(',', $propertyListTrimmed); diff --git a/lib/Cake/Console/Command/Task/DbConfigTask.php b/lib/Cake/Console/Command/Task/DbConfigTask.php index 2d493c8aa44..1947f18b6d6 100644 --- a/lib/Cake/Console/Command/Task/DbConfigTask.php +++ b/lib/Cake/Console/Command/Task/DbConfigTask.php @@ -110,7 +110,7 @@ protected function _interactive() { $datasource = $this->in(__d('cake_console', 'Datasource:'), array('Mysql', 'Postgres', 'Sqlite', 'Sqlserver'), 'Mysql'); $persistent = $this->in(__d('cake_console', 'Persistent Connection?'), array('y', 'n'), 'n'); - if (strtolower($persistent) == 'n') { + if (strtolower($persistent) === 'n') { $persistent = 'false'; } else { $persistent = 'true'; @@ -126,7 +126,7 @@ protected function _interactive() { $port = $this->in(__d('cake_console', 'Port?'), null, 'n'); } - if (strtolower($port) == 'n') { + if (strtolower($port) === 'n') { $port = null; } @@ -142,7 +142,7 @@ protected function _interactive() { if (!$password) { $blank = $this->in(__d('cake_console', 'The password you supplied was empty. Use an empty password?'), array('y', 'n'), 'n'); - if ($blank == 'y') { + if ($blank === 'y') { $blankPassword = true; } } @@ -157,7 +157,7 @@ protected function _interactive() { while (!$prefix) { $prefix = $this->in(__d('cake_console', 'Table Prefix?'), null, 'n'); } - if (strtolower($prefix) == 'n') { + if (strtolower($prefix) === 'n') { $prefix = null; } @@ -165,17 +165,17 @@ protected function _interactive() { while (!$encoding) { $encoding = $this->in(__d('cake_console', 'Table encoding?'), null, 'n'); } - if (strtolower($encoding) == 'n') { + if (strtolower($encoding) === 'n') { $encoding = null; } $schema = ''; - if ($datasource == 'postgres') { + if ($datasource === 'postgres') { while (!$schema) { $schema = $this->in(__d('cake_console', 'Table schema?'), null, 'n'); } } - if (strtolower($schema) == 'n') { + if (strtolower($schema) === 'n') { $schema = null; } @@ -188,7 +188,7 @@ protected function _interactive() { $dbConfigs[] = $config; $doneYet = $this->in(__d('cake_console', 'Do you wish to add another database configuration?'), null, 'n'); - if (strtolower($doneYet == 'n')) { + if (strtolower($doneYet === 'n')) { $done = true; } } @@ -239,7 +239,7 @@ protected function _verify($config) { $this->hr(); $looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n'), 'y'); - if (strtolower($looksGood) == 'y') { + if (strtolower($looksGood) === 'y') { return $config; } return false; diff --git a/lib/Cake/Console/Command/Task/ExtractTask.php b/lib/Cake/Console/Command/Task/ExtractTask.php index eb40822b761..1949f08a8e3 100644 --- a/lib/Cake/Console/Command/Task/ExtractTask.php +++ b/lib/Cake/Console/Command/Task/ExtractTask.php @@ -388,14 +388,14 @@ protected function _parse($functionName, $map) { } list($type, $string, $line) = $countToken; - if (($type == T_STRING) && ($string == $functionName) && ($firstParenthesis == '(')) { + if (($type == T_STRING) && ($string == $functionName) && ($firstParenthesis === '(')) { $position = $count; $depth = 0; while (!$depth) { - if ($this->_tokens[$position] == '(') { + if ($this->_tokens[$position] === '(') { $depth++; - } elseif ($this->_tokens[$position] == ')') { + } elseif ($this->_tokens[$position] === ')') { $depth--; } $position++; @@ -537,7 +537,7 @@ protected function _buildFiles() { } $this->_store($domain, $header, $sentence); - if ($domain != 'default' && $this->_merge) { + if ($domain !== 'default' && $this->_merge) { $this->_store('default', $header, $sentence); } } @@ -640,11 +640,11 @@ protected function _writeHeader() { protected function _getStrings(&$position, $target) { $strings = array(); $count = count($strings); - while ($count < $target && ($this->_tokens[$position] == ',' || $this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING)) { + while ($count < $target && ($this->_tokens[$position] === ',' || $this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING)) { $count = count($strings); - if ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING && $this->_tokens[$position + 1] == '.') { + if ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING && $this->_tokens[$position + 1] === '.') { $string = ''; - while ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING || $this->_tokens[$position] == '.') { + while ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING || $this->_tokens[$position] === '.') { if ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING) { $string .= $this->_formatString($this->_tokens[$position][1]); } @@ -668,7 +668,7 @@ protected function _getStrings(&$position, $target) { protected function _formatString($string) { $quote = substr($string, 0, 1); $string = substr($string, 1, -1); - if ($quote == '"') { + if ($quote === '"') { $string = stripcslashes($string); } else { $string = strtr($string, array("\\'" => "'", "\\\\" => "\\")); @@ -697,11 +697,11 @@ protected function _markerError($file, $line, $marker, $count) { $this->out($this->_tokens[$count][1], false); } else { $this->out($this->_tokens[$count], false); - if ($this->_tokens[$count] == '(') { + if ($this->_tokens[$count] === '(') { $parenthesis++; } - if ($this->_tokens[$count] == ')') { + if ($this->_tokens[$count] === ')') { $parenthesis--; } } diff --git a/lib/Cake/Console/Command/Task/FixtureTask.php b/lib/Cake/Console/Command/Task/FixtureTask.php index b4add6a4bc2..74120557376 100644 --- a/lib/Cake/Console/Command/Task/FixtureTask.php +++ b/lib/Cake/Console/Command/Task/FixtureTask.php @@ -107,7 +107,7 @@ public function execute() { if (!isset($this->connection)) { $this->connection = 'default'; } - if (strtolower($this->args[0]) == 'all') { + if (strtolower($this->args[0]) === 'all') { return $this->all(); } $model = $this->_modelName($this->args[0]); @@ -159,17 +159,17 @@ protected function _interactive() { public function importOptions($modelName) { $options = array(); $doSchema = $this->in(__d('cake_console', 'Would you like to import schema for this fixture?'), array('y', 'n'), 'n'); - if ($doSchema == 'y') { + if ($doSchema === 'y') { $options['schema'] = $modelName; } $doRecords = $this->in(__d('cake_console', 'Would you like to use record importing for this fixture?'), array('y', 'n'), 'n'); - if ($doRecords == 'y') { + if ($doRecords === 'y') { $options['records'] = true; } - if ($doRecords == 'n') { + if ($doRecords === 'n') { $prompt = __d('cake_console', "Would you like to build this fixture with data from %s's table?", $modelName); $fromTable = $this->in($prompt, array('y', 'n'), 'n'); - if (strtolower($fromTable) == 'y') { + if (strtolower($fromTable) === 'y') { $options['fromTable'] = true; } } @@ -203,7 +203,7 @@ public function bake($model, $useTable = false, $importOptions = array()) { if (isset($importOptions['records'])) { $importBits[] = "'records' => true"; } - if ($this->connection != 'default') { + if ($this->connection !== 'default') { $importBits[] .= "'connection' => '{$this->connection}'"; } if (!empty($importBits)) { @@ -307,7 +307,7 @@ protected function _generateRecords($tableInfo, $recordCount = 1) { case 'string': case 'binary': $isPrimaryUuid = ( - isset($fieldInfo['key']) && strtolower($fieldInfo['key']) == 'primary' && + isset($fieldInfo['key']) && strtolower($fieldInfo['key']) === 'primary' && isset($fieldInfo['length']) && $fieldInfo['length'] == 36 ); if ($isPrimaryUuid) { diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index bb71a4805b4..01a0ff95a7d 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -98,7 +98,7 @@ public function execute() { if (!isset($this->connection)) { $this->connection = 'default'; } - if (strtolower($this->args[0]) == 'all') { + if (strtolower($this->args[0]) === 'all') { return $this->all(); } $model = $this->_modelName($this->args[0]); @@ -150,7 +150,7 @@ protected function _getModelObject($className, $table = null) { $object = new Model(array('name' => $className, 'table' => $table, 'ds' => $this->connection)); $fields = $object->schema(true); foreach ($fields as $name => $field) { - if (isset($field['key']) && $field['key'] == 'primary') { + if (isset($field['key']) && $field['key'] === 'primary') { $object->primaryKey = $name; break; } @@ -209,7 +209,7 @@ protected function _interactive() { if (!in_array($useTable, $this->_tables)) { $prompt = __d('cake_console', "The table %s doesn't exist or could not be automatically detected\ncontinue anyway?", $useTable); $continue = $this->in($prompt, array('y', 'n')); - if (strtolower($continue) == 'n') { + if (strtolower($continue) === 'n') { return false; } } @@ -235,13 +235,13 @@ protected function _interactive() { $prompt = __d('cake_console', "Would you like to supply validation criteria \nfor the fields in your model?"); $wannaDoValidation = $this->in($prompt, array('y','n'), 'y'); - if (array_search($useTable, $this->_tables) !== false && strtolower($wannaDoValidation) == 'y') { + if (array_search($useTable, $this->_tables) !== false && strtolower($wannaDoValidation) === 'y') { $validate = $this->doValidation($tempModel); } $prompt = __d('cake_console', "Would you like to define model associations\n(hasMany, hasOne, belongsTo, etc.)?"); $wannaDoAssoc = $this->in($prompt, array('y','n'), 'y'); - if (strtolower($wannaDoAssoc) == 'y') { + if (strtolower($wannaDoAssoc) === 'y') { $associations = $this->doAssociations($tempModel); } } @@ -258,7 +258,7 @@ protected function _interactive() { if ($fullTableName !== Inflector::tableize($currentModelName)) { $this->out(__d('cake_console', 'DB Table: %s', $fullTableName)); } - if ($primaryKey != 'id') { + if ($primaryKey !== 'id') { $this->out(__d('cake_console', 'Primary Key: %s', $primaryKey)); } if (!empty($validate)) { @@ -275,7 +275,7 @@ protected function _interactive() { $this->hr(); $looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n'), 'y'); - if (strtolower($looksGood) == 'y') { + if (strtolower($looksGood) === 'y') { $vars = compact('associations', 'validate', 'primaryKey', 'useTable', 'displayField'); $vars['useDbConfig'] = $this->connection; if ($this->bake($currentModelName, $vars)) { @@ -315,7 +315,7 @@ protected function _printAssociation($modelName, $type, $associations) { public function findPrimaryKey($fields) { $name = 'id'; foreach ($fields as $name => $field) { - if (isset($field['key']) && $field['key'] == 'primary') { + if (isset($field['key']) && $field['key'] === 'primary') { break; } } @@ -332,7 +332,7 @@ public function findDisplayField($fields) { $fieldNames = array_keys($fields); $prompt = __d('cake_console', "A displayField could not be automatically detected\nwould you like to choose one?"); $continue = $this->in($prompt, array('y', 'n')); - if (strtolower($continue) == 'n') { + if (strtolower($continue) === 'n') { return false; } $prompt = __d('cake_console', 'Choose a field from the options above:'); @@ -379,7 +379,7 @@ public function initValidations() { sort($options); $default = 1; foreach ($options as $option) { - if ($option{0} != '_') { + if ($option{0} !== '_') { $choices[$default] = strtolower($option); $default++; } @@ -402,7 +402,7 @@ public function fieldValidation($fieldName, $metaData, $primaryKey = 'id') { $validate = $alreadyChosen = array(); $anotherValidator = 'y'; - while ($anotherValidator == 'y') { + while ($anotherValidator === 'y') { if ($this->interactive) { $this->out(); $this->out(__d('cake_console', 'Field: %s', $fieldName)); @@ -428,25 +428,25 @@ public function fieldValidation($fieldName, $metaData, $primaryKey = 'id') { $methods = array_flip($this->_validations); $guess = $defaultChoice; if ($metaData['null'] != 1 && !in_array($fieldName, array($primaryKey, 'created', 'modified', 'updated'))) { - if ($fieldName == 'email') { + if ($fieldName === 'email') { $guess = $methods['email']; - } elseif ($metaData['type'] == 'string' && $metaData['length'] == 36) { + } elseif ($metaData['type'] === 'string' && $metaData['length'] == 36) { $guess = $methods['uuid']; - } elseif ($metaData['type'] == 'string') { + } elseif ($metaData['type'] === 'string') { $guess = $methods['notempty']; - } elseif ($metaData['type'] == 'text') { + } elseif ($metaData['type'] === 'text') { $guess = $methods['notempty']; - } elseif ($metaData['type'] == 'integer') { + } elseif ($metaData['type'] === 'integer') { $guess = $methods['numeric']; - } elseif ($metaData['type'] == 'boolean') { + } elseif ($metaData['type'] === 'boolean') { $guess = $methods['boolean']; - } elseif ($metaData['type'] == 'date') { + } elseif ($metaData['type'] === 'date') { $guess = $methods['date']; - } elseif ($metaData['type'] == 'time') { + } elseif ($metaData['type'] === 'time') { $guess = $methods['time']; - } elseif ($metaData['type'] == 'datetime') { + } elseif ($metaData['type'] === 'datetime') { $guess = $methods['datetime']; - } elseif ($metaData['type'] == 'inet') { + } elseif ($metaData['type'] === 'inet') { $guess = $methods['ip']; } } @@ -549,14 +549,14 @@ public function findBelongsTo(Model $model, $associations) { $fieldNames = array_keys($model->schema(true)); foreach ($fieldNames as $fieldName) { $offset = strpos($fieldName, '_id'); - if ($fieldName != $model->primaryKey && $fieldName != 'parent_id' && $offset !== false) { + if ($fieldName != $model->primaryKey && $fieldName !== 'parent_id' && $offset !== false) { $tmpModelName = $this->_modelNameFromKey($fieldName); $associations['belongsTo'][] = array( 'alias' => $tmpModelName, 'className' => $tmpModelName, 'foreignKey' => $fieldName, ); - } elseif ($fieldName == 'parent_id') { + } elseif ($fieldName === 'parent_id') { $associations['belongsTo'][] = array( 'alias' => 'Parent' . $model->name, 'className' => $model->name, @@ -593,7 +593,7 @@ public function findHasOneAndMany(Model $model, $associations) { 'className' => $tempOtherModel->name, 'foreignKey' => $fieldName ); - } elseif ($otherTable == $model->table && $fieldName == 'parent_id') { + } elseif ($otherTable == $model->table && $fieldName === 'parent_id') { $assoc = array( 'alias' => 'Child' . $model->name, 'className' => $model->name, @@ -659,7 +659,7 @@ public function confirmAssociations(Model $model, $associations) { if ('n' == strtolower($response)) { unset($associations[$type][$i]); - } elseif ($type == 'hasMany') { + } elseif ($type === 'hasMany') { unset($associations['hasOne'][$i]); } } @@ -755,7 +755,7 @@ protected function _generatePossibleKeys() { $tempOtherModel = new Model(array('table' => $otherTable, 'ds' => $this->connection)); $modelFieldsTemp = $tempOtherModel->schema(true); foreach ($modelFieldsTemp as $fieldName => $field) { - if ($field['type'] == 'integer' || $field['type'] == 'string') { + if ($field['type'] === 'integer' || $field['type'] === 'string') { $possible[$otherTable][] = $fieldName; } } @@ -877,7 +877,7 @@ public function getTable($modelName, $useDbConfig = null) { $this->out(__d('cake_console', "Given your model named '%s',\nCake would expect a database table named '%s'", $modelName, $fullTableName)); $tableIsGood = $this->in(__d('cake_console', 'Do you want to use this table?'), array('y', 'n'), 'y'); } - if (strtolower($tableIsGood) == 'n') { + if (strtolower($tableIsGood) === 'n') { $useTable = $this->in(__d('cake_console', 'What is the name of the table?')); } } diff --git a/lib/Cake/Console/Command/Task/PluginTask.php b/lib/Cake/Console/Command/Task/PluginTask.php index 0ee7e6034b1..e6668509ad8 100644 --- a/lib/Cake/Console/Command/Task/PluginTask.php +++ b/lib/Cake/Console/Command/Task/PluginTask.php @@ -107,7 +107,7 @@ public function bake($plugin) { $looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n', 'q'), 'y'); - if (strtolower($looksGood) == 'y') { + if (strtolower($looksGood) === 'y') { $Folder = new Folder($this->path . $plugin); $directories = array( 'Config' . DS . 'Schema', diff --git a/lib/Cake/Console/Command/Task/TestTask.php b/lib/Cake/Console/Command/Task/TestTask.php index d80e0da2d7a..bba7573da32 100644 --- a/lib/Cake/Console/Command/Task/TestTask.php +++ b/lib/Cake/Console/Command/Task/TestTask.php @@ -198,7 +198,7 @@ public function getObjectType() { } $keys[] = 'q'; $selection = $this->in(__d('cake_console', 'Enter the type of object to bake a test for or (q)uit'), $keys, 'q'); - if ($selection == 'q') { + if ($selection === 'q') { return $this->_stop(); } $types = array_keys($this->classTypes); @@ -281,7 +281,7 @@ public function &buildTestSubject($type, $class) { ClassRegistry::flush(); App::import($type, $class); $class = $this->getRealClassName($type, $class); - if (strtolower($type) == 'model') { + if (strtolower($type) === 'model') { $instance = ClassRegistry::init($class); } else { $instance = new $class(); @@ -298,7 +298,7 @@ public function &buildTestSubject($type, $class) { * @return string Real classname */ public function getRealClassName($type, $class) { - if (strtolower($type) == 'model' || empty($this->classTypes[$type])) { + if (strtolower($type) === 'model' || empty($this->classTypes[$type])) { return $class; } @@ -358,7 +358,7 @@ public function getTestableMethods($className) { $thisMethods = array_diff($classMethods, $parentMethods); $out = array(); foreach ($thisMethods as $method) { - if (substr($method, 0, 1) != '_' && $method != strtolower($className)) { + if (substr($method, 0, 1) !== '_' && $method != strtolower($className)) { $out[] = $method; } } @@ -397,7 +397,7 @@ protected function _processModel($subject) { if (!isset($this->_fixtures[$className])) { $this->_processModel($subject->{$alias}); } - if ($type == 'hasAndBelongsToMany') { + if ($type === 'hasAndBelongsToMany') { if (!empty($subject->hasAndBelongsToMany[$alias]['with'])) { list(, $joinModel) = pluginSplit($subject->hasAndBelongsToMany[$alias]['with']); } else { @@ -454,7 +454,7 @@ protected function _addFixture($name) { public function getUserFixtures() { $proceed = $this->in(__d('cake_console', 'Bake could not detect fixtures, would you like to add some?'), array('y', 'n'), 'n'); $fixtures = array(); - if (strtolower($proceed) == 'y') { + if (strtolower($proceed) === 'y') { $fixtureList = $this->in(__d('cake_console', "Please provide a comma separated list of the fixtures names you'd like to use.\nExample: 'app.comment, app.post, plugin.forums.post'")); $fixtureListTrimmed = str_replace(' ', '', $fixtureList); $fixtures = explode(',', $fixtureListTrimmed); @@ -472,7 +472,7 @@ public function getUserFixtures() { */ public function hasMockClass($type) { $type = strtolower($type); - return $type == 'controller'; + return $type === 'controller'; } /** @@ -486,17 +486,17 @@ public function hasMockClass($type) { public function generateConstructor($type, $fullClassName, $plugin) { $type = strtolower($type); $pre = $construct = $post = ''; - if ($type == 'model') { + if ($type === 'model') { $construct = "ClassRegistry::init('{$plugin}$fullClassName');\n"; } - if ($type == 'behavior') { + if ($type === 'behavior') { $construct = "new $fullClassName();\n"; } - if ($type == 'helper') { + if ($type === 'helper') { $pre = "\$View = new View();\n"; $construct = "new {$fullClassName}(\$View);\n"; } - if ($type == 'component') { + if ($type === 'component') { $pre = "\$Collection = new ComponentCollection();\n"; $construct = "new {$fullClassName}(\$Collection);\n"; } @@ -514,11 +514,11 @@ public function generateConstructor($type, $fullClassName, $plugin) { public function generateUses($type, $realType, $className) { $uses = array(); $type = strtolower($type); - if ($type == 'component') { + if ($type === 'component') { $uses[] = array('ComponentCollection', 'Controller'); $uses[] = array('Component', 'Controller'); } - if ($type == 'helper') { + if ($type === 'helper') { $uses[] = array('View', 'View'); $uses[] = array('Helper', 'View'); } diff --git a/lib/Cake/Console/Command/Task/ViewTask.php b/lib/Cake/Console/Command/Task/ViewTask.php index 5624d43401c..7d623cd5b55 100644 --- a/lib/Cake/Console/Command/Task/ViewTask.php +++ b/lib/Cake/Console/Command/Task/ViewTask.php @@ -100,7 +100,7 @@ public function execute() { $this->controllerName = $this->_controllerName($this->args[0]); $this->Project->interactive = false; - if (strtolower($this->args[0]) == 'all') { + if (strtolower($this->args[0]) === 'all') { return $this->all(); } @@ -211,7 +211,7 @@ protected function _interactive() { $prompt = __d('cake_console', "Would you like bake to build your views interactively?\nWarning: Choosing no will overwrite %s views if it exist.", $this->controllerName); $interactive = $this->in($prompt, array('y', 'n'), 'n'); - if (strtolower($interactive) == 'n') { + if (strtolower($interactive) === 'n') { $this->interactive = false; } @@ -220,13 +220,13 @@ protected function _interactive() { $wannaDoAdmin = $this->in(__d('cake_console', "Would you like to create the views for admin routing?"), array('y', 'n'), 'n'); - if (strtolower($wannaDoScaffold) == 'y' || strtolower($wannaDoAdmin) == 'y') { + if (strtolower($wannaDoScaffold) === 'y' || strtolower($wannaDoAdmin) === 'y') { $vars = $this->_loadController(); - if (strtolower($wannaDoScaffold) == 'y') { + if (strtolower($wannaDoScaffold) === 'y') { $actions = $this->scaffoldActions; $this->bakeActions($actions, $vars); } - if (strtolower($wannaDoAdmin) == 'y') { + if (strtolower($wannaDoAdmin) === 'y') { $admin = $this->Project->getPrefix(); $regularActions = $this->scaffoldActions; $adminActions = array(); @@ -332,7 +332,7 @@ public function customAction() { $this->out(__d('cake_console', 'Path: %s', $this->getPath() . $this->controllerName . DS . Inflector::underscore($action) . ".ctp")); $this->hr(); $looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n'), 'y'); - if (strtolower($looksGood) == 'y') { + if (strtolower($looksGood) === 'y') { $this->bake($action, ' '); $this->_stop(); } else { diff --git a/lib/Cake/Console/Command/TestShell.php b/lib/Cake/Console/Command/TestShell.php index 98597045cd1..651df9d5423 100644 --- a/lib/Cake/Console/Command/TestShell.php +++ b/lib/Cake/Console/Command/TestShell.php @@ -326,7 +326,7 @@ public function available() { break; } - if ($choice == 'q') { + if ($choice === 'q') { break; } } diff --git a/lib/Cake/Console/Command/TestsuiteShell.php b/lib/Cake/Console/Command/TestsuiteShell.php index bd4f4b768c8..842c163cf1c 100644 --- a/lib/Cake/Console/Command/TestsuiteShell.php +++ b/lib/Cake/Console/Command/TestsuiteShell.php @@ -67,11 +67,11 @@ protected function _parseArgs() { $category = $this->args[0]; - if ($category == 'core') { + if ($category === 'core') { $params['core'] = true; - } elseif ($category == 'app') { + } elseif ($category === 'app') { $params['app'] = true; - } elseif ($category != 'core') { + } elseif ($category !== 'core') { $params['plugin'] = $category; } diff --git a/lib/Cake/Console/ConsoleOptionParser.php b/lib/Cake/Console/ConsoleOptionParser.php index 3946e6a5f06..8386a827ab2 100644 --- a/lib/Cake/Console/ConsoleOptionParser.php +++ b/lib/Cake/Console/ConsoleOptionParser.php @@ -470,9 +470,9 @@ public function parse($argv, $command = null) { $params = $args = array(); $this->_tokens = $argv; while (($token = array_shift($this->_tokens)) !== null) { - if (substr($token, 0, 2) == '--') { + if (substr($token, 0, 2) === '--') { $params = $this->_parseLongOption($token, $params); - } elseif (substr($token, 0, 1) == '-') { + } elseif (substr($token, 0, 1) === '-') { $params = $this->_parseShortOption($token, $params); } else { $args = $this->_parseArg($token, $args); @@ -521,9 +521,9 @@ public function help($subcommand = null, $format = 'text', $width = 72) { return $subparser->help(null, $format, $width); } $formatter = new HelpFormatter($this); - if ($format == 'text' || $format === true) { + if ($format === 'text' || $format === true) { return $formatter->text($width); - } elseif ($format == 'xml') { + } elseif ($format === 'xml') { return $formatter->xml(); } } diff --git a/lib/Cake/Console/ConsoleOutput.php b/lib/Cake/Console/ConsoleOutput.php index 1d8dd9a9f18..81b487b5969 100644 --- a/lib/Cake/Console/ConsoleOutput.php +++ b/lib/Cake/Console/ConsoleOutput.php @@ -153,7 +153,7 @@ class ConsoleOutput { public function __construct($stream = 'php://stdout') { $this->_output = fopen($stream, 'w'); - if (DS == '\\' && !(bool)env('ANSICON')) { + if (DS === '\\' && !(bool)env('ANSICON')) { $this->_outputAs = self::PLAIN; } } diff --git a/lib/Cake/Console/Shell.php b/lib/Cake/Console/Shell.php index 6cca5d9071a..f2d31648968 100644 --- a/lib/Cake/Console/Shell.php +++ b/lib/Cake/Console/Shell.php @@ -290,7 +290,7 @@ public function hasMethod($name) { if (!$method->isPublic() || substr($name, 0, 1) === '_') { return false; } - if ($method->getDeclaringClass()->name == 'Shell') { + if ($method->getDeclaringClass()->name === 'Shell') { return false; } return true; @@ -403,7 +403,7 @@ public function runCommand($command, $argv) { */ protected function _displayHelp($command) { $format = 'text'; - if (!empty($this->args[0]) && $this->args[0] == 'xml') { + if (!empty($this->args[0]) && $this->args[0] === 'xml') { $format = 'xml'; $this->stdout->outputAs(ConsoleOutput::RAW); } else { @@ -654,10 +654,10 @@ public function createFile($path, $contents) { $this->out(__d('cake_console', 'File `%s` exists', $path)); $key = $this->in(__d('cake_console', 'Do you want to overwrite?'), array('y', 'n', 'q'), 'n'); - if (strtolower($key) == 'q') { + if (strtolower($key) === 'q') { $this->out(__d('cake_console', 'Quitting.'), 2); $this->_stop(); - } elseif (strtolower($key) != 'y') { + } elseif (strtolower($key) !== 'y') { $this->out(__d('cake_console', 'Skip `%s`', $path), 2); return false; } @@ -695,7 +695,7 @@ protected function _checkUnitTest() { $prompt = __d('cake_console', 'PHPUnit is not installed. Do you want to bake unit test files anyway?'); $unitTest = $this->in($prompt, array('y', 'n'), 'y'); - $result = strtolower($unitTest) == 'y' || strtolower($unitTest) == 'yes'; + $result = strtolower($unitTest) === 'y' || strtolower($unitTest) === 'yes'; if ($result) { $this->out(); diff --git a/lib/Cake/Console/ShellDispatcher.php b/lib/Cake/Console/ShellDispatcher.php index 288bb5b6b23..7a1ef4888c0 100644 --- a/lib/Cake/Console/ShellDispatcher.php +++ b/lib/Cake/Console/ShellDispatcher.php @@ -201,7 +201,7 @@ public function dispatch() { } $methods = array_diff(get_class_methods($Shell), get_class_methods('Shell')); $added = in_array($command, $methods); - $private = $command[0] == '_' && method_exists($Shell, $command); + $private = $command[0] === '_' && method_exists($Shell, $command); if (!$private) { if ($added) { @@ -288,7 +288,7 @@ public function parseParams($args) { } } - if ($params['app'][0] == '/' || preg_match('/([a-z])(:)/i', $params['app'], $matches)) { + if ($params['app'][0] === '/' || preg_match('/([a-z])(:)/i', $params['app'], $matches)) { $params['root'] = dirname($params['app']); } elseif (strpos($params['app'], '/')) { $params['root'] .= '/' . dirname($params['app']); diff --git a/lib/Cake/Console/Templates/default/classes/model.ctp b/lib/Cake/Console/Templates/default/classes/model.ctp index ec43958dc4a..68ebad2dad4 100644 --- a/lib/Cake/Console/Templates/default/classes/model.ctp +++ b/lib/Cake/Console/Templates/default/classes/model.ctp @@ -38,7 +38,7 @@ foreach (array('hasOne', 'belongsTo', 'hasMany', 'hasAndBelongsToMany') as $asso */ class extends AppModel { - + /** * Use database config * diff --git a/lib/Cake/Console/Templates/skel/webroot/index.php b/lib/Cake/Console/Templates/skel/webroot/index.php index ecb7db2422b..9913fb9f070 100644 --- a/lib/Cake/Console/Templates/skel/webroot/index.php +++ b/lib/Cake/Console/Templates/skel/webroot/index.php @@ -77,7 +77,7 @@ } // for built-in server -if (php_sapi_name() == 'cli-server') { +if (php_sapi_name() === 'cli-server') { if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $_SERVER['REQUEST_URI'])) { return false; } diff --git a/lib/Cake/Controller/Component/Auth/ControllerAuthorize.php b/lib/Cake/Controller/Component/Auth/ControllerAuthorize.php index e6cdca65ca3..b7fe94ad7db 100644 --- a/lib/Cake/Controller/Component/Auth/ControllerAuthorize.php +++ b/lib/Cake/Controller/Component/Auth/ControllerAuthorize.php @@ -23,7 +23,7 @@ * {{{ * public function isAuthorized($user) { * if (!empty($this->request->params['admin'])) { - * return $user['role'] == 'admin'; + * return $user['role'] === 'admin'; * } * return !empty($user); * } diff --git a/lib/Cake/Controller/Component/Auth/DigestAuthenticate.php b/lib/Cake/Controller/Component/Auth/DigestAuthenticate.php index 7cbd9db71e3..60c1345b248 100644 --- a/lib/Cake/Controller/Component/Auth/DigestAuthenticate.php +++ b/lib/Cake/Controller/Component/Auth/DigestAuthenticate.php @@ -188,7 +188,7 @@ protected function _getDigest() { $digest = env('PHP_AUTH_DIGEST'); if (empty($digest) && function_exists('apache_request_headers')) { $headers = apache_request_headers(); - if (!empty($headers['Authorization']) && substr($headers['Authorization'], 0, 7) == 'Digest ') { + if (!empty($headers['Authorization']) && substr($headers['Authorization'], 0, 7) === 'Digest ') { $digest = substr($headers['Authorization'], 7); } } @@ -205,7 +205,7 @@ protected function _getDigest() { * @return array An array of digest authentication headers */ public function parseAuthData($digest) { - if (substr($digest, 0, 7) == 'Digest ') { + if (substr($digest, 0, 7) === 'Digest ') { $digest = substr($digest, 7); } $keys = $match = array(); diff --git a/lib/Cake/Controller/Component/RequestHandlerComponent.php b/lib/Cake/Controller/Component/RequestHandlerComponent.php index dae929f4461..85a51f33891 100644 --- a/lib/Cake/Controller/Component/RequestHandlerComponent.php +++ b/lib/Cake/Controller/Component/RequestHandlerComponent.php @@ -130,7 +130,7 @@ public function initialize(Controller $controller) { if (isset($this->request->params['ext'])) { $this->ext = $this->request->params['ext']; } - if (empty($this->ext) || $this->ext == 'html') { + if (empty($this->ext) || $this->ext === 'html') { $this->_setExtension(); } $this->params = $controller->params; @@ -590,7 +590,7 @@ public function renderAs(Controller $controller, $type, $options = array()) { } $options = array_merge($defaults, $options); - if ($type == 'ajax') { + if ($type === 'ajax') { $controller->layout = $this->ajaxLayout; return $this->respondAs('html', $options); } diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index 4ccec11628c..f78e0cd30ee 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -963,7 +963,7 @@ public function referer($default = null, $local = false) { } $referer = $this->request->referer($local); - if ($referer == '/' && $default) { + if ($referer === '/' && $default) { return Router::url($default, true); } return $referer; @@ -1048,13 +1048,13 @@ public function postConditions($data = array(), $op = null, $bool = 'AND', $excl if ($fieldOp === 'LIKE') { $key = $key . ' LIKE'; $value = '%' . $value . '%'; - } elseif ($fieldOp && $fieldOp != '=') { + } elseif ($fieldOp && $fieldOp !== '=') { $key = $key . ' ' . $fieldOp; } $cond[$key] = $value; } } - if ($bool && strtoupper($bool) != 'AND') { + if ($bool && strtoupper($bool) !== 'AND') { $cond = array($bool => $cond); } return $cond; diff --git a/lib/Cake/Controller/Scaffold.php b/lib/Cake/Controller/Scaffold.php index 78e4232a0be..66e34f88740 100644 --- a/lib/Cake/Controller/Scaffold.php +++ b/lib/Cake/Controller/Scaffold.php @@ -227,7 +227,7 @@ protected function _scaffoldSave(CakeRequest $request, $action = 'edit') { } if ($this->controller->beforeScaffold($action)) { - if ($action == 'edit') { + if ($action === 'edit') { if (isset($request->params['pass'][0])) { $this->ScaffoldModel->id = $request['pass'][0]; } @@ -237,7 +237,7 @@ protected function _scaffoldSave(CakeRequest $request, $action = 'edit') { } if (!empty($request->data)) { - if ($action == 'create') { + if ($action === 'create') { $this->ScaffoldModel->create(); } @@ -443,7 +443,7 @@ protected function _associations() { $associations[$type][$assocKey]['controller'] = Inflector::pluralize(Inflector::underscore($model)); - if ($type == 'hasAndBelongsToMany') { + if ($type === 'hasAndBelongsToMany') { $associations[$type][$assocKey]['with'] = $assocData['with']; } } diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index d59447815d4..ae994255371 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -433,7 +433,7 @@ public static function objects($type, $path = null, $cache = true) { $type = 'plugins'; } - if ($type == 'plugins') { + if ($type === 'plugins') { $extension = '/.*/'; $includeDirectories = true; } @@ -637,11 +637,11 @@ public static function import($type = null, $name = null, $parent = true, $searc return self::_loadClass($name, $plugin, $type, $originalType, $parent); } - if ($originalType == 'file' && !empty($file)) { + if ($originalType === 'file' && !empty($file)) { return self::_loadFile($name, $plugin, $search, $file, $return); } - if ($originalType == 'vendor') { + if ($originalType === 'vendor') { return self::_loadVendor($name, $plugin, $file, $ext); } @@ -660,7 +660,7 @@ public static function import($type = null, $name = null, $parent = true, $searc * @return boolean true indicating the successful load and existence of the class */ protected static function _loadClass($name, $plugin, $type, $originalType, $parent) { - if ($type == 'Console/Command' && $name == 'Shell') { + if ($type === 'Console/Command' && $name === 'Shell') { $type = 'Console'; } elseif (isset(self::$types[$originalType]['suffix'])) { $suffix = self::$types[$originalType]['suffix']; diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index a9164d3cfea..78f0636959b 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -149,7 +149,7 @@ protected static function _getMessage($exception) { $message .= "\nException Attributes: " . var_export($exception->getAttributes(), true); } } - if (php_sapi_name() != 'cli') { + if (php_sapi_name() !== 'cli') { $request = Router::getRequest(); if ($request) { $message .= "\nRequest URL: " . $request->here(); diff --git a/lib/Cake/Error/ExceptionRenderer.php b/lib/Cake/Error/ExceptionRenderer.php index 834348e2122..069ed186038 100644 --- a/lib/Cake/Error/ExceptionRenderer.php +++ b/lib/Cake/Error/ExceptionRenderer.php @@ -104,7 +104,7 @@ public function __construct(Exception $exception) { if ($exception instanceof CakeException && !$methodExists) { $method = '_cakeError'; - if (empty($template) || $template == 'internalError') { + if (empty($template) || $template === 'internalError') { $template = 'error500'; } } elseif ($exception instanceof PDOException) { @@ -119,7 +119,7 @@ public function __construct(Exception $exception) { } $isNotDebug = !Configure::read('debug'); - if ($isNotDebug && $method == '_cakeError') { + if ($isNotDebug && $method === '_cakeError') { $method = 'error400'; } if ($isNotDebug && $code == 500) { diff --git a/lib/Cake/I18n/I18n.php b/lib/Cake/I18n/I18n.php index 4a34f6ab66f..c052f5b9487 100644 --- a/lib/Cake/I18n/I18n.php +++ b/lib/Cake/I18n/I18n.php @@ -174,7 +174,7 @@ public static function translate($singular, $plural = null, $domain = null, $cat Cache::write($_this->domain, $_this->_domains[$domain][$_this->_lang], '_cake_core_'); } - if ($_this->category == 'LC_TIME') { + if ($_this->category === 'LC_TIME') { return $_this->_translateTime($singular, $domain); } @@ -410,7 +410,7 @@ public static function loadMo($filename) { $header = unpack("L1magic/L1version/L1count/L1o_msg/L1o_trn", $header); extract($header); - if ((dechex($magic) == '950412de' || dechex($magic) == 'ffffffff950412de') && !$version) { + if ((dechex($magic) === '950412de' || dechex($magic) === 'ffffffff950412de') && !$version) { for ($n = 0; $n < $count; $n++) { $r = unpack("L1len/L1offs", substr($data, $o_msg + $n * 8, 8)); $msgid = substr($data, $r["offs"], $r["len"]); diff --git a/lib/Cake/I18n/Multibyte.php b/lib/Cake/I18n/Multibyte.php index 05702edf33d..e81893bd42c 100644 --- a/lib/Cake/I18n/Multibyte.php +++ b/lib/Cake/I18n/Multibyte.php @@ -750,7 +750,7 @@ public static function mimeEncode($string, $charset = null, $newline = "\r\n") { $length = 75 - strlen($start) - strlen($end); $length = $length - ($length % 4); - if ($charset == 'UTF-8') { + if ($charset === 'UTF-8') { $parts = array(); $maxchars = floor(($length * 3) / 4); $stringLength = strlen($string); diff --git a/lib/Cake/Log/Engine/ConsoleLog.php b/lib/Cake/Log/Engine/ConsoleLog.php index f5f5b45bb0f..283b8d677c9 100644 --- a/lib/Cake/Log/Engine/ConsoleLog.php +++ b/lib/Cake/Log/Engine/ConsoleLog.php @@ -50,7 +50,7 @@ class ConsoleLog extends BaseLog { */ public function __construct($config = array()) { parent::__construct($config); - if (DS == '\\' && !(bool)env('ANSICON')) { + if (DS === '\\' && !(bool)env('ANSICON')) { $outputAs = ConsoleOutput::PLAIN; } else { $outputAs = ConsoleOutput::COLOR; diff --git a/lib/Cake/Log/Engine/FileLog.php b/lib/Cake/Log/Engine/FileLog.php index 14ff20c3043..e9c65dc5870 100644 --- a/lib/Cake/Log/Engine/FileLog.php +++ b/lib/Cake/Log/Engine/FileLog.php @@ -76,7 +76,7 @@ public function write($type, $message) { if (!empty($this->_file)) { $filename = $this->_path . $this->_file; - } elseif ($type == 'error' || $type == 'warning') { + } elseif ($type === 'error' || $type === 'warning') { $filename = $this->_path . 'error.log'; } elseif (in_array($type, $debugTypes)) { $filename = $this->_path . 'debug.log'; diff --git a/lib/Cake/Model/Behavior/ContainableBehavior.php b/lib/Cake/Model/Behavior/ContainableBehavior.php index 71180dad9e8..41f9cd1debb 100644 --- a/lib/Cake/Model/Behavior/ContainableBehavior.php +++ b/lib/Cake/Model/Behavior/ContainableBehavior.php @@ -200,7 +200,7 @@ public function beforeFind(Model $Model, $query) { if (!empty($mandatory[$Model->alias])) { foreach ($mandatory[$Model->alias] as $field) { - if ($field == '--primaryKey--') { + if ($field === '--primaryKey--') { $field = $Model->primaryKey; } elseif (preg_match('/^.+\.\-\-[^-]+\-\-$/', $field)) { list($modelName, $field) = explode('.', $field); @@ -307,7 +307,7 @@ public function containments(Model $Model, $contain, $containments = array(), $t if (!$optionKey && is_string($key) && preg_match('/^[a-z(]/', $key) && (!isset($Model->{$key}) || !is_object($Model->{$key}))) { $option = 'fields'; $val = array($key); - if ($key{0} == '(') { + if ($key{0} === '(') { $val = preg_split('/\s*,\s*/', substr($key, 1, -1)); } elseif (preg_match('/ASC|DESC$/', $key)) { $option = 'order'; @@ -374,9 +374,9 @@ public function fieldDependencies(Model $Model, $map, $fields = array()) { foreach ($map as $parent => $children) { foreach ($children as $type => $bindings) { foreach ($bindings as $dependency) { - if ($type == 'hasAndBelongsToMany') { + if ($type === 'hasAndBelongsToMany') { $fields[$parent][] = '--primaryKey--'; - } elseif ($type == 'belongsTo') { + } elseif ($type === 'belongsTo') { $fields[$parent][] = $dependency . '.--primaryKey--'; } } diff --git a/lib/Cake/Model/BehaviorCollection.php b/lib/Cake/Model/BehaviorCollection.php index 5980fd94d99..c2731669334 100644 --- a/lib/Cake/Model/BehaviorCollection.php +++ b/lib/Cake/Model/BehaviorCollection.php @@ -160,7 +160,7 @@ public function load($behavior, $config = array()) { foreach ($methods as $m) { if (!isset($parentMethods[$m])) { $methodAllowed = ( - $m[0] != '_' && !array_key_exists($m, $this->_methods) && + $m[0] !== '_' && !array_key_exists($m, $this->_methods) && !in_array($m, $callbacks) ); if ($methodAllowed) { diff --git a/lib/Cake/Model/CakeSchema.php b/lib/Cake/Model/CakeSchema.php index acf8b792f8d..197814ad60f 100644 --- a/lib/Cake/Model/CakeSchema.php +++ b/lib/Cake/Model/CakeSchema.php @@ -227,7 +227,7 @@ public function read($options = array()) { foreach ($models as $model) { $importModel = $model; $plugin = null; - if ($model == 'AppModel') { + if ($model === 'AppModel') { continue; } @@ -412,7 +412,7 @@ public function generateTable($table, $fields) { if (is_array($fields)) { $cols = array(); foreach ($fields as $field => $value) { - if ($field != 'indexes' && $field != 'tableParameters') { + if ($field !== 'indexes' && $field !== 'tableParameters') { if (is_string($value)) { $type = $value; $value = array('type' => $type); @@ -420,14 +420,14 @@ public function generateTable($table, $fields) { $col = "\t\t'{$field}' => array('type' => '" . $value['type'] . "', "; unset($value['type']); $col .= implode(', ', $this->_values($value)); - } elseif ($field == 'indexes') { + } elseif ($field === 'indexes') { $col = "\t\t'indexes' => array(\n\t\t\t"; $props = array(); foreach ((array)$value as $key => $index) { $props[] = "'{$key}' => array(" . implode(', ', $this->_values($index)) . ")"; } $col .= implode(",\n\t\t\t", $props) . "\n\t\t"; - } elseif ($field == 'tableParameters') { + } elseif ($field === 'tableParameters') { $col = "\t\t'tableParameters' => array("; $props = array(); foreach ((array)$value as $key => $param) { @@ -472,7 +472,7 @@ public function compare($old, $new = null) { } $tables = array(); foreach ($new as $table => $fields) { - if ($table == 'missing') { + if ($table === 'missing') { continue; } if (!array_key_exists($table, $old)) { diff --git a/lib/Cake/Model/Datasource/Database/Postgres.php b/lib/Cake/Model/Datasource/Database/Postgres.php index 002d25f68e9..d5895fb747b 100644 --- a/lib/Cake/Model/Datasource/Database/Postgres.php +++ b/lib/Cake/Model/Datasource/Database/Postgres.php @@ -199,10 +199,10 @@ public function describe($model) { foreach ($cols as $c) { $type = $c->type; if (!empty($c->oct_length) && $c->char_length === null) { - if ($c->type == 'character varying') { + if ($c->type === 'character varying') { $length = null; $type = 'text'; - } elseif ($c->type == 'uuid') { + } elseif ($c->type === 'uuid') { $length = 36; } else { $length = intval($c->oct_length); @@ -217,7 +217,7 @@ public function describe($model) { } $fields[$c->name] = array( 'type' => $this->column($type), - 'null' => ($c->null == 'NO' ? false : true), + 'null' => ($c->null === 'NO' ? false : true), 'default' => preg_replace( "/^'(.*)'$/", "$1", @@ -234,7 +234,7 @@ public function describe($model) { } } if ( - $fields[$c->name]['default'] == 'NULL' || + $fields[$c->name]['default'] === 'NULL' || preg_match('/nextval\([\'"]?([\w.]+)/', $c->default, $seq) ) { $fields[$c->name]['default'] = null; @@ -247,7 +247,7 @@ public function describe($model) { $this->_sequenceMap[$table][$c->name] = $sequenceName; } } - if ($fields[$c->name]['type'] == 'boolean' && !empty($fields[$c->name]['default'])) { + if ($fields[$c->name]['type'] === 'boolean' && !empty($fields[$c->name]['default'])) { $fields[$c->name]['default'] = constant($fields[$c->name]['default']); } } @@ -382,7 +382,7 @@ public function fields(Model $model, $alias = null, $fields = array(), $quote = $result = array(); for ($i = 0; $i < $count; $i++) { if (!preg_match('/^.+\\(.*\\)/', $fields[$i]) && !preg_match('/\s+AS\s+/', $fields[$i])) { - if (substr($fields[$i], -1) == '*') { + if (substr($fields[$i], -1) === '*') { if (strpos($fields[$i], '.') !== false && $fields[$i] != $alias . '.*') { $build = explode('.', $fields[$i]); $AssociatedModel = $model->{$build[0]}; @@ -576,7 +576,7 @@ protected function _alterIndexes($table, $indexes) { if (isset($indexes['drop'])) { foreach ($indexes['drop'] as $name => $value) { $out = 'DROP '; - if ($name == 'PRIMARY') { + if ($name === 'PRIMARY') { continue; } else { $out .= 'INDEX ' . $name; @@ -587,7 +587,7 @@ protected function _alterIndexes($table, $indexes) { if (isset($indexes['add'])) { foreach ($indexes['add'] as $name => $value) { $out = 'CREATE '; - if ($name == 'PRIMARY') { + if ($name === 'PRIMARY') { continue; } else { if (!empty($value['unique'])) { @@ -663,11 +663,11 @@ public function column($real) { return 'datetime'; case (strpos($col, 'time') === 0): return 'time'; - case ($col == 'bigint'): + case ($col === 'bigint'): return 'biginteger'; - case (strpos($col, 'int') !== false && $col != 'interval'): + case (strpos($col, 'int') !== false && $col !== 'interval'): return 'integer'; - case (strpos($col, 'char') !== false || $col == 'uuid'): + case (strpos($col, 'char') !== false || $col === 'uuid'): return 'string'; case (strpos($col, 'text') !== false): return 'text'; @@ -693,7 +693,7 @@ public function length($real) { if (strpos($col, '(') !== false) { list($col, $limit) = explode('(', $col); } - if ($col == 'uuid') { + if ($col === 'uuid') { return 36; } if ($limit) { @@ -852,7 +852,7 @@ public function buildColumn($column) { $out = str_replace('DEFAULT DEFAULT', 'DEFAULT NULL', $out); } elseif (in_array($column['type'], array('integer', 'float'))) { $out = str_replace('DEFAULT DEFAULT', 'DEFAULT 0', $out); - } elseif ($column['type'] == 'boolean') { + } elseif ($column['type'] === 'boolean') { $out = str_replace('DEFAULT DEFAULT', 'DEFAULT FALSE', $out); } } @@ -872,7 +872,7 @@ public function buildIndex($indexes, $table = null) { return array(); } foreach ($indexes as $name => $value) { - if ($name == 'PRIMARY') { + if ($name === 'PRIMARY') { $out = 'PRIMARY KEY (' . $this->name($value['column']) . ')'; } else { $out = 'CREATE '; diff --git a/lib/Cake/Model/Datasource/Database/Sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php index 4e6c6f8bf86..43bef5f5a32 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlite.php +++ b/lib/Cake/Model/Datasource/Database/Sqlite.php @@ -357,7 +357,7 @@ public function fetchResult() { foreach ($this->map as $col => $meta) { list($table, $column, $type) = $meta; $resultRow[$table][$column] = $row[$col]; - if ($type == 'boolean' && !is_null($row[$col])) { + if ($type === 'boolean' && !is_null($row[$col])) { $resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]); } } @@ -412,7 +412,7 @@ public function buildColumn($column) { return null; } - if (isset($column['key']) && $column['key'] == 'primary' && $type == 'integer') { + if (isset($column['key']) && $column['key'] === 'primary' && $type === 'integer') { return $this->name($name) . ' ' . $this->columns['primary_key']['name']; } return parent::buildColumn($column); @@ -456,7 +456,7 @@ public function buildIndex($indexes, $table = null) { foreach ($indexes as $name => $value) { - if ($name == 'PRIMARY') { + if ($name === 'PRIMARY') { continue; } $out = 'CREATE '; diff --git a/lib/Cake/Model/Datasource/Database/Sqlserver.php b/lib/Cake/Model/Datasource/Database/Sqlserver.php index 802039bf12d..bd81ee4a0b1 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlserver.php +++ b/lib/Cake/Model/Datasource/Database/Sqlserver.php @@ -227,7 +227,7 @@ public function describe($model) { $this->value($fields[$field]['default'], $fields[$field]['type']); } - if ($fields[$field]['key'] !== false && $fields[$field]['type'] == 'integer') { + if ($fields[$field]['key'] !== false && $fields[$field]['type'] === 'integer') { $fields[$field]['length'] = 11; } elseif ($fields[$field]['key'] === false) { unset($fields[$field]['key']); @@ -235,7 +235,7 @@ public function describe($model) { if (in_array($fields[$field]['type'], array('date', 'time', 'datetime', 'timestamp'))) { $fields[$field]['length'] = null; } - if ($fields[$field]['type'] == 'float' && !empty($column->Size)) { + if ($fields[$field]['type'] === 'float' && !empty($column->Size)) { $fields[$field]['length'] = $fields[$field]['length'] . ',' . $column->Size; } } @@ -271,7 +271,7 @@ public function fields(Model $model, $alias = null, $fields = array(), $quote = } if (!preg_match('/\s+AS\s+/i', $fields[$i])) { - if (substr($fields[$i], -1) == '*') { + if (substr($fields[$i], -1) === '*') { if (strpos($fields[$i], '.') !== false && $fields[$i] != $alias . '.*') { $build = explode('.', $fields[$i]); $AssociatedModel = $model->{$build[0]}; @@ -299,7 +299,7 @@ public function fields(Model $model, $alias = null, $fields = array(), $quote = $fieldName = $this->name($name); $fieldAlias = $this->name($alias); } - if ($model->getColumnType($fields[$i]) == 'datetime') { + if ($model->getColumnType($fields[$i]) === 'datetime') { $fieldName = "CONVERT(VARCHAR(20), {$fieldName}, 20)"; } $fields[$i] = "{$fieldName} AS {$fieldAlias}"; @@ -402,13 +402,13 @@ public function column($real) { $col = $real->Type; } - if ($col == 'datetime2') { + if ($col === 'datetime2') { return 'datetime'; } if (in_array($col, array('date', 'time', 'datetime', 'timestamp'))) { return $col; } - if ($col == 'bit') { + if ($col === 'bit') { return 'boolean'; } if (strpos($col, 'bigint') !== false) { @@ -426,7 +426,7 @@ public function column($real) { if (strpos($col, 'text') !== false) { return 'text'; } - if (strpos($col, 'binary') !== false || $col == 'image') { + if (strpos($col, 'binary') !== false || $col === 'image') { return 'binary'; } if (in_array($col, array('float', 'real', 'decimal', 'numeric'))) { @@ -481,7 +481,7 @@ public function resultSet($results) { } else { $map = array(0, $name); } - $map[] = ($column['sqlsrv:decl_type'] == 'bit') ? 'boolean' : $column['native_type']; + $map[] = ($column['sqlsrv:decl_type'] === 'bit') ? 'boolean' : $column['native_type']; $this->map[$index++] = $map; } } @@ -683,7 +683,7 @@ public function buildIndex($indexes, $table = null) { $join = array(); foreach ($indexes as $name => $value) { - if ($name == 'PRIMARY') { + if ($name === 'PRIMARY') { $join[] = 'PRIMARY KEY (' . $this->name($value['column']) . ')'; } elseif (isset($value['unique']) && $value['unique']) { $out = "ALTER TABLE {$table} ADD CONSTRAINT {$name} UNIQUE"; @@ -709,7 +709,7 @@ public function buildIndex($indexes, $table = null) { protected function _getPrimaryKey($model) { $schema = $this->describe($model); foreach ($schema as $field => $props) { - if (isset($props['key']) && $props['key'] == 'primary') { + if (isset($props['key']) && $props['key'] === 'primary') { return $field; } } diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 7fd40c48f13..b3e3b7eabd5 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -323,9 +323,9 @@ public function value($data, $column = null) { $data, array_fill(0, count($data), $column) ); } elseif (is_object($data) && isset($data->type, $data->value)) { - if ($data->type == 'identifier') { + if ($data->type === 'identifier') { return $this->name($data->value); - } elseif ($data->type == 'expression') { + } elseif ($data->type === 'expression') { return $data->value; } } elseif (in_array($data, array('{$__cakeID__$}', '{$__cakeForeignKey__$}'), true)) { @@ -899,7 +899,7 @@ public function showLog($sorted = false) { if (empty($log['log'])) { return; } - if (PHP_SAPI != 'cli') { + if (PHP_SAPI !== 'cli') { $controller = null; $View = new View($controller, false); $View->set('logs', array($this->configKeyName => $log)); @@ -1878,7 +1878,7 @@ protected function _prepareUpdateFields(Model $model, $fields, $quoteValues = tr if ($quoteValues) { $update .= $this->value($value, $model->getColumnType($field)); - } elseif ($model->getColumnType($field) == 'boolean' && (is_int($value) || is_bool($value))) { + } elseif ($model->getColumnType($field) === 'boolean' && (is_int($value) || is_bool($value))) { $update .= $this->boolean($value, true); } elseif (!$alias) { $update .= str_replace($quotedAlias . '.', '', str_replace( diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 9c586908fd2..950a591ca3b 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -818,7 +818,7 @@ public function __isset($name) { $className = empty($this->__backAssociation[$type][$name]['className']) ? $name : $this->__backAssociation[$type][$name]['className']; break; - } elseif ($type == 'hasAndBelongsToMany') { + } elseif ($type === 'hasAndBelongsToMany') { foreach ($this->{$type} as $k => $relation) { if (empty($relation['with'])) { continue; @@ -1061,7 +1061,7 @@ protected function _generateAssociation($type, $assocKey) { break; case 'foreignKey': - $data = (($type == 'belongsTo') ? Inflector::underscore($assocKey) : Inflector::singularize($this->table)) . '_id'; + $data = (($type === 'belongsTo') ? Inflector::underscore($assocKey) : Inflector::singularize($this->table)) . '_id'; break; case 'associationForeignKey': @@ -1262,7 +1262,7 @@ public function deconstruct($field, $data) { if (isset($data['hour']) && isset($data['meridian']) && $data['hour'] == 12 && 'am' == $data['meridian']) { $data['hour'] = '00'; } - if ($type == 'time') { + if ($type === 'time') { foreach ($timeFields as $key => $val) { if (!isset($data[$val]) || $data[$val] === '0' || $data[$val] === '00') { $data[$val] = '00'; @@ -1277,9 +1277,9 @@ public function deconstruct($field, $data) { } } - if ($type == 'datetime' || $type == 'timestamp' || $type == 'date') { + if ($type === 'datetime' || $type === 'timestamp' || $type === 'date') { foreach ($dateFields as $key => $val) { - if ($val == 'hour' || $val == 'min' || $val == 'sec') { + if ($val === 'hour' || $val === 'min' || $val === 'sec') { if (!isset($data[$val]) || $data[$val] === '0' || $data[$val] === '00') { $data[$val] = '00'; } else { diff --git a/lib/Cake/Model/Permission.php b/lib/Cake/Model/Permission.php index 0bf298c2948..b47eaa9790d 100644 --- a/lib/Cake/Model/Permission.php +++ b/lib/Cake/Model/Permission.php @@ -100,7 +100,7 @@ public function check($aro, $aco, $action = "*") { return false; } - if ($action != '*' && !in_array('_' . $action, $permKeys)) { + if ($action !== '*' && !in_array('_' . $action, $permKeys)) { trigger_error(__d('cake_dev', "ACO permissions key %s does not exist in DbAcl::check()", $action), E_USER_NOTICE); return false; } @@ -126,7 +126,7 @@ public function check($aro, $aco, $action = "*") { } else { $perms = Hash::extract($perms, '{n}.' . $this->alias); foreach ($perms as $perm) { - if ($action == '*') { + if ($action === '*') { foreach ($permKeys as $key) { if (!empty($perm)) { diff --git a/lib/Cake/Model/Validator/CakeValidationRule.php b/lib/Cake/Model/Validator/CakeValidationRule.php index 228db0e4910..eb098fa2b3c 100644 --- a/lib/Cake/Model/Validator/CakeValidationRule.php +++ b/lib/Cake/Model/Validator/CakeValidationRule.php @@ -194,7 +194,7 @@ public function checkEmpty($field, &$data) { */ public function skip() { if (!empty($this->on)) { - if ($this->on == 'create' && $this->isUpdate() || $this->on == 'update' && !$this->isUpdate()) { + if ($this->on === 'create' && $this->isUpdate() || $this->on === 'update' && !$this->isUpdate()) { return true; } } diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index ef2dbf962c7..868d10414e3 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -134,7 +134,7 @@ public function __construct($url = null, $parseEnvironment = true) { if (empty($url)) { $url = $this->_url(); } - if ($url[0] == '/') { + if ($url[0] === '/') { $url = substr($url, 1); } $this->url = $url; @@ -255,7 +255,7 @@ protected function _url() { if (strpos($uri, '?') !== false) { list($uri) = explode('?', $uri, 2); } - if (empty($uri) || $uri == '/' || $uri == '//' || $uri == '/index.php') { + if (empty($uri) || $uri === '/' || $uri === '//' || $uri === '/index.php') { return '/'; } return $uri; @@ -412,7 +412,7 @@ public function referer($local = false) { if (!empty($ref) && !empty($base)) { if ($local && strpos($ref, $base) === 0) { $ref = substr($ref, strlen($base)); - if ($ref[0] != '/') { + if ($ref[0] !== '/') { $ref = '/' . $ref; } return $ref; @@ -893,10 +893,10 @@ public function offsetGet($name) { if (isset($this->params[$name])) { return $this->params[$name]; } - if ($name == 'url') { + if ($name === 'url') { return $this->query; } - if ($name == 'data') { + if ($name === 'data') { return $this->data; } return null; diff --git a/lib/Cake/Network/CakeSocket.php b/lib/Cake/Network/CakeSocket.php index bbee23acedd..808523a5cfb 100644 --- a/lib/Cake/Network/CakeSocket.php +++ b/lib/Cake/Network/CakeSocket.php @@ -135,7 +135,7 @@ public function connect() { } $scheme = null; - if (isset($this->config['request']['uri']) && $this->config['request']['uri']['scheme'] == 'https') { + if (isset($this->config['request']['uri']) && $this->config['request']['uri']['scheme'] === 'https') { $scheme = 'ssl://'; } diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index 0702737c7bb..92446ff255c 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -1512,7 +1512,7 @@ protected function _render($content) { */ protected function _getTypes() { $types = array($this->_emailFormat); - if ($this->_emailFormat == 'both') { + if ($this->_emailFormat === 'both') { $types = array('html', 'text'); } return $types; diff --git a/lib/Cake/Network/Http/HttpSocket.php b/lib/Cake/Network/Http/HttpSocket.php index a23089c10f0..c3253249916 100644 --- a/lib/Cake/Network/Http/HttpSocket.php +++ b/lib/Cake/Network/Http/HttpSocket.php @@ -545,7 +545,7 @@ public function url($url = null, $uriTemplate = null) { if (is_array($port)) { $port = $port[0]; } - if ($url{0} == '/') { + if ($url{0} === '/') { $url = $this->config['request']['uri']['host'] . ':' . $port . $url; } if (!preg_match('/^.+:\/\/|\*|^\//', $url)) { @@ -867,7 +867,7 @@ protected function _buildRequestLine($request = array(), $versionToken = 'HTTP/1 if (is_string($request)) { $isValid = preg_match("/(.+) (.+) (.+)\r\n/U", $request, $match); - if (!$this->quirksMode && (!$isValid || ($match[2] == '*' && !in_array($match[3], $asteriskMethods)))) { + if (!$this->quirksMode && (!$isValid || ($match[2] === '*' && !in_array($match[3], $asteriskMethods)))) { throw new SocketException(__d('cake_dev', 'HttpSocket::_buildRequestLine - Passed an invalid request line string. Activate quirks mode to do this.')); } return $request; @@ -918,7 +918,7 @@ protected function _buildHeader($header, $mode = 'standard') { $returnHeader = ''; foreach ($header as $field => $contents) { - if (is_array($contents) && $mode == 'standard') { + if (is_array($contents) && $mode === 'standard') { $contents = implode(',', $contents); } foreach ((array)$contents as $content) { diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 3897b239e26..da587d1c1f6 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -191,7 +191,7 @@ public static function defaultRouteClass($routeClass = null) { */ protected static function _validateRouteClass($routeClass) { if ( - $routeClass != 'CakeRoute' && + $routeClass !== 'CakeRoute' && (!class_exists($routeClass) || !is_subclass_of($routeClass, 'CakeRoute')) ) { throw new RouterException(__d('cake_dev', 'Route classes must extend CakeRoute')); @@ -332,7 +332,7 @@ public static function connect($route, $defaults = array(), $options = array()) $routeClass = self::_validateRouteClass($routeClass); unset($options['routeClass']); } - if ($routeClass == 'RedirectRoute' && isset($defaults['redirect'])) { + if ($routeClass === 'RedirectRoute' && isset($defaults['redirect'])) { $defaults = $defaults['redirect']; } self::$routes[] = new $routeClass($route, $defaults, $options); @@ -715,7 +715,7 @@ public static function reload() { return; } foreach (self::$_initialState as $key => $val) { - if ($key != '_initialState') { + if ($key !== '_initialState') { self::${$key} = $val; } } @@ -1001,7 +1001,7 @@ public static function queryString($q, $extra = array(), $escape = false) { $out .= $addition; - if (isset($out[0]) && $out[0] != '?') { + if (isset($out[0]) && $out[0] !== '?') { $out = '?' . $out; } return $out; diff --git a/lib/Cake/Test/Case/BasicsTest.php b/lib/Cake/Test/Case/BasicsTest.php index aa5aff1b14a..805842b477b 100644 --- a/lib/Cake/Test/Case/BasicsTest.php +++ b/lib/Cake/Test/Case/BasicsTest.php @@ -767,7 +767,7 @@ public function testDebug() { '
this-is-a-test
' ########################### EXPECTED; - if (php_sapi_name() == 'cli') { + if (php_sapi_name() === 'cli') { $expected = sprintf($expectedText, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 17); } else { $expected = sprintf($expectedHtml, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 19); @@ -791,7 +791,7 @@ public function testDebug() { '
this-is-a-test
' ########################### EXPECTED; - if (php_sapi_name() == 'cli') { + if (php_sapi_name() === 'cli') { $expected = sprintf($expectedText, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 17); } else { $expected = sprintf($expectedHtml, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 19); diff --git a/lib/Cake/Test/Case/Cache/CacheTest.php b/lib/Cake/Test/Case/Cache/CacheTest.php index 05e14022ea4..43cdddd2458 100644 --- a/lib/Cake/Test/Case/Cache/CacheTest.php +++ b/lib/Cake/Test/Case/Cache/CacheTest.php @@ -228,7 +228,7 @@ public function testWritingWithConfig() { 'duration' => 3600, 'probability' => 100, 'engine' => 'File', - 'isWindows' => DIRECTORY_SEPARATOR == '\\', + 'isWindows' => DIRECTORY_SEPARATOR === '\\', 'mask' => 0664, 'groups' => array() ); diff --git a/lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php b/lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php index 1ea885040f4..3ab84af6382 100644 --- a/lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php @@ -504,12 +504,12 @@ protected function _debug($printTreesToo = false) { $perms = ''; foreach ($rights as $right) { if ($this->Acl->check($aro, $aco, $right)) { - if ($right == '*') { + if ($right === '*') { $perms .= '****'; break; } $perms .= $right[0]; - } elseif ($right != '*') { + } elseif ($right !== '*') { $perms .= ' '; } } diff --git a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php index db8d41e1fc9..7b2a1986521 100644 --- a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php @@ -107,7 +107,7 @@ public function beforeFind($query) { * @return void */ public function find($conditions = null, $fields = array(), $order = null, $recursive = null) { - if ($conditions == 'popular') { + if ($conditions === 'popular') { $conditions = array($this->name . '.' . $this->primaryKey . ' > ' => '1'); $options = Hash::merge($fields, compact('conditions')); return parent::find('all', $options); @@ -278,7 +278,7 @@ protected function _findPublished($state, $query, $results = array()) { * @return array */ protected function _findTotals($state, $query, $results = array()) { - if ($state == 'before') { + if ($state === 'before') { $query['fields'] = array('author_id'); $this->virtualFields['total_posts'] = "COUNT({$this->alias}.id)"; $query['fields'][] = 'total_posts'; @@ -296,7 +296,7 @@ protected function _findTotals($state, $query, $results = array()) { * @return array */ protected function _findTotalsOperation($state, $query, $results = array()) { - if ($state == 'before') { + if ($state === 'before') { if (!empty($query['operation']) && $query['operation'] === 'count') { unset($query['limit']); $query['recursive'] = -1; diff --git a/lib/Cake/Test/Case/Controller/ControllerTest.php b/lib/Cake/Test/Case/Controller/ControllerTest.php index ac48d16d260..9e2d1619e3e 100644 --- a/lib/Cake/Test/Case/Controller/ControllerTest.php +++ b/lib/Cake/Test/Case/Controller/ControllerTest.php @@ -103,7 +103,7 @@ public function beforeFind($query) { * @return void */ public function find($type = 'first', $options = array()) { - if ($type == 'popular') { + if ($type === 'popular') { $conditions = array($this->name . '.' . $this->primaryKey . ' > ' => '1'); $options = Hash::merge($options, compact('conditions')); return parent::find('all', $options); diff --git a/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php b/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php index eb322cca615..e88842d1f11 100644 --- a/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php +++ b/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php @@ -124,7 +124,7 @@ public function testDefaultOutputAs() { TestCakeLog::config('test_console_log', array( 'engine' => 'TestConsoleLog', )); - if (DS == '\\' && !(bool)env('ANSICON')) { + if (DS === '\\' && !(bool)env('ANSICON')) { $expected = ConsoleOutput::PLAIN; } else { $expected = ConsoleOutput::COLOR; diff --git a/lib/Cake/Test/Case/Model/AclNodeTest.php b/lib/Cake/Test/Case/Model/AclNodeTest.php index db428c88335..1038c07b272 100644 --- a/lib/Cake/Test/Case/Model/AclNodeTest.php +++ b/lib/Cake/Test/Case/Model/AclNodeTest.php @@ -193,9 +193,9 @@ class DbAroUserTest extends CakeTestModel { * @return void */ public function bindNode($ref = null) { - if (Configure::read('DbAclbindMode') == 'string') { + if (Configure::read('DbAclbindMode') === 'string') { return 'ROOT/admins/Gandalf'; - } elseif (Configure::read('DbAclbindMode') == 'array') { + } elseif (Configure::read('DbAclbindMode') === 'array') { return array('DbAroTest' => array('DbAroTest.model' => 'AuthUser', 'DbAroTest.foreign_key' => 2)); } } diff --git a/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php b/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php index 2768c68b63f..c942118ddd0 100644 --- a/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php +++ b/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php @@ -61,7 +61,7 @@ public function setup(Model $model, $config = array()) { */ public function beforeFind(Model $model, $query) { $settings = $this->settings[$model->alias]; - if (!isset($settings['beforeFind']) || $settings['beforeFind'] == 'off') { + if (!isset($settings['beforeFind']) || $settings['beforeFind'] === 'off') { return parent::beforeFind($model, $query); } switch ($settings['beforeFind']) { @@ -86,7 +86,7 @@ public function beforeFind(Model $model, $query) { */ public function afterFind(Model $model, $results, $primary) { $settings = $this->settings[$model->alias]; - if (!isset($settings['afterFind']) || $settings['afterFind'] == 'off') { + if (!isset($settings['afterFind']) || $settings['afterFind'] === 'off') { return parent::afterFind($model, $results, $primary); } switch ($settings['afterFind']) { @@ -109,7 +109,7 @@ public function afterFind(Model $model, $results, $primary) { */ public function beforeSave(Model $model) { $settings = $this->settings[$model->alias]; - if (!isset($settings['beforeSave']) || $settings['beforeSave'] == 'off') { + if (!isset($settings['beforeSave']) || $settings['beforeSave'] === 'off') { return parent::beforeSave($model); } switch ($settings['beforeSave']) { @@ -132,7 +132,7 @@ public function beforeSave(Model $model) { */ public function afterSave(Model $model, $created) { $settings = $this->settings[$model->alias]; - if (!isset($settings['afterSave']) || $settings['afterSave'] == 'off') { + if (!isset($settings['afterSave']) || $settings['afterSave'] === 'off') { return parent::afterSave($model, $created); } $string = 'modified after'; @@ -162,7 +162,7 @@ public function afterSave(Model $model, $created) { */ public function beforeValidate(Model $model) { $settings = $this->settings[$model->alias]; - if (!isset($settings['validate']) || $settings['validate'] == 'off') { + if (!isset($settings['validate']) || $settings['validate'] === 'off') { return parent::beforeValidate($model); } switch ($settings['validate']) { @@ -189,7 +189,7 @@ public function beforeValidate(Model $model) { */ public function afterValidate(Model $model) { $settings = $this->settings[$model->alias]; - if (!isset($settings['afterValidate']) || $settings['afterValidate'] == 'off') { + if (!isset($settings['afterValidate']) || $settings['afterValidate'] === 'off') { return parent::afterValidate($model); } switch ($settings['afterValidate']) { @@ -210,7 +210,7 @@ public function afterValidate(Model $model) { */ public function beforeDelete(Model $model, $cascade = true) { $settings = $this->settings[$model->alias]; - if (!isset($settings['beforeDelete']) || $settings['beforeDelete'] == 'off') { + if (!isset($settings['beforeDelete']) || $settings['beforeDelete'] === 'off') { return parent::beforeDelete($model, $cascade); } switch ($settings['beforeDelete']) { @@ -235,7 +235,7 @@ public function beforeDelete(Model $model, $cascade = true) { */ public function afterDelete(Model $model) { $settings = $this->settings[$model->alias]; - if (!isset($settings['afterDelete']) || $settings['afterDelete'] == 'off') { + if (!isset($settings['afterDelete']) || $settings['afterDelete'] === 'off') { return parent::afterDelete($model); } switch ($settings['afterDelete']) { @@ -253,7 +253,7 @@ public function afterDelete(Model $model) { */ public function onError(Model $model, $error) { $settings = $this->settings[$model->alias]; - if (!isset($settings['onError']) || $settings['onError'] == 'off') { + if (!isset($settings['onError']) || $settings['onError'] === 'off') { return parent::onError($model, $error); } echo "onError trigger success"; diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index 09f65259196..3079efbcc08 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -1131,7 +1131,7 @@ public function testGenerateAssociationQuerySelfJoin() { $linkModel = $this->Model->Category2->{$assoc}; $external = isset($assocData['external']); - if ($this->Model->Category2->alias == $linkModel->alias && $type != 'hasAndBelongsToMany' && $type != 'hasMany') { + if ($this->Model->Category2->alias == $linkModel->alias && $type !== 'hasAndBelongsToMany' && $type !== 'hasMany') { $result = $this->Dbo->generateAssociationQuery($this->Model->Category2, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null); $this->assertFalse(empty($result)); } else { diff --git a/lib/Cake/Test/Case/Model/models.php b/lib/Cake/Test/Case/Model/models.php index d70c276c52b..815a101edd4 100644 --- a/lib/Cake/Test/Case/Model/models.php +++ b/lib/Cake/Test/Case/Model/models.php @@ -2574,7 +2574,7 @@ public function initialize($levelLimit = 3, $childLimit = 3, $currentLevel = nul $this->create($data); if ($hierarchal) { - if ($this->name == 'UnconventionalTree') { + if ($this->name === 'UnconventionalTree') { $data[$this->name]['join'] = $parentId; } else { $data[$this->name]['parent_id'] = $parentId; diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index 1df89fc5a92..5d7b9f922ab 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -29,7 +29,7 @@ public function reConstruct($url = 'some/path', $parseEnvironment = true) { if (empty($url)) { $url = $this->_url(); } - if ($url[0] == '/') { + if ($url[0] === '/') { $url = substr($url, 1); } $this->url = $url; diff --git a/lib/Cake/Test/Case/Routing/DispatcherTest.php b/lib/Cake/Test/Case/Routing/DispatcherTest.php index 4c76e1c6624..f3125977633 100644 --- a/lib/Cake/Test/Case/Routing/DispatcherTest.php +++ b/lib/Cake/Test/Case/Routing/DispatcherTest.php @@ -376,7 +376,7 @@ class SomePostsController extends AppController { * @return void */ public function beforeFilter() { - if ($this->params['action'] == 'index') { + if ($this->params['action'] === 'index') { $this->params['action'] = 'view'; } else { $this->params['action'] = 'change'; @@ -1666,7 +1666,7 @@ public function testHttpMethodOverrides() { */ protected function _cachePath($here) { $path = $here; - if ($here == '/') { + if ($here === '/') { $path = 'home'; } $path = strtolower(Inflector::slug($path)); diff --git a/lib/Cake/Test/Case/Routing/RouterTest.php b/lib/Cake/Test/Case/Routing/RouterTest.php index c2d3ff8100e..109a1f29354 100644 --- a/lib/Cake/Test/Case/Routing/RouterTest.php +++ b/lib/Cake/Test/Case/Routing/RouterTest.php @@ -57,7 +57,7 @@ public function tearDown() { * @return void */ public function testFullBaseURL() { - $skip = PHP_SAPI == 'cli'; + $skip = PHP_SAPI === 'cli'; if ($skip) { $this->markTestSkipped('Cannot validate base urls in CLI'); } diff --git a/lib/Cake/Test/Case/Utility/FileTest.php b/lib/Cake/Test/Case/Utility/FileTest.php index a3c2cf22ad4..998e0c21f37 100644 --- a/lib/Cake/Test/Case/Utility/FileTest.php +++ b/lib/Cake/Test/Case/Utility/FileTest.php @@ -303,7 +303,7 @@ public function testOpeningNonExistentFileCreatesIt() { */ public function testPrepare() { $string = "some\nvery\ncool\r\nteststring here\n\n\nfor\r\r\n\n\r\n\nhere"; - if (DS == '\\') { + if (DS === '\\') { $expected = "some\r\nvery\r\ncool\r\nteststring here\r\n\r\n\r\n"; $expected .= "for\r\n\r\n\r\n\r\n\r\nhere"; } else { diff --git a/lib/Cake/Test/test_app/Lib/Cache/Engine/TestAppCacheEngine.php b/lib/Cake/Test/test_app/Lib/Cache/Engine/TestAppCacheEngine.php index f09544a4aae..7ca755bb3c4 100644 --- a/lib/Cake/Test/test_app/Lib/Cache/Engine/TestAppCacheEngine.php +++ b/lib/Cake/Test/test_app/Lib/Cache/Engine/TestAppCacheEngine.php @@ -20,7 +20,7 @@ class TestAppCacheEngine extends CacheEngine { public function write($key, $value, $duration) { - if ($key == 'fail') { + if ($key === 'fail') { return false; } } diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index 85e653df333..8c4b0218bdf 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -380,7 +380,7 @@ public function assertTags($string, $expected, $fullDebug = false) { $tags = (string)$tags; } $i++; - if (is_string($tags) && $tags{0} == '<') { + if (is_string($tags) && $tags{0} === '<') { $tags = array(substr($tags, 1) => array()); } elseif (is_string($tags)) { $tagsTrimmed = preg_replace('/\s+/m', '', $tags); @@ -388,7 +388,7 @@ public function assertTags($string, $expected, $fullDebug = false) { if (preg_match('/^\*?\//', $tags, $match) && $tagsTrimmed !== '//') { $prefix = array(null, null); - if ($match[0] == '*/') { + if ($match[0] === '*/') { $prefix = array('Anything, ', '.*?'); } $regex[] = array( diff --git a/lib/Cake/TestSuite/ControllerTestCase.php b/lib/Cake/TestSuite/ControllerTestCase.php index 76bc857da18..86aa62fb91a 100644 --- a/lib/Cake/TestSuite/ControllerTestCase.php +++ b/lib/Cake/TestSuite/ControllerTestCase.php @@ -186,7 +186,7 @@ abstract class ControllerTestCase extends CakeTestCase { * @throws BadMethodCallException when you call methods that don't exist. */ public function __call($name, $arguments) { - if ($name == 'testAction') { + if ($name === 'testAction') { return call_user_func_array(array($this, '_testAction'), $arguments); } throw new BadMethodCallException("Method '{$name}' does not exist."); @@ -226,7 +226,7 @@ protected function _testAction($url = '', $options = array()) { $_SERVER['REQUEST_METHOD'] = strtoupper($options['method']); if (is_array($options['data'])) { - if (strtoupper($options['method']) == 'GET') { + if (strtoupper($options['method']) === 'GET') { $_GET = $options['data']; $_POST = array(); } else { @@ -263,7 +263,7 @@ protected function _testAction($url = '', $options = array()) { $this->generate($plugin . Inflector::camelize($request->params['controller'])); } $params = array(); - if ($options['return'] == 'result') { + if ($options['return'] === 'result') { $params['return'] = 1; $params['bare'] = 1; $params['requested'] = 1; diff --git a/lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php b/lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php index 359b99ccc1e..7f0d21686f4 100644 --- a/lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php +++ b/lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php @@ -157,14 +157,14 @@ public function coverageScript() {