Permalink
Browse files

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

  • Loading branch information...
1 parent 22a2e1b commit 5cc03ca80524c1d8805baf2e3f7923397ca29d3a @dogmatic69 dogmatic69 committed Sep 14, 2012
@@ -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:
@@ -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();
@@ -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,
@@ -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) {
@@ -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']);
@@ -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();
}
@@ -962,7 +962,7 @@ public function testAddDetector() {
* @return void
*/
public function detectCallback($request) {
- return $request->return == true;
+ return (bool)$request->return;
}
/**
@@ -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();';
@@ -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
) {
@@ -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'];
}
/**

0 comments on commit 5cc03ca

Please sign in to comment.