From 5cc03ca80524c1d8805baf2e3f7923397ca29d3a Mon Sep 17 00:00:00 2001 From: dogmatic69 Date: Fri, 14 Sep 2012 18:54:29 +0100 Subject: [PATCH] converting if($foo == true) to if($foo) --- lib/Cake/Console/Command/ConsoleShell.php | 14 +++++++------- lib/Cake/Console/Command/Task/ControllerTask.php | 2 +- lib/Cake/Console/Command/Task/DbConfigTask.php | 6 +----- lib/Cake/Console/Command/Task/ModelTask.php | 10 ++++------ lib/Cake/Network/CakeSocket.php | 2 +- lib/Cake/Routing/Router.php | 2 +- lib/Cake/Test/Case/Network/CakeRequestTest.php | 2 +- lib/Cake/View/Helper/CacheHelper.php | 2 +- lib/Cake/View/Helper/FormHelper.php | 4 ++-- lib/Cake/View/Helper/PaginatorHelper.php | 7 +------ 10 files changed, 20 insertions(+), 31 deletions(-) diff --git a/lib/Cake/Console/Command/ConsoleShell.php b/lib/Cake/Console/Command/ConsoleShell.php index d8c79c9338f..66d286c03bf 100644 --- a/lib/Cake/Console/Command/ConsoleShell.php +++ b/lib/Cake/Console/Command/ConsoleShell.php @@ -182,7 +182,7 @@ public function main($command = null) { $this->out(" - {$model}"); } break; - case (preg_match("/^(\w+) bind (\w+) (\w+)/", $command, $tmp) == true): + case preg_match("/^(\w+) bind (\w+) (\w+)/", $command, $tmp): foreach ($tmp as $data) { $data = strip_tags($data); $data = str_replace($this->badCommandChars, "", $data); @@ -200,7 +200,7 @@ public function main($command = null) { $this->out(__d('cake_console', "Please verify you are using valid models and association types")); } break; - case (preg_match("/^(\w+) unbind (\w+) (\w+)/", $command, $tmp) == true): + case preg_match("/^(\w+) unbind (\w+) (\w+)/", $command, $tmp): foreach ($tmp as $data) { $data = strip_tags($data); $data = str_replace($this->badCommandChars, "", $data); @@ -298,7 +298,7 @@ public function main($command = null) { $this->out(__d('cake_console', 'Saved record for %s', $modelToSave)); } break; - case (preg_match("/^(\w+) columns/", $command, $tmp) == true): + case preg_match("/^(\w+) columns/", $command, $tmp): $modelToCheck = strip_tags(str_replace($this->badCommandChars, "", $tmp[1])); if ($this->_isValidModel($modelToCheck)) { @@ -315,22 +315,22 @@ public function main($command = null) { $this->out(__d('cake_console', "Please verify that you selected a valid model")); } break; - case (preg_match("/^routes\s+reload/i", $command, $tmp) == true): + case preg_match("/^routes\s+reload/i", $command, $tmp): if (!$this->_loadRoutes()) { $this->err(__d('cake_console', "There was an error loading the routes config. Please check that the file exists and is free of parse errors.")); break; } $this->out(__d('cake_console', "Routes configuration reloaded, %d routes connected", count(Router::$routes))); break; - case (preg_match("/^routes\s+show/i", $command, $tmp) == true): + case preg_match("/^routes\s+show/i", $command, $tmp): $this->out(print_r(Hash::combine(Router::$routes, '{n}.template', '{n}.defaults'), true)); break; - case (preg_match("/^route\s+(\(.*\))$/i", $command, $tmp) == true): + case preg_match("/^route\s+(\(.*\))$/i", $command, $tmp): if ($url = eval('return array' . $tmp[1] . ';')) { $this->out(Router::url($url)); } break; - case (preg_match("/^route\s+(.*)/i", $command, $tmp) == true): + case preg_match("/^route\s+(.*)/i", $command, $tmp): $this->out(var_export(Router::parse($tmp[1]), true)); break; default: diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index 567e288c89b..657274aa048 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -395,7 +395,7 @@ public function listAll($useDbConfig = null) { } $this->__tables = $this->Model->getAllTables($useDbConfig); - if ($this->interactive == true) { + if ($this->interactive) { $this->out(__d('cake_console', 'Possible Controllers based on your current database:')); $this->hr(); $this->_controllerNames = array(); diff --git a/lib/Cake/Console/Command/Task/DbConfigTask.php b/lib/Cake/Console/Command/Task/DbConfigTask.php index f952fbbd4a5..bd732fe9678 100644 --- a/lib/Cake/Console/Command/Task/DbConfigTask.php +++ b/lib/Cake/Console/Command/Task/DbConfigTask.php @@ -277,11 +277,7 @@ public function bake($configs) { $info['port'] = null; } - if ($info['persistent'] === false) { - $info['persistent'] = 'false'; - } else { - $info['persistent'] = ($info['persistent'] == true) ? 'true' : 'false'; - } + $info['persistent'] = var_export((bool)$info['persistent'], true); $oldConfigs[] = array( 'name' => $configName, diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index b13330d6f0a..5aa14d39ecc 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -472,16 +472,14 @@ public function fieldValidation($fieldName, $metaData, $primaryKey = 'id') { } if ($choice != $defaultChoice) { + $validate[$validatorName] = $choice; if (is_numeric($choice) && isset($this->_validations[$choice])) { $validate[$validatorName] = $this->_validations[$choice]; - } else { - $validate[$validatorName] = $choice; } } - if ($this->interactive == true && $choice != $defaultChoice) { + $anotherValidator = 'n'; + if ($this->interactive && $choice != $defaultChoice) { $anotherValidator = $this->in(__d('cake_console', 'Would you like to add another validation rule?'), array('y', 'n'), 'n'); - } else { - $anotherValidator = 'n'; } } return $validate; @@ -583,7 +581,7 @@ public function findHasOneAndMany(Model $model, $associations) { $pattern = '/_' . preg_quote($model->table, '/') . '|' . preg_quote($model->table, '/') . '_/'; $possibleJoinTable = preg_match($pattern, $otherTable); - if ($possibleJoinTable == true) { + if ($possibleJoinTable) { continue; } foreach ($modelFieldsTemp as $fieldName => $field) { diff --git a/lib/Cake/Network/CakeSocket.php b/lib/Cake/Network/CakeSocket.php index 04f0302c432..aa5ab6dc839 100644 --- a/lib/Cake/Network/CakeSocket.php +++ b/lib/Cake/Network/CakeSocket.php @@ -130,7 +130,7 @@ public function connect() { $scheme = 'ssl://'; } - if ($this->config['persistent'] == true) { + if ($this->config['persistent']) { $this->connection = @pfsockopen($scheme . $this->config['host'], $this->config['port'], $errNum, $errStr, $this->config['timeout']); } else { $this->connection = @fsockopen($scheme . $this->config['host'], $this->config['port'], $errNum, $errStr, $this->config['timeout']); diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 662ed0af017..4c6f3552822 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -425,7 +425,7 @@ public static function connectNamed($named, $options = array()) { $options = array_merge(array('default' => false, 'reset' => false, 'greedy' => true), $options); } - if ($options['reset'] == true || self::$_namedConfig['rules'] === false) { + if ($options['reset'] || self::$_namedConfig['rules'] === false) { self::$_namedConfig['rules'] = array(); } diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index ae64aad6e8c..1e3977bef3f 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -962,7 +962,7 @@ public function testAddDetector() { * @return void */ public function detectCallback($request) { - return $request->return == true; + return (bool)$request->return; } /** diff --git a/lib/Cake/View/Helper/CacheHelper.php b/lib/Cake/View/Helper/CacheHelper.php index 2f85cd50bb1..3ebcea3f8b7 100644 --- a/lib/Cake/View/Helper/CacheHelper.php +++ b/lib/Cake/View/Helper/CacheHelper.php @@ -312,7 +312,7 @@ protected function _writeFile($content, $timestamp, $useCallbacks = false) { Router::setRequestInfo($controller->request); $this->request = $request;'; - if ($useCallbacks == true) { + if ($useCallbacks) { $file .= ' $controller->constructClasses(); $controller->startupProcess();'; diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index d9b5b6a8d3a..f561b6ede93 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -1286,7 +1286,7 @@ public function checkbox($fieldName, $options = array()) { 'value' => ($options['hiddenField'] !== true ? $options['hiddenField'] : '0'), 'secure' => false ); - if (isset($options['disabled']) && $options['disabled'] == true) { + if (isset($options['disabled']) && $options['disabled']) { $hiddenOptions['disabled'] = 'disabled'; } $output = $this->hidden($fieldName, $hiddenOptions); @@ -1865,7 +1865,7 @@ public function select($fieldName, $options = array(), $attributes = array()) { if (!empty($tag) || isset($template)) { $hasOptions = (count($options) > 0 || $showEmpty); if ( - (!isset($secure) || $secure == true) && + (!isset($secure) || $secure) && empty($attributes['disabled']) && $hasOptions ) { diff --git a/lib/Cake/View/Helper/PaginatorHelper.php b/lib/Cake/View/Helper/PaginatorHelper.php index 207bad137a2..83687734524 100644 --- a/lib/Cake/View/Helper/PaginatorHelper.php +++ b/lib/Cake/View/Helper/PaginatorHelper.php @@ -526,12 +526,7 @@ public function hasPage($model = null, $page = 1) { */ protected function _hasPage($model, $page) { $params = $this->params($model); - if (!empty($params)) { - if ($params["{$page}Page"] == true) { - return true; - } - } - return false; + return !empty($params) && $params[$page . 'Page']; } /**