diff --git a/lib/Cake/Console/Command/ApiShell.php b/lib/Cake/Console/Command/ApiShell.php index 8ba50e7fb..44e36368f 100644 --- a/lib/Cake/Console/Command/ApiShell.php +++ b/lib/Cake/Console/Command/ApiShell.php @@ -73,12 +73,13 @@ class ApiShell extends AppShell { $path = $this->paths['core']; } - if (count($this->args) == 1) { - $file = $type; - $class = Inflector::camelize($type); - } elseif (count($this->args) > 1) { + $count = count($this->args); + if ($count > 1) { $file = Inflector::underscore($this->args[1]); $class = Inflector::camelize($this->args[1]); + } elseif($count) { + $file = $type; + $class = Inflector::camelize($type); } $objects = App::objects('class', $path); if (in_array($class, $objects)) { diff --git a/lib/Cake/Console/Command/Task/ExtractTask.php b/lib/Cake/Console/Command/Task/ExtractTask.php index 37af29d49..f6f9c560a 100644 --- a/lib/Cake/Console/Command/Task/ExtractTask.php +++ b/lib/Cake/Console/Command/Task/ExtractTask.php @@ -480,7 +480,7 @@ class ExtractTask extends AppShell { } $dims = Hash::dimensions($rules); - if ($dims == 1 || ($dims == 2 && isset($rules['message']))) { + if ($dims === 1 || ($dims === 2 && isset($rules['message']))) { $rules = array($rules); } diff --git a/lib/Cake/Console/Command/Task/ProjectTask.php b/lib/Cake/Console/Command/Task/ProjectTask.php index 769ec5e1d..d1dff2b9f 100644 --- a/lib/Cake/Console/Command/Task/ProjectTask.php +++ b/lib/Cake/Console/Command/Task/ProjectTask.php @@ -384,7 +384,7 @@ class ProjectTask extends AppShell { $admin = ''; $prefixes = Configure::read('Routing.prefixes'); if (!empty($prefixes)) { - if (count($prefixes) == 1) { + if (count($prefixes) === 1) { return $prefixes[0] . '_'; } if ($this->interactive) { diff --git a/lib/Cake/Console/Command/Task/TemplateTask.php b/lib/Cake/Console/Command/Task/TemplateTask.php index b9a7fba63..0a0366c5c 100644 --- a/lib/Cake/Console/Command/Task/TemplateTask.php +++ b/lib/Cake/Console/Command/Task/TemplateTask.php @@ -166,7 +166,7 @@ class TemplateTask extends AppShell { * @return string returns the path to the selected theme. */ public function getThemePath() { - if (count($this->templatePaths) == 1) { + if (count($this->templatePaths) === 1) { $paths = array_values($this->templatePaths); return $paths[0]; } diff --git a/lib/Cake/Console/Command/Task/TestTask.php b/lib/Cake/Console/Command/Task/TestTask.php index 8c28aac35..e1da43c79 100644 --- a/lib/Cake/Console/Command/Task/TestTask.php +++ b/lib/Cake/Console/Command/Task/TestTask.php @@ -83,15 +83,16 @@ class TestTask extends BakeTask { */ public function execute() { parent::execute(); - if (empty($this->args)) { + $count = count($this->args); + if (!$count) { $this->_interactive(); } - if (count($this->args) == 1) { + if ($count === 1) { $this->_interactive($this->args[0]); } - if (count($this->args) > 1) { + if ($count > 1) { $type = Inflector::classify($this->args[0]); if ($this->bake($type, $this->args[1])) { $this->out('Done'); diff --git a/lib/Cake/Console/Shell.php b/lib/Cake/Console/Shell.php index 567aa731f..f23004e4a 100644 --- a/lib/Cake/Console/Shell.php +++ b/lib/Cake/Console/Shell.php @@ -325,7 +325,7 @@ class Shell extends Object { */ public function dispatchShell() { $args = func_get_args(); - if (is_string($args[0]) && count($args) == 1) { + if (is_string($args[0]) && count($args) === 1) { $args = explode(' ', $args[0]); } diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index cd8c801c2..4eb68f1b5 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -454,7 +454,7 @@ class Controller extends Object implements CakeEventListener { $this->passedArgs = array_merge($request->params['pass'], $request->params['named']); } - if (array_key_exists('return', $request->params) && $request->params['return'] == 1) { + if (!empty($request->params['return']) && $request->params['return']) { $this->autoRender = false; } if (!empty($request->params['bare'])) { diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index f32c05bf4..541bd87aa 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -643,7 +643,7 @@ class Mysql extends DboSource { if (in_array($col, array('date', 'time', 'datetime', 'timestamp'))) { return $col; } - if (($col === 'tinyint' && $limit == 1) || $col === 'boolean') { + if (($col === 'tinyint' && $limit === 1) || $col === 'boolean') { return 'boolean'; } if (strpos($col, 'bigint') !== false || $col === 'bigint') { diff --git a/lib/Cake/Routing/Route/RedirectRoute.php b/lib/Cake/Routing/Route/RedirectRoute.php index bfb0f06c3..d890d2475 100644 --- a/lib/Cake/Routing/Route/RedirectRoute.php +++ b/lib/Cake/Routing/Route/RedirectRoute.php @@ -74,7 +74,7 @@ class RedirectRoute extends CakeRoute { $this->response = new CakeResponse(); } $redirect = $this->redirect; - if (count($this->redirect) == 1 && !isset($this->redirect['controller'])) { + if (count($this->redirect) === 1 && !isset($this->redirect['controller'])) { $redirect = $this->redirect[0]; } if (isset($this->options['persist']) && is_array($redirect)) { diff --git a/lib/Cake/Utility/CakeTime.php b/lib/Cake/Utility/CakeTime.php index f8f92fd79..dd1570b6e 100644 --- a/lib/Cake/Utility/CakeTime.php +++ b/lib/Cake/Utility/CakeTime.php @@ -745,7 +745,7 @@ class CakeTime { $years = floor($months / 12); $months = $months - ($years * 12); } - if ($future['m'] < $past['m'] && $future['Y'] - $past['Y'] == 1) { + if ($future['m'] < $past['m'] && $future['Y'] - $past['Y'] === 1) { $years--; } diff --git a/lib/Cake/Utility/Set.php b/lib/Cake/Utility/Set.php index 3bfa00882..6e1ffc6a0 100644 --- a/lib/Cake/Utility/Set.php +++ b/lib/Cake/Utility/Set.php @@ -349,7 +349,7 @@ class Set { $context = array('trace' => array(null), 'item' => $context, 'key' => $key); } if ($token === '..') { - if (count($context['trace']) == 1) { + if (count($context['trace']) === 1) { $context['trace'][] = $context['key']; } $parent = implode('/', $context['trace']) . '/.'; @@ -373,7 +373,7 @@ class Set { ); } elseif (is_array($context['item']) && array_key_exists($token, $context['item']) - && !(strval($key) === strval($token) && count($tokens) == 1 && $tokens[0] === '.')) { + && !(strval($key) === strval($token) && count($tokens) === 1 && $tokens[0] === '.')) { $items = $context['item'][$token]; if (!is_array($items)) { $items = array($items); diff --git a/lib/Cake/View/Helper.php b/lib/Cake/View/Helper.php index 7ff039331..d9296f09a 100644 --- a/lib/Cake/View/Helper.php +++ b/lib/Cake/View/Helper.php @@ -526,12 +526,11 @@ class Helper extends Object { $isHabtm = ( isset($this->fieldset[$this->_modelScope]['fields'][$parts[0]]['type']) && - $this->fieldset[$this->_modelScope]['fields'][$parts[0]]['type'] === 'multiple' && - $count == 1 + $this->fieldset[$this->_modelScope]['fields'][$parts[0]]['type'] === 'multiple' ); // habtm models are special - if ($count == 1 && $isHabtm) { + if ($count === 1 && $isHabtm) { $this->_association = $parts[0]; $entity = $parts[0] . '.' . $parts[0]; } else { diff --git a/lib/Cake/basics.php b/lib/Cake/basics.php index 434629562..30e5d0bca 100644 --- a/lib/Cake/basics.php +++ b/lib/Cake/basics.php @@ -44,20 +44,15 @@ if (!function_exists('config')) { */ function config() { $args = func_get_args(); + $count = count($args); + $included = 0; foreach ($args as $arg) { if (file_exists(APP . 'Config' . DS . $arg . '.php')) { include_once APP . 'Config' . DS . $arg . '.php'; - - if (count($args) == 1) { - return true; - } - } else { - if (count($args) == 1) { - return false; - } + $included++; } } - return true; + return $included === $count; } }