Browse Source

converting if($foo == true) to if($foo)

dogmatic69 13 years ago
parent
commit
5cc03ca805

+ 7 - 7
lib/Cake/Console/Command/ConsoleShell.php

@@ -182,7 +182,7 @@ class ConsoleShell extends AppShell {
 						$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 @@ class ConsoleShell extends AppShell {
 						$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 @@ class ConsoleShell extends AppShell {
 						$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 @@ class ConsoleShell extends AppShell {
 						$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:

+ 1 - 1
lib/Cake/Console/Command/Task/ControllerTask.php

@@ -395,7 +395,7 @@ class ControllerTask extends BakeTask {
 		}
 		$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();

+ 1 - 5
lib/Cake/Console/Command/Task/DbConfigTask.php

@@ -277,11 +277,7 @@ class DbConfigTask extends AppShell {
 					$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,

+ 4 - 6
lib/Cake/Console/Command/Task/ModelTask.php

@@ -472,16 +472,14 @@ class ModelTask extends BakeTask {
 			}
 
 			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 @@ class ModelTask extends BakeTask {
 
 			$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) {

+ 1 - 1
lib/Cake/Network/CakeSocket.php

@@ -130,7 +130,7 @@ class CakeSocket {
 			$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']);

+ 1 - 1
lib/Cake/Routing/Router.php

@@ -425,7 +425,7 @@ class Router {
 			$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();
 		}
 

+ 1 - 1
lib/Cake/Test/Case/Network/CakeRequestTest.php

@@ -962,7 +962,7 @@ class CakeRequestTest extends CakeTestCase {
  * @return void
  */
 	public function detectCallback($request) {
-		return $request->return == true;
+		return (bool)$request->return;
 	}
 
 /**

+ 1 - 1
lib/Cake/View/Helper/CacheHelper.php

@@ -312,7 +312,7 @@ class CacheHelper extends AppHelper {
 				Router::setRequestInfo($controller->request);
 				$this->request = $request;';
 
-		if ($useCallbacks == true) {
+		if ($useCallbacks) {
 			$file .= '
 				$controller->constructClasses();
 				$controller->startupProcess();';

+ 2 - 2
lib/Cake/View/Helper/FormHelper.php

@@ -1286,7 +1286,7 @@ class FormHelper extends AppHelper {
 				'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 @@ class FormHelper extends AppHelper {
 		if (!empty($tag) || isset($template)) {
 			$hasOptions = (count($options) > 0 || $showEmpty);
 			if (
-				(!isset($secure) || $secure == true) &&
+				(!isset($secure) || $secure) &&
 				empty($attributes['disabled']) &&
 				$hasOptions
 			) {

+ 1 - 6
lib/Cake/View/Helper/PaginatorHelper.php

@@ -526,12 +526,7 @@ class PaginatorHelper extends AppHelper {
  */
 	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'];
 	}
 
 /**