coding standards and simplification of else cases as well as some minor fixes

This commit is contained in:
euromark 2013-07-03 00:52:48 +02:00
parent 58149f2315
commit 7cb19b97db
31 changed files with 142 additions and 169 deletions

View file

@ -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.'));
}

View file

@ -345,7 +345,6 @@ class ConsoleShell extends AppShell {
default:
$this->out(__d('cake_console', "Invalid command"));
$this->out();
break;
}
$command = '';
}

View file

@ -84,8 +84,7 @@ class I18nShell extends AppShell {
$this->out($this->OptionParser->help());
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.'));
}

View file

@ -107,12 +107,11 @@ 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();
}
}
/**
* Read database and Write schema object
@ -185,11 +184,10 @@ 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();
}
}
/**
* Dump Schema object to sql file

View file

@ -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();
}

View file

@ -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;
}
/**

View file

@ -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);
}
} elseif ($this->controller->scaffoldError('delete') === false) {
return $this->_scaffoldError();
}

View file

@ -198,7 +198,7 @@ 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'));
@ -206,7 +206,6 @@ class ErrorHandler {
}
return CakeLog::write($log, $message);
}
}
/**
* Generate an error page when some fatal error happens.

View file

@ -762,7 +762,7 @@ 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;
@ -773,7 +773,6 @@ class TreeBehavior extends ModelBehavior {
array('callbacks' => false, 'validate' => false)
);
}
}
/**
* Check if the current tree is valid.

View file

@ -755,15 +755,13 @@ class Postgres extends DboSource {
break;
default:
$resultRow[$table][$column] = $row[$index];
break;
}
}
return $resultRow;
} else {
}
$this->_result->closeCursor();
return false;
}
}
/**
* Translates between PHP boolean values and PostgreSQL boolean values
@ -788,7 +786,6 @@ class Postgres extends DboSource {
break;
default:
$result = (bool)$data;
break;
}
if ($quote) {

View file

@ -50,7 +50,6 @@ class CakeTestModel extends Model {
break;
default:
$queryData['order'] = array($this->alias . '.' . $this->primaryKey => 'ASC');
break;
}
return $queryData;
}

View file

@ -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;
}
}

View file

@ -334,7 +334,6 @@ class Inflector {
}
}
self::${$var}['rules'] = $rules + self::${$var}['rules'];
break;
}
}

View file

@ -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;
}

View file

@ -665,15 +665,13 @@ class Helper extends Object {
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('#</*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i', "", $this->_cleaned);
} while ($oldstring != $this->_cleaned);
} while ($oldstring !== $this->_cleaned);
$this->_cleaned = str_replace(array("&amp;", "&lt;", "&gt;"), array("&amp;amp;", "&amp;lt;", "&amp;gt;"), $this->_cleaned);
}

View file

@ -420,7 +420,6 @@ class FormHelper extends AppHelper {
));
default:
$htmlAttributes['method'] = 'post';
break;
}
$this->requestType = strtolower($options['type']);

View file

@ -165,7 +165,6 @@ abstract class JsBaseEngineHelper extends AppHelper {
if ($quoteString) {
$val = '"' . $val . '"';
}
break;
}
return $val;
}

View file

@ -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;
}

View file

@ -78,7 +78,6 @@ class TimeHelper extends AppHelper {
break;
default:
$this->{$name} = $value;
break;
}
}