From 7cb19b97db1cef29a3b8b3dcb3ee092004cf2b11 Mon Sep 17 00:00:00 2001 From: euromark Date: Wed, 3 Jul 2013 00:52:48 +0200 Subject: [PATCH] coding standards and simplification of else cases as well as some minor fixes --- lib/Cake/Console/Command/BakeShell.php | 3 +-- lib/Cake/Console/Command/ConsoleShell.php | 23 ++++++++-------- lib/Cake/Console/Command/I18nShell.php | 9 +++---- lib/Cake/Console/Command/SchemaShell.php | 12 ++++----- lib/Cake/Console/Command/Task/FixtureTask.php | 16 +++++------ lib/Cake/Console/Command/Task/PluginTask.php | 3 +-- lib/Cake/Console/Command/Task/ProjectTask.php | 5 +--- lib/Cake/Controller/Scaffold.php | 26 +++++++++--------- lib/Cake/Error/ErrorHandler.php | 23 ++++++++-------- lib/Cake/Model/Behavior/TreeBehavior.php | 19 +++++++------ lib/Cake/Model/Datasource/DataSource.php | 4 +-- lib/Cake/Model/Datasource/Database/Mysql.php | 6 ++--- .../Model/Datasource/Database/Postgres.php | 17 +++++------- lib/Cake/Model/Datasource/DboSource.php | 14 +++++----- lib/Cake/Model/Model.php | 18 ++++++------- .../Case/Model/BehaviorCollectionTest.php | 8 +++--- lib/Cake/TestSuite/Fixture/CakeTestModel.php | 3 +-- lib/Cake/Utility/CakeTime.php | 3 +-- lib/Cake/Utility/Debugger.php | 8 +++--- lib/Cake/Utility/Inflector.php | 3 +-- lib/Cake/Utility/Validation.php | 1 - lib/Cake/View/Helper.php | 11 +++----- lib/Cake/View/Helper/FormHelper.php | 27 +++++++++---------- lib/Cake/View/Helper/JqueryEngineHelper.php | 2 +- lib/Cake/View/Helper/JsBaseEngineHelper.php | 11 ++++---- lib/Cake/View/Helper/MootoolsEngineHelper.php | 6 ++--- lib/Cake/View/Helper/PaginatorHelper.php | 5 ++-- .../View/Helper/PrototypeEngineHelper.php | 6 ++--- lib/Cake/View/Helper/RssHelper.php | 10 +++---- lib/Cake/View/Helper/TimeHelper.php | 3 +-- lib/Cake/basics.php | 6 ++--- 31 files changed, 142 insertions(+), 169 deletions(-) diff --git a/lib/Cake/Console/Command/BakeShell.php b/lib/Cake/Console/Command/BakeShell.php index 93503ef7f..ce12401a9 100644 --- a/lib/Cake/Console/Command/BakeShell.php +++ b/lib/Cake/Console/Command/BakeShell.php @@ -123,8 +123,7 @@ class BakeShell extends AppShell { $this->Test->execute(); break; case 'Q': - exit(0); - break; + return $this->_stop(); default: $this->out(__d('cake_console', 'You have made an invalid selection. Please choose a type of class to Bake by entering D, M, V, F, T, or C.')); } diff --git a/lib/Cake/Console/Command/ConsoleShell.php b/lib/Cake/Console/Command/ConsoleShell.php index e6ee110cd..7b97f89db 100644 --- a/lib/Cake/Console/Command/ConsoleShell.php +++ b/lib/Cake/Console/Command/ConsoleShell.php @@ -172,7 +172,7 @@ class ConsoleShell extends AppShell { switch ($command) { case 'help': $this->help(); - break; + break; case 'quit': case 'exit': return true; @@ -182,7 +182,7 @@ class ConsoleShell extends AppShell { foreach ($this->models as $model) { $this->out(" - {$model}"); } - break; + break; case preg_match("/^(\w+) bind (\w+) (\w+)/", $command, $tmp): foreach ($tmp as $data) { $data = strip_tags($data); @@ -200,7 +200,7 @@ class ConsoleShell extends AppShell { } else { $this->out(__d('cake_console', "Please verify you are using valid models and association types")); } - break; + break; case preg_match("/^(\w+) unbind (\w+) (\w+)/", $command, $tmp): foreach ($tmp as $data) { $data = strip_tags($data); @@ -228,7 +228,7 @@ class ConsoleShell extends AppShell { } else { $this->out(__d('cake_console', "Please verify you are using valid models, valid current association, and valid association types")); } - break; + break; case (strpos($command, "->find") > 0): // Remove any bad info $command = strip_tags($command); @@ -285,7 +285,7 @@ class ConsoleShell extends AppShell { $this->out(__d('cake_console', "%s is not a valid model", $modelToCheck)); } - break; + break; case (strpos($command, '->save') > 0): // Validate the model we're trying to save here $command = strip_tags($command); @@ -302,7 +302,7 @@ class ConsoleShell extends AppShell { //@codingStandardsIgnoreEnd $this->out(__d('cake_console', 'Saved record for %s', $modelToSave)); } - break; + break; case preg_match("/^(\w+) columns/", $command, $tmp): $modelToCheck = strip_tags(str_replace($this->badCommandChars, "", $tmp[1])); @@ -321,31 +321,30 @@ class ConsoleShell extends AppShell { } else { $this->out(__d('cake_console', "Please verify that you selected a valid model")); } - break; + break; 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; + break; case preg_match("/^routes\s+show/i", $command, $tmp): $this->out(print_r(Hash::combine(Router::$routes, '{n}.template', '{n}.defaults'), true)); - break; + break; case (preg_match("/^route\s+(\(.*\))$/i", $command, $tmp) == true): //@codingStandardsIgnoreStart if ($url = eval('return array' . $tmp[1] . ';')) { //@codingStandardsIgnoreEnd $this->out(Router::url($url)); } - break; + break; case preg_match("/^route\s+(.*)/i", $command, $tmp): $this->out(var_export(Router::parse($tmp[1]), true)); - break; + break; default: $this->out(__d('cake_console', "Invalid command")); $this->out(); - break; } $command = ''; } diff --git a/lib/Cake/Console/Command/I18nShell.php b/lib/Cake/Console/Command/I18nShell.php index bcfca62c4..c0782ba4e 100644 --- a/lib/Cake/Console/Command/I18nShell.php +++ b/lib/Cake/Console/Command/I18nShell.php @@ -76,16 +76,15 @@ class I18nShell extends AppShell { switch ($choice) { case 'e': $this->Extract->execute(); - break; + break; case 'i': $this->initdb(); - break; + break; case 'h': $this->out($this->OptionParser->help()); - break; + break; case 'q': - exit(0); - break; + return $this->_stop(); default: $this->out(__d('cake_console', 'You have made an invalid selection. Please choose a command to execute by entering E, I, H, or Q.')); } diff --git a/lib/Cake/Console/Command/SchemaShell.php b/lib/Cake/Console/Command/SchemaShell.php index 90acff90e..c45988b67 100644 --- a/lib/Cake/Console/Command/SchemaShell.php +++ b/lib/Cake/Console/Command/SchemaShell.php @@ -107,11 +107,10 @@ class SchemaShell extends AppShell { if ($File->exists()) { $this->out($File->read()); return $this->_stop(); - } else { - $file = $this->Schema->path . DS . $this->params['file']; - $this->err(__d('cake_console', 'Schema file (%s) could not be found.', $file)); - return $this->_stop(); } + $file = $this->Schema->path . DS . $this->params['file']; + $this->err(__d('cake_console', 'Schema file (%s) could not be found.', $file)); + return $this->_stop(); } /** @@ -185,10 +184,9 @@ class SchemaShell extends AppShell { if ($this->Schema->write($content)) { $this->out(__d('cake_console', 'Schema file: %s generated', $content['file'])); return $this->_stop(); - } else { - $this->err(__d('cake_console', 'Schema file: %s generated')); - return $this->_stop(); } + $this->err(__d('cake_console', 'Schema file: %s generated')); + return $this->_stop(); } /** diff --git a/lib/Cake/Console/Command/Task/FixtureTask.php b/lib/Cake/Console/Command/Task/FixtureTask.php index 2a3cdce61..d6831325e 100644 --- a/lib/Cake/Console/Command/Task/FixtureTask.php +++ b/lib/Cake/Console/Command/Task/FixtureTask.php @@ -304,7 +304,7 @@ class FixtureTask extends BakeTask { case 'integer': case 'float': $insert = $i + 1; - break; + break; case 'string': case 'binary': $isPrimaryUuid = ( @@ -319,22 +319,22 @@ class FixtureTask extends BakeTask { $insert = substr($insert, 0, (int)$fieldInfo['length'] - 2); } } - break; + break; case 'timestamp': $insert = time(); - break; + break; case 'datetime': $insert = date('Y-m-d H:i:s'); - break; + break; case 'date': $insert = date('Y-m-d'); - break; + break; case 'time': $insert = date('H:i:s'); - break; + break; case 'boolean': $insert = 1; - break; + break; case 'text': $insert = "Lorem ipsum dolor sit amet, aliquet feugiat."; $insert .= " Convallis morbi fringilla gravida,"; @@ -343,7 +343,7 @@ class FixtureTask extends BakeTask { $insert .= " vestibulum massa neque ut et, id hendrerit sit,"; $insert .= " feugiat in taciti enim proin nibh, tempor dignissim, rhoncus"; $insert .= " duis vestibulum nunc mattis convallis."; - break; + break; } $record[$field] = $insert; } diff --git a/lib/Cake/Console/Command/Task/PluginTask.php b/lib/Cake/Console/Command/Task/PluginTask.php index c64cdcaf3..4db5b7d3b 100644 --- a/lib/Cake/Console/Command/Task/PluginTask.php +++ b/lib/Cake/Console/Command/Task/PluginTask.php @@ -65,9 +65,8 @@ class PluginTask extends AppShell { $this->out(__d('cake_console', 'Plugin: %s already exists, no action taken', $plugin)); $this->out(__d('cake_console', 'Path: %s', $pluginPath)); return false; - } else { - $this->_interactive($plugin); } + $this->_interactive($plugin); } else { return $this->_interactive(); } diff --git a/lib/Cake/Console/Command/Task/ProjectTask.php b/lib/Cake/Console/Command/Task/ProjectTask.php index cc63d0846..d8fb25cb5 100644 --- a/lib/Cake/Console/Command/Task/ProjectTask.php +++ b/lib/Cake/Console/Command/Task/ProjectTask.php @@ -368,12 +368,9 @@ class ProjectTask extends AppShell { if ($File->write($result)) { Configure::write('Routing.prefixes', array($name)); return true; - } else { - return false; } - } else { - return false; } + return false; } /** diff --git a/lib/Cake/Controller/Scaffold.php b/lib/Cake/Controller/Scaffold.php index 27aecb8ed..477b8c9d5 100644 --- a/lib/Cake/Controller/Scaffold.php +++ b/lib/Cake/Controller/Scaffold.php @@ -250,9 +250,8 @@ class Scaffold { $success ); return $this->_sendMessage($message); - } else { - return $this->controller->afterScaffoldSaveError($action); } + return $this->controller->afterScaffoldSaveError($action); } else { if ($this->_validSession) { $this->controller->Session->setFlash(__d('cake', 'Please correct errors below.')); @@ -309,14 +308,13 @@ class Scaffold { if ($this->ScaffoldModel->delete()) { $message = __d('cake', 'The %1$s with id: %2$s has been deleted.', Inflector::humanize($this->modelClass), $id); return $this->_sendMessage($message); - } else { - $message = __d('cake', - 'There was an error deleting the %1$s with id: %2$s', - Inflector::humanize($this->modelClass), - $id - ); - return $this->_sendMessage($message); } + $message = __d('cake', + 'There was an error deleting the %1$s with id: %2$s', + Inflector::humanize($this->modelClass), + $id + ); + return $this->_sendMessage($message); } elseif ($this->controller->scaffoldError('delete') === false) { return $this->_scaffoldError(); } @@ -388,21 +386,21 @@ class Scaffold { case 'index': case 'list': $this->_scaffoldIndex($request); - break; + break; case 'view': $this->_scaffoldView($request); - break; + break; case 'add': case 'create': $this->_scaffoldSave($request, 'add'); - break; + break; case 'edit': case 'update': $this->_scaffoldSave($request, 'edit'); - break; + break; case 'delete': $this->_scaffoldDelete($request); - break; + break; } } else { throw new MissingActionException(array( diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index 7da8902d5..edb043bd7 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -198,14 +198,13 @@ class ErrorHandler { 'path' => Debugger::trimPath($file) ); return Debugger::getInstance()->outputError($data); - } else { - $message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']'; - if (!empty($errorConfig['trace'])) { - $trace = Debugger::trace(array('start' => 1, 'format' => 'log')); - $message .= "\nTrace:\n" . $trace . "\n"; - } - return CakeLog::write($log, $message); } + $message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']'; + if (!empty($errorConfig['trace'])) { + $trace = Debugger::trace(array('start' => 1, 'format' => 'log')); + $message .= "\nTrace:\n" . $trace . "\n"; + } + return CakeLog::write($log, $message); } /** @@ -254,28 +253,28 @@ class ErrorHandler { case E_USER_ERROR: $error = 'Fatal Error'; $log = LOG_ERR; - break; + break; case E_WARNING: case E_USER_WARNING: case E_COMPILE_WARNING: case E_RECOVERABLE_ERROR: $error = 'Warning'; $log = LOG_WARNING; - break; + break; case E_NOTICE: case E_USER_NOTICE: $error = 'Notice'; $log = LOG_NOTICE; - break; + break; case E_STRICT: $error = 'Strict'; $log = LOG_NOTICE; - break; + break; case E_DEPRECATED: case E_USER_DEPRECATED: $error = 'Deprecated'; $log = LOG_NOTICE; - break; + break; } return array($error, $log); } diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index 040aff1c1..1faeec819 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -762,17 +762,16 @@ class TreeBehavior extends ModelBehavior { array($Model->escapeField() => $id) ); return $Model->delete($id); - } else { - $edge = $this->_getMax($Model, $scope, $right, $recursive); - if ($node[$right] == $edge) { - $edge = $edge - 2; - } - $Model->id = $id; - return $Model->save( - array($left => $edge + 1, $right => $edge + 2, $parent => null), - array('callbacks' => false, 'validate' => false) - ); } + $edge = $this->_getMax($Model, $scope, $right, $recursive); + if ($node[$right] == $edge) { + $edge = $edge - 2; + } + $Model->id = $id; + return $Model->save( + array($left => $edge + 1, $right => $edge + 2, $parent => null), + array('callbacks' => false, 'validate' => false) + ); } /** diff --git a/lib/Cake/Model/Datasource/DataSource.php b/lib/Cake/Model/Datasource/DataSource.php index 9d091599e..e30353fd5 100644 --- a/lib/Cake/Model/Datasource/DataSource.php +++ b/lib/Cake/Model/Datasource/DataSource.php @@ -357,7 +357,7 @@ class DataSource extends Object { } } $type = $model->getColumnType($model->primaryKey); - break; + break; case '{$__cakeForeignKey__$}': foreach ($model->associations() as $name) { foreach ($model->$name as $assocName => $assoc) { @@ -389,7 +389,7 @@ class DataSource extends Object { } } } - break; + break; } if (empty($val) && $val !== '0') { return false; diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index 5bf989080..ed64940d6 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -516,13 +516,13 @@ class Mysql extends DboSource { } $colList[] = $alter; } - break; + break; case 'drop': foreach ($column as $field => $col) { $col['name'] = $field; $colList[] = 'DROP ' . $this->name($field); } - break; + break; case 'change': foreach ($column as $field => $col) { if (!isset($col['name'])) { @@ -530,7 +530,7 @@ class Mysql extends DboSource { } $colList[] = 'CHANGE ' . $this->name($field) . ' ' . $this->buildColumn($col); } - break; + break; } } $colList = array_merge($colList, $this->_alterIndexes($curTable, $indexes)); diff --git a/lib/Cake/Model/Datasource/Database/Postgres.php b/lib/Cake/Model/Datasource/Database/Postgres.php index 2c09cfbd8..1977a966f 100644 --- a/lib/Cake/Model/Datasource/Database/Postgres.php +++ b/lib/Cake/Model/Datasource/Database/Postgres.php @@ -516,13 +516,13 @@ class Postgres extends DboSource { $col['name'] = $field; $colList[] = 'ADD COLUMN ' . $this->buildColumn($col); } - break; + break; case 'drop': foreach ($column as $field => $col) { $col['name'] = $field; $colList[] = 'DROP COLUMN ' . $this->name($field); } - break; + break; case 'change': foreach ($column as $field => $col) { if (!isset($col['name'])) { @@ -552,7 +552,7 @@ class Postgres extends DboSource { } } - break; + break; } } if (isset($indexes['drop']['PRIMARY'])) { @@ -748,21 +748,19 @@ class Postgres extends DboSource { switch ($type) { case 'bool': $resultRow[$table][$column] = is_null($row[$index]) ? null : $this->boolean($row[$index]); - break; + break; case 'binary': case 'bytea': $resultRow[$table][$column] = is_null($row[$index]) ? null : stream_get_contents($row[$index]); - break; + break; default: $resultRow[$table][$column] = $row[$index]; - break; } } return $resultRow; - } else { - $this->_result->closeCursor(); - return false; } + $this->_result->closeCursor(); + return false; } /** @@ -788,7 +786,6 @@ class Postgres extends DboSource { break; default: $result = (bool)$data; - break; } if ($quote) { diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 824bd2869..c82ec3bdf 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -1569,7 +1569,7 @@ class DboSource extends DataSource { } return true; } - break; + break; case 'hasMany': $assocData['fields'] = $this->fields($linkModel, $association, $assocData['fields']); if (!empty($assocData['foreignKey'])) { @@ -1585,7 +1585,7 @@ class DboSource extends DataSource { 'offset' => $assocData['offset'], 'group' => null ); - break; + break; case 'hasAndBelongsToMany': $joinFields = array(); $joinAssoc = null; @@ -1622,7 +1622,7 @@ class DboSource extends DataSource { 'conditions' => $this->getConstraint('hasAndBelongsToMany', $model, $linkModel, $joinAlias, $assocData, $association) )) ); - break; + break; } if (isset($query)) { return $this->buildStatement($query, $model); @@ -2596,22 +2596,22 @@ class DboSource extends DataSource { switch ($operator) { case '=': $operator = 'IN'; - break; + break; case '!=': case '<>': $operator = 'NOT IN'; - break; + break; } $value = "({$value})"; } elseif ($null || $value === 'NULL') { switch ($operator) { case '=': $operator = 'IS'; - break; + break; case '!=': case '<>': $operator = 'IS NOT'; - break; + break; } } if ($virtual) { diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index a0033c818..09418910b 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -1058,34 +1058,34 @@ class Model extends Object implements CakeEventListener { switch ($key) { case 'fields': $data = ''; - break; + break; case 'foreignKey': $data = (($type === 'belongsTo') ? Inflector::underscore($assocKey) : Inflector::singularize($this->table)) . '_id'; - break; + break; case 'associationForeignKey': $data = Inflector::singularize($this->{$class}->table) . '_id'; - break; + break; case 'with': $data = Inflector::camelize(Inflector::singularize($this->{$type}[$assocKey]['joinTable'])); $dynamicWith = true; - break; + break; case 'joinTable': $tables = array($this->table, $this->{$class}->table); sort($tables); $data = $tables[0] . '_' . $tables[1]; - break; + break; case 'className': $data = $class; - break; + break; case 'unique': $data = true; - break; + break; } $this->{$type}[$assocKey][$key] = $data; } @@ -2281,7 +2281,7 @@ class Model extends Object implements CakeEventListener { $validationErrors[$association] = $this->{$association}->validationErrors; } $return[$association] = $validates; - break; + break; case 'hasMany': foreach ($values as $i => $value) { if (isset($values[$i][$association])) { @@ -2297,7 +2297,7 @@ class Model extends Object implements CakeEventListener { $validates = false; } $return[$association] = $_return; - break; + break; } } } diff --git a/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php b/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php index c11940cef..58a667baa 100644 --- a/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php +++ b/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php @@ -142,15 +142,15 @@ class TestBehavior extends ModelBehavior { switch ($settings['afterSave']) { case 'on': $model->data[$model->alias]['aftersave'] = $string; - break; + break; case 'test': unset($model->data[$model->alias]['name']); - break; + break; case 'test2': return false; case 'modify': $model->data[$model->alias]['name'] .= ' ' . $string; - break; + break; } } @@ -241,7 +241,7 @@ class TestBehavior extends ModelBehavior { switch ($settings['afterDelete']) { case 'on': echo 'afterDelete success'; - break; + break; } } diff --git a/lib/Cake/TestSuite/Fixture/CakeTestModel.php b/lib/Cake/TestSuite/Fixture/CakeTestModel.php index 0a0e25645..6e456c1cf 100644 --- a/lib/Cake/TestSuite/Fixture/CakeTestModel.php +++ b/lib/Cake/TestSuite/Fixture/CakeTestModel.php @@ -47,10 +47,9 @@ class CakeTestModel extends Model { case (is_string($queryData['fields']) && !($queryData['fields'] == $pk || $queryData['fields'] == $aliasedPk)) || (is_array($queryData['fields']) && !(array_key_exists($pk, $queryData['fields']) || array_key_exists($aliasedPk, $queryData['fields']))): - break; + break; default: $queryData['order'] = array($this->alias . '.' . $this->primaryKey => 'ASC'); - break; } return $queryData; } diff --git a/lib/Cake/Utility/CakeTime.php b/lib/Cake/Utility/CakeTime.php index d2fb91ddf..0804f1644 100644 --- a/lib/Cake/Utility/CakeTime.php +++ b/lib/Cake/Utility/CakeTime.php @@ -97,14 +97,13 @@ class CakeTime { * * @param string $name Variable name * @param mixes $value Variable value + * @return void */ public function __set($name, $value) { switch ($name) { case 'niceFormat': self::${$name} = $value; break; - default: - break; } } diff --git a/lib/Cake/Utility/Debugger.php b/lib/Cake/Utility/Debugger.php index 68417015c..871bd31b7 100644 --- a/lib/Cake/Utility/Debugger.php +++ b/lib/Cake/Utility/Debugger.php @@ -230,24 +230,24 @@ class Debugger { case E_USER_ERROR: $error = 'Fatal Error'; $level = LOG_ERR; - break; + break; case E_WARNING: case E_USER_WARNING: case E_COMPILE_WARNING: case E_RECOVERABLE_ERROR: $error = 'Warning'; $level = LOG_WARNING; - break; + break; case E_NOTICE: case E_USER_NOTICE: $error = 'Notice'; $level = LOG_NOTICE; - break; + break; case E_DEPRECATED: case E_USER_DEPRECATED: $error = 'Deprecated'; $level = LOG_NOTICE; - break; + break; default: return; } diff --git a/lib/Cake/Utility/Inflector.php b/lib/Cake/Utility/Inflector.php index 26e64a283..0fc06af7b 100644 --- a/lib/Cake/Utility/Inflector.php +++ b/lib/Cake/Utility/Inflector.php @@ -308,7 +308,7 @@ class Inflector { } else { self::$_transliteration = $rules + self::$_transliteration; } - break; + break; default: foreach ($rules as $rule => $pattern) { @@ -334,7 +334,6 @@ class Inflector { } } self::${$var}['rules'] = $rules + self::${$var}['rules']; - break; } } diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index 5935ee5b3..e60acd16d 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -255,7 +255,6 @@ class Validation { break; default: self::$errors[] = __d('cake_dev', 'You must define the $operator parameter for Validation::comparison()'); - break; } return false; } diff --git a/lib/Cake/View/Helper.php b/lib/Cake/View/Helper.php index 2c88ef0cd..cc3638aed 100644 --- a/lib/Cake/View/Helper.php +++ b/lib/Cake/View/Helper.php @@ -662,18 +662,16 @@ class Helper extends Object { switch ($field) { case '_method': $name = $field; - break; + break; default: $name = 'data[' . implode('][', $this->entity()) . ']'; - break; } if (is_array($options)) { $options[$key] = $name; return $options; - } else { - return $name; } + return $name; } /** @@ -729,9 +727,8 @@ class Helper extends Object { if (is_array($options)) { $options[$key] = $result; return $options; - } else { - return $result; } + return $result; } /** @@ -920,7 +917,7 @@ class Helper extends Object { do { $oldstring = $this->_cleaned; $this->_cleaned = preg_replace('#]*>#i', "", $this->_cleaned); - } while ($oldstring != $this->_cleaned); + } while ($oldstring !== $this->_cleaned); $this->_cleaned = str_replace(array("&", "<", ">"), array("&amp;", "&lt;", "&gt;"), $this->_cleaned); } diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index bc0247926..a97c85217 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -407,7 +407,7 @@ class FormHelper extends AppHelper { switch (strtolower($options['type'])) { case 'get': $htmlAttributes['method'] = 'get'; - break; + break; case 'file': $htmlAttributes['enctype'] = 'multipart/form-data'; $options['type'] = ($created) ? 'put' : 'post'; @@ -420,7 +420,6 @@ class FormHelper extends AppHelper { )); default: $htmlAttributes['method'] = 'post'; - break; } $this->requestType = strtolower($options['type']); @@ -2456,16 +2455,16 @@ class FormHelper extends AppHelper { $selects[] = $this->year( $fieldName, $minYear, $maxYear, $attrs['Year'] ); - break; + break; case 'M': $attrs['Month']['value'] = $month; $attrs['Month']['monthNames'] = $monthNames; $selects[] = $this->month($fieldName, $attrs['Month']); - break; + break; case 'D': $attrs['Day']['value'] = $day; $selects[] = $this->day($fieldName, $attrs['Day']); - break; + break; } } $opt = implode($separator, $selects); @@ -2477,7 +2476,7 @@ class FormHelper extends AppHelper { $attrs['Minute']['value'] = $min; $opt .= $this->hour($fieldName, true, $attrs['Hour']) . ':' . $this->minute($fieldName, $attrs['Minute']); - break; + break; case '12': $attrs['Hour']['value'] = $hour; $attrs['Minute']['value'] = $min; @@ -2485,7 +2484,7 @@ class FormHelper extends AppHelper { $opt .= $this->hour($fieldName, false, $attrs['Hour']) . ':' . $this->minute($fieldName, $attrs['Minute']) . ' ' . $this->meridian($fieldName, $attrs['Meridian']); - break; + break; } return $opt; } @@ -2719,20 +2718,20 @@ class FormHelper extends AppHelper { $data[sprintf('%02d', $i)] = sprintf('%02d', $i); $i += $interval; } - break; + break; case 'hour': for ($i = 1; $i <= 12; $i++) { $data[sprintf('%02d', $i)] = $i; } - break; + break; case 'hour24': for ($i = 0; $i <= 23; $i++) { $data[sprintf('%02d', $i)] = $i; } - break; + break; case 'meridian': $data = array('am' => 'am', 'pm' => 'pm'); - break; + break; case 'day': $min = 1; $max = 31; @@ -2747,7 +2746,7 @@ class FormHelper extends AppHelper { for ($i = $min; $i <= $max; $i++) { $data[sprintf('%02d', $i)] = $i; } - break; + break; case 'month': if ($options['monthNames'] === true) { $data['01'] = __d('cake', 'January'); @@ -2769,7 +2768,7 @@ class FormHelper extends AppHelper { $data[sprintf("%02s", $m)] = strftime("%m", mktime(1, 1, 1, $m, 1, 1999)); } } - break; + break; case 'year': $current = intval(date('Y')); @@ -2791,7 +2790,7 @@ class FormHelper extends AppHelper { if ($options['order'] !== 'asc') { $data = array_reverse($data, true); } - break; + break; } $this->_options[$name] = $data; return $this->_options[$name]; diff --git a/lib/Cake/View/Helper/JqueryEngineHelper.php b/lib/Cake/View/Helper/JqueryEngineHelper.php index 0bbc07c60..b72144a0c 100644 --- a/lib/Cake/View/Helper/JqueryEngineHelper.php +++ b/lib/Cake/View/Helper/JqueryEngineHelper.php @@ -235,7 +235,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper { case 'slideDown': case 'slideUp': $effect = ".$name($speed);"; - break; + break; } return $this->selection . $effect; } diff --git a/lib/Cake/View/Helper/JsBaseEngineHelper.php b/lib/Cake/View/Helper/JsBaseEngineHelper.php index 23c91616d..a7afce88c 100644 --- a/lib/Cake/View/Helper/JsBaseEngineHelper.php +++ b/lib/Cake/View/Helper/JsBaseEngineHelper.php @@ -147,25 +147,24 @@ abstract class JsBaseEngineHelper extends AppHelper { switch (true) { case (is_array($val) || is_object($val)): $val = $this->object($val); - break; + break; case ($val === null): $val = 'null'; - break; + break; case (is_bool($val)): $val = ($val === true) ? 'true' : 'false'; - break; + break; case (is_int($val)): $val = $val; - break; + break; case (is_float($val)): $val = sprintf("%.11f", $val); - break; + break; default: $val = $this->escape($val); if ($quoteString) { $val = '"' . $val . '"'; } - break; } return $val; } diff --git a/lib/Cake/View/Helper/MootoolsEngineHelper.php b/lib/Cake/View/Helper/MootoolsEngineHelper.php index e5058bac5..5d66cf2e5 100644 --- a/lib/Cake/View/Helper/MootoolsEngineHelper.php +++ b/lib/Cake/View/Helper/MootoolsEngineHelper.php @@ -205,10 +205,10 @@ class MootoolsEngineHelper extends JsBaseEngineHelper { switch ($name) { case 'hide': $effect = 'setStyle("display", "none")'; - break; + break; case 'show': $effect = 'setStyle("display", "")'; - break; + break; case 'fadeIn': case 'fadeOut': case 'slideIn': @@ -219,7 +219,7 @@ class MootoolsEngineHelper extends JsBaseEngineHelper { $effect .= "set(\"$effectName\", {duration:$speed})."; } $effect .= "$effectName(\"$direction\")"; - break; + break; } return $this->selection . '.' . $effect . ';'; } diff --git a/lib/Cake/View/Helper/PaginatorHelper.php b/lib/Cake/View/Helper/PaginatorHelper.php index 09af0d16c..7357abe15 100644 --- a/lib/Cake/View/Helper/PaginatorHelper.php +++ b/lib/Cake/View/Helper/PaginatorHelper.php @@ -628,10 +628,10 @@ class PaginatorHelper extends AppHelper { } $out = $start . $options['separator'][0] . $end . $options['separator'][1]; $out .= $paging['count']; - break; + break; case 'pages': $out = $paging['page'] . $options['separator'] . $paging['pageCount']; - break; + break; default: $map = array( '%page%' => $paging['page'], @@ -648,7 +648,6 @@ class PaginatorHelper extends AppHelper { '{:page}', '{:pages}', '{:current}', '{:count}', '{:start}', '{:end}', '{:model}' ); $out = str_replace($newKeys, array_values($map), $out); - break; } return $out; } diff --git a/lib/Cake/View/Helper/PrototypeEngineHelper.php b/lib/Cake/View/Helper/PrototypeEngineHelper.php index 1807cb765..c20a9f781 100644 --- a/lib/Cake/View/Helper/PrototypeEngineHelper.php +++ b/lib/Cake/View/Helper/PrototypeEngineHelper.php @@ -212,17 +212,17 @@ class PrototypeEngineHelper extends JsBaseEngineHelper { case 'hide': case 'show': $effect = $this->selection . '.' . $name . '();'; - break; + break; case 'slideIn': case 'slideOut': $name = ($name === 'slideIn') ? 'slideDown' : 'slideUp'; $effect = 'Effect.' . $name . '(' . $this->selection . $optionString . ');'; - break; + break; case 'fadeIn': case 'fadeOut': $name = ($name === 'fadeIn') ? 'appear' : 'fade'; $effect = $this->selection . '.' . $name . '(' . substr($optionString, 2) . ');'; - break; + break; } return $effect; } diff --git a/lib/Cake/View/Helper/RssHelper.php b/lib/Cake/View/Helper/RssHelper.php index b3706767f..f1e22faaf 100644 --- a/lib/Cake/View/Helper/RssHelper.php +++ b/lib/Cake/View/Helper/RssHelper.php @@ -208,7 +208,7 @@ class RssHelper extends AppHelper { switch ($key) { case 'pubDate' : $val = $this->time($val); - break; + break; case 'category' : if (is_array($val) && !empty($val[0])) { foreach ($val as $category) { @@ -224,7 +224,7 @@ class RssHelper extends AppHelper { } elseif (is_array($val) && isset($val['domain'])) { $attrib['domain'] = $val['domain']; } - break; + break; case 'link': case 'guid': case 'comments': @@ -234,7 +234,7 @@ class RssHelper extends AppHelper { $val = $val['url']; } $val = $this->url($val, true); - break; + break; case 'source': if (is_array($val) && isset($val['url'])) { $attrib['url'] = $this->url($val['url'], true); @@ -243,7 +243,7 @@ class RssHelper extends AppHelper { $attrib['url'] = $this->url($val[0], true); $val = $val[1]; } - break; + break; case 'enclosure': if (is_string($val['url']) && is_file(WWW_ROOT . $val['url']) && file_exists(WWW_ROOT . $val['url'])) { if (!isset($val['length']) && strpos($val['url'], '://') === false) { @@ -256,7 +256,7 @@ class RssHelper extends AppHelper { $val['url'] = $this->url($val['url'], true); $attrib = $val; $val = null; - break; + break; default: $attrib = $att; } diff --git a/lib/Cake/View/Helper/TimeHelper.php b/lib/Cake/View/Helper/TimeHelper.php index 175dd002a..a5edd8ef3 100644 --- a/lib/Cake/View/Helper/TimeHelper.php +++ b/lib/Cake/View/Helper/TimeHelper.php @@ -75,10 +75,9 @@ class TimeHelper extends AppHelper { switch ($name) { case 'niceFormat': $this->_engine->{$name} = $value; - break; + break; default: $this->{$name} = $value; - break; } } diff --git a/lib/Cake/basics.php b/lib/Cake/basics.php index b0b30e937..538de3f00 100644 --- a/lib/Cake/basics.php +++ b/lib/Cake/basics.php @@ -402,13 +402,13 @@ if (!function_exists('cache')) { switch (strtolower($target)) { case 'cache': $filename = CACHE . $path; - break; + break; case 'public': $filename = WWW_ROOT . $path; - break; + break; case 'tmp': $filename = TMP . $path; - break; + break; } $timediff = $expires - $now; $filetime = false;