mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
simplify else cases
This commit is contained in:
parent
7cb19b97db
commit
a90cb29c0f
17 changed files with 109 additions and 134 deletions
|
@ -195,7 +195,7 @@ class Mysql extends DboSource {
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
$result->closeCursor();
|
$result->closeCursor();
|
||||||
return array();
|
return array();
|
||||||
} else {
|
}
|
||||||
$tables = array();
|
$tables = array();
|
||||||
|
|
||||||
while ($line = $result->fetch(PDO::FETCH_NUM)) {
|
while ($line = $result->fetch(PDO::FETCH_NUM)) {
|
||||||
|
@ -206,7 +206,6 @@ class Mysql extends DboSource {
|
||||||
parent::listSources($tables);
|
parent::listSources($tables);
|
||||||
return $tables;
|
return $tables;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a map of the columns contained in a result
|
* Builds a map of the columns contained in a result
|
||||||
|
@ -679,7 +678,7 @@ class Mysql extends DboSource {
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
$result->closeCursor();
|
$result->closeCursor();
|
||||||
return array();
|
return array();
|
||||||
} else {
|
}
|
||||||
$tables = array();
|
$tables = array();
|
||||||
foreach ($result as $row) {
|
foreach ($result as $row) {
|
||||||
$tables[$row['Name']] = (array)$row;
|
$tables[$row['Name']] = (array)$row;
|
||||||
|
@ -697,7 +696,6 @@ class Mysql extends DboSource {
|
||||||
}
|
}
|
||||||
return $tables;
|
return $tables;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts database-layer column types to basic types
|
* Converts database-layer column types to basic types
|
||||||
|
|
|
@ -300,9 +300,8 @@ class Postgres extends DboSource {
|
||||||
}
|
}
|
||||||
if (isset($this->_sequenceMap[$table][$field])) {
|
if (isset($this->_sequenceMap[$table][$field])) {
|
||||||
return $this->_sequenceMap[$table][$field];
|
return $this->_sequenceMap[$table][$field];
|
||||||
} else {
|
|
||||||
return "{$table}_{$field}_seq";
|
|
||||||
}
|
}
|
||||||
|
return "{$table}_{$field}_seq";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -362,11 +362,10 @@ class Sqlite extends DboSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $resultRow;
|
return $resultRow;
|
||||||
} else {
|
}
|
||||||
$this->_result->closeCursor();
|
$this->_result->closeCursor();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a limit statement in the correct format for the particular database.
|
* Returns a limit statement in the correct format for the particular database.
|
||||||
|
|
|
@ -167,7 +167,7 @@ class Sqlserver extends DboSource {
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
$result->closeCursor();
|
$result->closeCursor();
|
||||||
return array();
|
return array();
|
||||||
} else {
|
}
|
||||||
$tables = array();
|
$tables = array();
|
||||||
|
|
||||||
while ($line = $result->fetch(PDO::FETCH_NUM)) {
|
while ($line = $result->fetch(PDO::FETCH_NUM)) {
|
||||||
|
@ -178,7 +178,6 @@ class Sqlserver extends DboSource {
|
||||||
parent::listSources($tables);
|
parent::listSources($tables);
|
||||||
return $tables;
|
return $tables;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of the fields in given table name.
|
* Returns an array of the fields in given table name.
|
||||||
|
@ -313,9 +312,8 @@ class Sqlserver extends DboSource {
|
||||||
$result[] = $prepend . $fields[$i];
|
$result[] = $prepend . $fields[$i];
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
} else {
|
|
||||||
return $fields;
|
|
||||||
}
|
}
|
||||||
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -534,9 +532,8 @@ class Sqlserver extends DboSource {
|
||||||
";
|
";
|
||||||
} elseif (strpos($limit, 'FETCH') !== false) {
|
} elseif (strpos($limit, 'FETCH') !== false) {
|
||||||
return "SELECT {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order} {$limit}";
|
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":
|
case "schema":
|
||||||
extract($data);
|
extract($data);
|
||||||
|
|
||||||
|
|
|
@ -592,13 +592,12 @@ class DboSource extends DataSource {
|
||||||
$recursive = $params[5 + $off];
|
$recursive = $params[5 + $off];
|
||||||
}
|
}
|
||||||
return $args[2]->find('all', compact('conditions', 'fields', 'order', 'limit', 'page', 'recursive'));
|
return $args[2]->find('all', compact('conditions', 'fields', 'order', 'limit', 'page', 'recursive'));
|
||||||
} else {
|
}
|
||||||
if (isset($params[3 + $off])) {
|
if (isset($params[3 + $off])) {
|
||||||
$recursive = $params[3 + $off];
|
$recursive = $params[3 + $off];
|
||||||
}
|
}
|
||||||
return $args[2]->find('first', compact('conditions', 'fields', 'order', 'recursive'));
|
return $args[2]->find('first', compact('conditions', 'fields', 'order', 'recursive'));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (isset($args[1]) && $args[1] === true) {
|
if (isset($args[1]) && $args[1] === true) {
|
||||||
return $this->fetchAll($args[0], true);
|
return $this->fetchAll($args[0], true);
|
||||||
} elseif (isset($args[1]) && !is_array($args[1])) {
|
} elseif (isset($args[1]) && !is_array($args[1])) {
|
||||||
|
@ -612,7 +611,6 @@ class DboSource extends DataSource {
|
||||||
return $this->fetchAll($args[0], $args[1], array('cache' => $cache));
|
return $this->fetchAll($args[0], $args[1], array('cache' => $cache));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a row from current resultset as an array
|
* Returns a row from current resultset as an array
|
||||||
|
@ -632,9 +630,8 @@ class DboSource extends DataSource {
|
||||||
$this->fetchVirtualField($resultRow);
|
$this->fetchVirtualField($resultRow);
|
||||||
}
|
}
|
||||||
return $resultRow;
|
return $resultRow;
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -123,7 +123,7 @@ class Permission extends AppModel {
|
||||||
|
|
||||||
if (empty($perms)) {
|
if (empty($perms)) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
}
|
||||||
$perms = Hash::extract($perms, '{n}.' . $this->alias);
|
$perms = Hash::extract($perms, '{n}.' . $this->alias);
|
||||||
foreach ($perms as $perm) {
|
foreach ($perms as $perm) {
|
||||||
if ($action === '*') {
|
if ($action === '*') {
|
||||||
|
@ -153,7 +153,6 @@ class Permission extends AppModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,9 +148,8 @@ class CakeValidationRule {
|
||||||
if (in_array($this->required, array('create', 'update'), true)) {
|
if (in_array($this->required, array('create', 'update'), true)) {
|
||||||
if ($this->required === 'create' && !$this->isUpdate() || $this->required === 'update' && $this->isUpdate()) {
|
if ($this->required === 'create' && !$this->isUpdate() || $this->required === 'update' && $this->isUpdate()) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->required;
|
return $this->required;
|
||||||
|
|
|
@ -382,11 +382,10 @@ class CakeSocket {
|
||||||
if ($enableCryptoResult === true) {
|
if ($enableCryptoResult === true) {
|
||||||
$this->encrypted = $enable;
|
$this->encrypted = $enable;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
$errorMessage = __d('cake_dev', 'Unable to perform enableCrypto operation on CakeSocket');
|
$errorMessage = __d('cake_dev', 'Unable to perform enableCrypto operation on CakeSocket');
|
||||||
$this->setLastError(null, $errorMessage);
|
$this->setLastError(null, $errorMessage);
|
||||||
throw new SocketException($errorMessage);
|
throw new SocketException($errorMessage);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1617,9 +1617,8 @@ class CakeEmail {
|
||||||
$charset = strtoupper($this->charset);
|
$charset = strtoupper($this->charset);
|
||||||
if (array_key_exists($charset, $this->_contentTypeCharset)) {
|
if (array_key_exists($charset, $this->_contentTypeCharset)) {
|
||||||
return strtoupper($this->_contentTypeCharset[$charset]);
|
return strtoupper($this->_contentTypeCharset[$charset]);
|
||||||
} else {
|
|
||||||
return strtoupper($this->charset);
|
|
||||||
}
|
}
|
||||||
|
return strtoupper($this->charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,9 +87,8 @@ class AclPerson extends CakeTestModel {
|
||||||
}
|
}
|
||||||
if (!$motherId) {
|
if (!$motherId) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
|
||||||
return array('AclPerson' => array('id' => $motherId));
|
|
||||||
}
|
}
|
||||||
|
return array('AclPerson' => array('id' => $motherId));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3672,12 +3672,11 @@ class ContainableBehaviorTest extends CakeTestCase {
|
||||||
if (!is_array($Model)) {
|
if (!is_array($Model)) {
|
||||||
$result = $Model->containments($contain);
|
$result = $Model->containments($contain);
|
||||||
return $this->_containments($result['models']);
|
return $this->_containments($result['models']);
|
||||||
} else {
|
}
|
||||||
$result = $Model;
|
$result = $Model;
|
||||||
foreach ($result as $i => $containment) {
|
foreach ($result as $i => $containment) {
|
||||||
$result[$i] = array_diff_key($containment, array('instance' => true));
|
$result[$i] = array_diff_key($containment, array('instance' => true));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,9 +122,8 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command {
|
||||||
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
|
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
|
||||||
} elseif (!isset($result) || $result->errorCount() > 0) {
|
} elseif (!isset($result) || $result->errorCount() > 0) {
|
||||||
exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
|
exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
|
||||||
} else {
|
|
||||||
exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
|
|
||||||
}
|
}
|
||||||
|
exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -516,13 +516,12 @@ class Folder {
|
||||||
umask($old);
|
umask($old);
|
||||||
$this->_messages[] = __d('cake_dev', '%s created', $pathname);
|
$this->_messages[] = __d('cake_dev', '%s created', $pathname);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
umask($old);
|
umask($old);
|
||||||
$this->_errors[] = __d('cake_dev', '%s NOT created', $pathname);
|
$this->_errors[] = __d('cake_dev', '%s NOT created', $pathname);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -810,9 +809,8 @@ class Folder {
|
||||||
if (!empty($newparts)) {
|
if (!empty($newparts)) {
|
||||||
array_pop($newparts);
|
array_pop($newparts);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
$newparts[] = $part;
|
$newparts[] = $part;
|
||||||
}
|
}
|
||||||
|
|
|
@ -816,9 +816,8 @@ class Validation {
|
||||||
protected static function _check($check, $regex) {
|
protected static function _check($check, $regex) {
|
||||||
if (is_string($regex) && preg_match($regex, $check)) {
|
if (is_string($regex) && preg_match($regex, $check)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -205,9 +205,8 @@ class FormHelper extends AppHelper {
|
||||||
return $this->fieldset[$model]['fields'];
|
return $this->fieldset[$model]['fields'];
|
||||||
} elseif (isset($this->fieldset[$model]['fields'][$field])) {
|
} elseif (isset($this->fieldset[$model]['fields'][$field])) {
|
||||||
return $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])) {
|
if ($key === 'errors' && !isset($this->validationErrors[$model])) {
|
||||||
|
@ -232,12 +231,11 @@ class FormHelper extends AppHelper {
|
||||||
if ($key === 'validates') {
|
if ($key === 'validates') {
|
||||||
if (empty($field)) {
|
if (empty($field)) {
|
||||||
return $this->fieldset[$model]['validates'];
|
return $this->fieldset[$model]['validates'];
|
||||||
} else {
|
}
|
||||||
return isset($this->fieldset[$model]['validates'][$field]) ?
|
return isset($this->fieldset[$model]['validates'][$field]) ?
|
||||||
$this->fieldset[$model]['validates'] : null;
|
$this->fieldset[$model]['validates'] : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if a field is required to be filled based on validation properties from the validating object.
|
* Returns if a field is required to be filled based on validation properties from the validating object.
|
||||||
|
@ -2572,9 +2570,8 @@ class FormHelper extends AppHelper {
|
||||||
if (is_array($options)) {
|
if (is_array($options)) {
|
||||||
$options[$key] = $name;
|
$options[$key] = $name;
|
||||||
return $options;
|
return $options;
|
||||||
} else {
|
|
||||||
return $name;
|
|
||||||
}
|
}
|
||||||
|
return $name;
|
||||||
}
|
}
|
||||||
return parent::_name($options, $field, $key);
|
return parent::_name($options, $field, $key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -491,7 +491,7 @@ class PaginatorHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
$link = $this->link($title, $url, compact('escape', 'model') + $options);
|
$link = $this->link($title, $url, compact('escape', 'model') + $options);
|
||||||
return $this->Html->tag($tag, $link, compact('class'));
|
return $this->Html->tag($tag, $link, compact('class'));
|
||||||
} else {
|
}
|
||||||
unset($options['rel']);
|
unset($options['rel']);
|
||||||
if (!$tag) {
|
if (!$tag) {
|
||||||
if ($disabledTag) {
|
if ($disabledTag) {
|
||||||
|
@ -507,7 +507,6 @@ class PaginatorHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
return $this->Html->tag($tag, $title, compact('escape', 'class') + $options);
|
return $this->Html->tag($tag, $title, compact('escape', 'class') + $options);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the given result set is not at the first page
|
* Returns true if the given result set is not at the first page
|
||||||
|
|
|
@ -564,9 +564,8 @@ class View extends Object {
|
||||||
//@codingStandardsIgnoreEnd
|
//@codingStandardsIgnoreEnd
|
||||||
unset($out);
|
unset($out);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
return substr($out, strlen($match[0]));
|
|
||||||
}
|
}
|
||||||
|
return substr($out, strlen($match[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue