diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index ed64940d6..099df5d5c 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -195,17 +195,16 @@ class Mysql extends DboSource { if (!$result) { $result->closeCursor(); return array(); - } else { - $tables = array(); - - while ($line = $result->fetch(PDO::FETCH_NUM)) { - $tables[] = $line[0]; - } - - $result->closeCursor(); - parent::listSources($tables); - return $tables; } + $tables = array(); + + while ($line = $result->fetch(PDO::FETCH_NUM)) { + $tables[] = $line[0]; + } + + $result->closeCursor(); + parent::listSources($tables); + return $tables; } /** @@ -679,24 +678,23 @@ class Mysql extends DboSource { if (!$result) { $result->closeCursor(); return array(); - } else { - $tables = array(); - foreach ($result as $row) { - $tables[$row['Name']] = (array)$row; - unset($tables[$row['Name']]['queryString']); - if (!empty($row['Collation'])) { - $charset = $this->getCharsetName($row['Collation']); - if ($charset) { - $tables[$row['Name']]['charset'] = $charset; - } + } + $tables = array(); + foreach ($result as $row) { + $tables[$row['Name']] = (array)$row; + unset($tables[$row['Name']]['queryString']); + if (!empty($row['Collation'])) { + $charset = $this->getCharsetName($row['Collation']); + if ($charset) { + $tables[$row['Name']]['charset'] = $charset; } } - $result->closeCursor(); - if (is_string($name) && isset($tables[$name])) { - return $tables[$name]; - } - return $tables; } + $result->closeCursor(); + if (is_string($name) && isset($tables[$name])) { + return $tables[$name]; + } + return $tables; } /** diff --git a/lib/Cake/Model/Datasource/Database/Postgres.php b/lib/Cake/Model/Datasource/Database/Postgres.php index 1977a966f..743feb35e 100644 --- a/lib/Cake/Model/Datasource/Database/Postgres.php +++ b/lib/Cake/Model/Datasource/Database/Postgres.php @@ -300,9 +300,8 @@ class Postgres extends DboSource { } if (isset($this->_sequenceMap[$table][$field])) { return $this->_sequenceMap[$table][$field]; - } else { - return "{$table}_{$field}_seq"; } + return "{$table}_{$field}_seq"; } /** diff --git a/lib/Cake/Model/Datasource/Database/Sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php index 6d3e15fcd..eabcb0876 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlite.php +++ b/lib/Cake/Model/Datasource/Database/Sqlite.php @@ -362,10 +362,9 @@ class Sqlite extends DboSource { } } return $resultRow; - } else { - $this->_result->closeCursor(); - return false; } + $this->_result->closeCursor(); + return false; } /** diff --git a/lib/Cake/Model/Datasource/Database/Sqlserver.php b/lib/Cake/Model/Datasource/Database/Sqlserver.php index da3f4920e..e67038525 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlserver.php +++ b/lib/Cake/Model/Datasource/Database/Sqlserver.php @@ -167,17 +167,16 @@ class Sqlserver extends DboSource { if (!$result) { $result->closeCursor(); return array(); - } else { - $tables = array(); - - while ($line = $result->fetch(PDO::FETCH_NUM)) { - $tables[] = $line[0]; - } - - $result->closeCursor(); - parent::listSources($tables); - return $tables; } + $tables = array(); + + while ($line = $result->fetch(PDO::FETCH_NUM)) { + $tables[] = $line[0]; + } + + $result->closeCursor(); + parent::listSources($tables); + return $tables; } /** @@ -313,9 +312,8 @@ class Sqlserver extends DboSource { $result[] = $prepend . $fields[$i]; } return $result; - } else { - return $fields; } + return $fields; } /** @@ -534,9 +532,8 @@ class Sqlserver extends DboSource { "; } elseif (strpos($limit, 'FETCH') !== false) { return "SELECT {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order} {$limit}"; - } else { - return "SELECT {$limit} {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order}"; } + return "SELECT {$limit} {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order}"; case "schema": extract($data); diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index c82ec3bdf..db80a4fa4 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -592,25 +592,23 @@ class DboSource extends DataSource { $recursive = $params[5 + $off]; } return $args[2]->find('all', compact('conditions', 'fields', 'order', 'limit', 'page', 'recursive')); + } + if (isset($params[3 + $off])) { + $recursive = $params[3 + $off]; + } + return $args[2]->find('first', compact('conditions', 'fields', 'order', 'recursive')); + } + if (isset($args[1]) && $args[1] === true) { + return $this->fetchAll($args[0], true); + } elseif (isset($args[1]) && !is_array($args[1])) { + return $this->fetchAll($args[0], false); + } elseif (isset($args[1]) && is_array($args[1])) { + if (isset($args[2])) { + $cache = $args[2]; } else { - if (isset($params[3 + $off])) { - $recursive = $params[3 + $off]; - } - return $args[2]->find('first', compact('conditions', 'fields', 'order', 'recursive')); - } - } else { - if (isset($args[1]) && $args[1] === true) { - return $this->fetchAll($args[0], true); - } elseif (isset($args[1]) && !is_array($args[1])) { - return $this->fetchAll($args[0], false); - } elseif (isset($args[1]) && is_array($args[1])) { - if (isset($args[2])) { - $cache = $args[2]; - } else { - $cache = true; - } - return $this->fetchAll($args[0], $args[1], array('cache' => $cache)); + $cache = true; } + return $this->fetchAll($args[0], $args[1], array('cache' => $cache)); } } @@ -632,9 +630,8 @@ class DboSource extends DataSource { $this->fetchVirtualField($resultRow); } return $resultRow; - } else { - return null; } + return null; } /** diff --git a/lib/Cake/Model/Permission.php b/lib/Cake/Model/Permission.php index 61044445a..16572eb57 100644 --- a/lib/Cake/Model/Permission.php +++ b/lib/Cake/Model/Permission.php @@ -123,33 +123,32 @@ class Permission extends AppModel { if (empty($perms)) { continue; - } else { - $perms = Hash::extract($perms, '{n}.' . $this->alias); - foreach ($perms as $perm) { - if ($action === '*') { + } + $perms = Hash::extract($perms, '{n}.' . $this->alias); + foreach ($perms as $perm) { + if ($action === '*') { - foreach ($permKeys as $key) { - if (!empty($perm)) { - if ($perm[$key] == -1) { - return false; - } elseif ($perm[$key] == 1) { - $inherited[$key] = 1; - } + foreach ($permKeys as $key) { + if (!empty($perm)) { + if ($perm[$key] == -1) { + return false; + } elseif ($perm[$key] == 1) { + $inherited[$key] = 1; } } + } - if (count($inherited) === count($permKeys)) { + if (count($inherited) === count($permKeys)) { + return true; + } + } else { + switch ($perm['_' . $action]) { + case -1: + return false; + case 0: + continue; + case 1: return true; - } - } else { - switch ($perm['_' . $action]) { - case -1: - return false; - case 0: - continue; - case 1: - return true; - } } } } diff --git a/lib/Cake/Model/Validator/CakeValidationRule.php b/lib/Cake/Model/Validator/CakeValidationRule.php index d9df05f7b..1f8134fb7 100644 --- a/lib/Cake/Model/Validator/CakeValidationRule.php +++ b/lib/Cake/Model/Validator/CakeValidationRule.php @@ -148,9 +148,8 @@ class CakeValidationRule { if (in_array($this->required, array('create', 'update'), true)) { if ($this->required === 'create' && !$this->isUpdate() || $this->required === 'update' && $this->isUpdate()) { return true; - } else { - return false; } + return false; } return $this->required; diff --git a/lib/Cake/Network/CakeSocket.php b/lib/Cake/Network/CakeSocket.php index 231261187..43f5318c4 100644 --- a/lib/Cake/Network/CakeSocket.php +++ b/lib/Cake/Network/CakeSocket.php @@ -382,11 +382,10 @@ class CakeSocket { if ($enableCryptoResult === true) { $this->encrypted = $enable; return true; - } else { - $errorMessage = __d('cake_dev', 'Unable to perform enableCrypto operation on CakeSocket'); - $this->setLastError(null, $errorMessage); - throw new SocketException($errorMessage); } + $errorMessage = __d('cake_dev', 'Unable to perform enableCrypto operation on CakeSocket'); + $this->setLastError(null, $errorMessage); + throw new SocketException($errorMessage); } } diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index eb2f07fc2..2d729427e 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -1617,9 +1617,8 @@ class CakeEmail { $charset = strtoupper($this->charset); if (array_key_exists($charset, $this->_contentTypeCharset)) { return strtoupper($this->_contentTypeCharset[$charset]); - } else { - return strtoupper($this->charset); } + return strtoupper($this->charset); } } diff --git a/lib/Cake/Test/Case/Model/Behavior/AclBehaviorTest.php b/lib/Cake/Test/Case/Model/Behavior/AclBehaviorTest.php index 85234fa08..a971fb507 100644 --- a/lib/Cake/Test/Case/Model/Behavior/AclBehaviorTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/AclBehaviorTest.php @@ -87,9 +87,8 @@ class AclPerson extends CakeTestModel { } if (!$motherId) { return null; - } else { - return array('AclPerson' => array('id' => $motherId)); } + return array('AclPerson' => array('id' => $motherId)); } } diff --git a/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php b/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php index 1829e3911..57a390069 100644 --- a/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php @@ -3672,11 +3672,10 @@ class ContainableBehaviorTest extends CakeTestCase { if (!is_array($Model)) { $result = $Model->containments($contain); return $this->_containments($result['models']); - } else { - $result = $Model; - foreach ($result as $i => $containment) { - $result[$i] = array_diff_key($containment, array('instance' => true)); - } + } + $result = $Model; + foreach ($result as $i => $containment) { + $result[$i] = array_diff_key($containment, array('instance' => true)); } return $result; } diff --git a/lib/Cake/TestSuite/CakeTestSuiteCommand.php b/lib/Cake/TestSuite/CakeTestSuiteCommand.php index 5d919020f..ab8fca7c2 100644 --- a/lib/Cake/TestSuite/CakeTestSuiteCommand.php +++ b/lib/Cake/TestSuite/CakeTestSuiteCommand.php @@ -122,9 +122,8 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); } elseif (!isset($result) || $result->errorCount() > 0) { exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT); - } else { - exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT); } + exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT); } } diff --git a/lib/Cake/Utility/Folder.php b/lib/Cake/Utility/Folder.php index f50465b2e..ca6c4128d 100644 --- a/lib/Cake/Utility/Folder.php +++ b/lib/Cake/Utility/Folder.php @@ -516,11 +516,10 @@ class Folder { umask($old); $this->_messages[] = __d('cake_dev', '%s created', $pathname); return true; - } else { - umask($old); - $this->_errors[] = __d('cake_dev', '%s NOT created', $pathname); - return false; } + umask($old); + $this->_errors[] = __d('cake_dev', '%s NOT created', $pathname); + return false; } } return false; @@ -810,9 +809,8 @@ class Folder { if (!empty($newparts)) { array_pop($newparts); continue; - } else { - return false; } + return false; } $newparts[] = $part; } diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index e60acd16d..322527040 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -816,9 +816,8 @@ class Validation { protected static function _check($check, $regex) { if (is_string($regex) && preg_match($regex, $check)) { return true; - } else { - return false; } + return false; } /** diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index a97c85217..cea2ea1f1 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -205,9 +205,8 @@ class FormHelper extends AppHelper { return $this->fieldset[$model]['fields']; } elseif (isset($this->fieldset[$model]['fields'][$field])) { return $this->fieldset[$model]['fields'][$field]; - } else { - return isset($object->hasAndBelongsToMany[$field]) ? array('type' => 'multiple') : null; } + return isset($object->hasAndBelongsToMany[$field]) ? array('type' => 'multiple') : null; } if ($key === 'errors' && !isset($this->validationErrors[$model])) { @@ -232,10 +231,9 @@ class FormHelper extends AppHelper { if ($key === 'validates') { if (empty($field)) { return $this->fieldset[$model]['validates']; - } else { - return isset($this->fieldset[$model]['validates'][$field]) ? - $this->fieldset[$model]['validates'] : null; } + return isset($this->fieldset[$model]['validates'][$field]) ? + $this->fieldset[$model]['validates'] : null; } } @@ -2572,9 +2570,8 @@ class FormHelper extends AppHelper { if (is_array($options)) { $options[$key] = $name; return $options; - } else { - return $name; } + return $name; } return parent::_name($options, $field, $key); } diff --git a/lib/Cake/View/Helper/PaginatorHelper.php b/lib/Cake/View/Helper/PaginatorHelper.php index 7357abe15..61c5622fc 100644 --- a/lib/Cake/View/Helper/PaginatorHelper.php +++ b/lib/Cake/View/Helper/PaginatorHelper.php @@ -491,22 +491,21 @@ class PaginatorHelper extends AppHelper { } $link = $this->link($title, $url, compact('escape', 'model') + $options); return $this->Html->tag($tag, $link, compact('class')); - } else { - unset($options['rel']); - if (!$tag) { - if ($disabledTag) { - $tag = $disabledTag; - $disabledTag = null; - } else { - $tag = $_defaults['tag']; - } - } - if ($disabledTag) { - $title = $this->Html->tag($disabledTag, $title, compact('escape') + $options); - return $this->Html->tag($tag, $title, compact('class')); - } - return $this->Html->tag($tag, $title, compact('escape', 'class') + $options); } + unset($options['rel']); + if (!$tag) { + if ($disabledTag) { + $tag = $disabledTag; + $disabledTag = null; + } else { + $tag = $_defaults['tag']; + } + } + if ($disabledTag) { + $title = $this->Html->tag($disabledTag, $title, compact('escape') + $options); + return $this->Html->tag($tag, $title, compact('class')); + } + return $this->Html->tag($tag, $title, compact('escape', 'class') + $options); } /** diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index e5234d44e..962d8168f 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -564,9 +564,8 @@ class View extends Object { //@codingStandardsIgnoreEnd unset($out); return false; - } else { - return substr($out, strlen($match[0])); } + return substr($out, strlen($match[0])); } }