Skip to content

Commit

Permalink
coding standards and else block simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
euromark committed Jul 3, 2013
1 parent f27d4a8 commit f389435
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 42 deletions.
6 changes: 3 additions & 3 deletions lib/Cake/Console/Command/SchemaShell.php
Expand Up @@ -327,15 +327,15 @@ protected function _create(CakeSchema $Schema, $table = null) {
$this->out("\n" . __d('cake_console', 'The following table(s) will be dropped.'));
$this->out(array_keys($drop));

if ('y' == $this->in(__d('cake_console', 'Are you sure you want to drop the table(s)?'), array('y', 'n'), 'n')) {
if ($this->in(__d('cake_console', 'Are you sure you want to drop the table(s)?'), array('y', 'n'), 'n') === 'y') {
$this->out(__d('cake_console', 'Dropping table(s).'));
$this->_run($drop, 'drop', $Schema);
}

$this->out("\n" . __d('cake_console', 'The following table(s) will be created.'));
$this->out(array_keys($create));

if ('y' == $this->in(__d('cake_console', 'Are you sure you want to create the table(s)?'), array('y', 'n'), 'y')) {
if ($this->in(__d('cake_console', 'Are you sure you want to create the table(s)?'), array('y', 'n'), 'y') === 'y') {
$this->out(__d('cake_console', 'Creating table(s).'));
$this->_run($create, 'create', $Schema);
}
Expand Down Expand Up @@ -378,7 +378,7 @@ protected function _update(&$Schema, $table = null) {

$this->out("\n" . __d('cake_console', 'The following statements will run.'));
$this->out(array_map('trim', $contents));
if ('y' == $this->in(__d('cake_console', 'Are you sure you want to alter the tables?'), array('y', 'n'), 'n')) {
if ($this->in(__d('cake_console', 'Are you sure you want to alter the tables?'), array('y', 'n'), 'n') === 'y') {
$this->out();
$this->out(__d('cake_console', 'Updating Database...'));
$this->_run($contents, 'update', $Schema);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/Task/ModelTask.php
Expand Up @@ -657,7 +657,7 @@ public function confirmAssociations(Model $model, $associations) {
$prompt = "{$model->name} {$type} {$assoc['alias']}?";
$response = $this->in($prompt, array('y', 'n'), 'y');

if ('n' == strtolower($response)) {
if (strtolower($response) === 'n') {
unset($associations[$type][$i]);
} elseif ($type === 'hasMany') {
unset($associations['hasOne'][$i]);
Expand Down
3 changes: 1 addition & 2 deletions lib/Cake/Console/Command/Task/ViewTask.php
Expand Up @@ -335,9 +335,8 @@ public function customAction() {
if (strtolower($looksGood) === 'y') {
$this->bake($action, ' ');
return $this->_stop();
} else {
$this->out(__d('cake_console', 'Bake Aborted.'));
}
$this->out(__d('cake_console', 'Bake Aborted.'));
}

/**
Expand Down
7 changes: 3 additions & 4 deletions lib/Cake/Controller/Scaffold.php
Expand Up @@ -252,10 +252,9 @@ protected function _scaffoldSave(CakeRequest $request, $action = 'edit') {
return $this->_sendMessage($message);
}
return $this->controller->afterScaffoldSaveError($action);
} else {
if ($this->_validSession) {
$this->controller->Session->setFlash(__d('cake', 'Please correct errors below.'));
}
}
if ($this->_validSession) {
$this->controller->Session->setFlash(__d('cake', 'Please correct errors below.'));
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Model/Model.php
Expand Up @@ -1255,11 +1255,11 @@ public function deconstruct($field, $data) {
isset($data['meridian']) &&
!empty($data['hour']) &&
$data['hour'] != 12 &&
'pm' == $data['meridian']
$data['meridian'] === 'pm'
) {
$data['hour'] = $data['hour'] + 12;
}
if (isset($data['hour']) && isset($data['meridian']) && $data['hour'] == 12 && 'am' == $data['meridian']) {
if (isset($data['hour']) && isset($data['meridian']) && $data['hour'] == 12 && $data['meridian'] === 'am') {
$data['hour'] = '00';
}
if ($type === 'time') {
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/Utility/Hash.php
Expand Up @@ -54,7 +54,6 @@ public static function get(array $data, $path) {
} else {
return null;
}

}
return $data;
}
Expand Down
3 changes: 1 addition & 2 deletions lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -731,9 +731,8 @@ public function error($field, $text = null, $options = array()) {
$tag = is_string($options['wrap']) ? $options['wrap'] : 'div';
unset($options['wrap']);
return $this->Html->tag($tag, $error, $options);
} else {
return $error;
}
return $error;
}

/**
Expand Down
9 changes: 3 additions & 6 deletions lib/Cake/View/Helper/HtmlHelper.php
Expand Up @@ -289,9 +289,8 @@ public function meta($type, $url = null, $options = array()) {

if (empty($options['block'])) {
return $out;
} else {
$this->_View->append($options['block'], $out);
}
$this->_View->append($options['block'], $out);
}

/**
Expand Down Expand Up @@ -451,9 +450,8 @@ public function css($path, $rel = null, $options = array()) {

if (empty($options['block'])) {
return $out;
} else {
$this->_View->append($options['block'], $out);
}
$this->_View->append($options['block'], $out);
}

/**
Expand Down Expand Up @@ -674,9 +672,8 @@ public function getCrumbs($separator = '»', $startText = false) {
}
}
return implode($separator, $out);
} else {
return null;
}
return null;
}

/**
Expand Down
42 changes: 21 additions & 21 deletions lib/Cake/basics.php
Expand Up @@ -478,30 +478,30 @@ function clearCache($params = null, $type = 'views', $ext = '.php') {
}
}
return true;
} else {
$cache = array(
CACHE . $type . DS . '*' . $params . $ext,
CACHE . $type . DS . '*' . $params . '_*' . $ext
);
$files = array();
while ($search = array_shift($cache)) {
$results = glob($search);
if ($results !== false) {
$files = array_merge($files, $results);
}
}
if (empty($files)) {
return false;
}
$cache = array(
CACHE . $type . DS . '*' . $params . $ext,
CACHE . $type . DS . '*' . $params . '_*' . $ext
);
$files = array();
while ($search = array_shift($cache)) {
$results = glob($search);
if ($results !== false) {
$files = array_merge($files, $results);
}
foreach ($files as $file) {
if (is_file($file) && strrpos($file, DS . 'empty') !== strlen($file) - 6) {
//@codingStandardsIgnoreStart
@unlink($file);
//@codingStandardsIgnoreEnd
}
}
if (empty($files)) {
return false;
}
foreach ($files as $file) {
if (is_file($file) && strrpos($file, DS . 'empty') !== strlen($file) - 6) {
//@codingStandardsIgnoreStart
@unlink($file);
//@codingStandardsIgnoreEnd
}
return true;
}
return true;

} elseif (is_array($params)) {
foreach ($params as $file) {
clearCache($file, $type, $ext);
Expand Down

0 comments on commit f389435

Please sign in to comment.