From 058a127a6a5e15f39def341e67a7cd6418882c34 Mon Sep 17 00:00:00 2001 From: Gabriel Caruso Date: Wed, 20 Dec 2017 14:50:39 -0200 Subject: [PATCH 1/2] Clean elses --- system/database/DB_forge.php | 6 ++---- system/database/DB_result.php | 8 +++----- system/libraries/Email.php | 12 ++++-------- system/libraries/Encryption.php | 6 ++---- system/libraries/Session/Session.php | 6 ++---- system/libraries/Upload.php | 6 ++---- system/libraries/Xmlrpcs.php | 18 ++++++------------ tests/mocks/ci_testcase.php | 6 ++---- 8 files changed, 23 insertions(+), 45 deletions(-) diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index 31fae43cfd6..dbf76fd13c8 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_forge.php @@ -382,10 +382,8 @@ protected function _create_table($table, $if_not_exists, $attributes) { return TRUE; } - else - { - $if_not_exists = FALSE; - } + + $if_not_exists = FALSE; } $sql = ($if_not_exists) diff --git a/system/database/DB_result.php b/system/database/DB_result.php index 98d8876a7ee..821a0ea07b9 100644 --- a/system/database/DB_result.php +++ b/system/database/DB_result.php @@ -163,10 +163,8 @@ public function result($type = 'object') { return $this->result_object(); } - else - { - return $this->custom_result_object($type); - } + + return $this->custom_result_object($type); } // -------------------------------------------------------------------- @@ -336,7 +334,7 @@ public function row($n = 0, $type = 'object') if ($type === 'object') return $this->row_object($n); elseif ($type === 'array') return $this->row_array($n); - else return $this->custom_row_object($n, $type); + return $this->custom_row_object($n, $type); } // -------------------------------------------------------------------- diff --git a/system/libraries/Email.php b/system/libraries/Email.php index f115d9f40a6..6d192a6e272 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -941,10 +941,8 @@ protected function _get_content_type() { return 'plain-attach'; } - else - { - return 'plain'; - } + + return 'plain'; } // -------------------------------------------------------------------- @@ -2209,10 +2207,8 @@ protected function _send_data($data) usleep(250000); continue; } - else - { - $timestamp = 0; - } + + $timestamp = 0; } if ($result === FALSE) diff --git a/system/libraries/Encryption.php b/system/libraries/Encryption.php index c3ddf60ed27..4f4f72057d4 100644 --- a/system/libraries/Encryption.php +++ b/system/libraries/Encryption.php @@ -682,10 +682,8 @@ protected function _get_params($params) { return FALSE; } - else - { - $params['mode'] = $this->_modes[$this->_driver][$params['mode']]; - } + + $params['mode'] = $this->_modes[$this->_driver][$params['mode']]; } if (isset($params['hmac']) && $params['hmac'] === FALSE) diff --git a/system/libraries/Session/Session.php b/system/libraries/Session/Session.php index 3e4865cd149..406b9a21987 100644 --- a/system/libraries/Session/Session.php +++ b/system/libraries/Session/Session.php @@ -222,10 +222,8 @@ protected function _ci_load_classes($driver) { return $prefix.$class; } - else - { - log_message('debug', 'Session: '.$prefix.$class.".php found but it doesn't declare class ".$prefix.$class.'.'); - } + + log_message('debug', 'Session: '.$prefix.$class.".php found but it doesn't declare class ".$prefix.$class.'.'); } return 'CI_'.$class; diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 9e838948034..c6771b584a2 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -678,10 +678,8 @@ public function set_filename($path, $filename) $this->set_error('upload_bad_filename', 'debug'); return FALSE; } - else - { - return $new_filename; - } + + return $new_filename; } // -------------------------------------------------------------------- diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index 0274f13b61c..7f760a0885d 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -402,15 +402,11 @@ protected function _execute($m) { return get_instance()->{$method_parts[1]}($m); } - else - { - return $this->object->{$method_parts[1]}($m); - } - } - else - { - return call_user_func($this->methods[$methName]['function'], $m); + + return $this->object->{$method_parts[1]}($m); } + + return call_user_func($this->methods[$methName]['function'], $m); } // -------------------------------------------------------------------- @@ -499,10 +495,8 @@ public function methodHelp($m) return new XML_RPC_Response(new XML_RPC_Values($docstring, 'string')); } - else - { - return new XML_RPC_Response(0, $this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']); - } + + return new XML_RPC_Response(0, $this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']); } // -------------------------------------------------------------------- diff --git a/tests/mocks/ci_testcase.php b/tests/mocks/ci_testcase.php index b320aab7425..593685c2367 100644 --- a/tests/mocks/ci_testcase.php +++ b/tests/mocks/ci_testcase.php @@ -377,10 +377,8 @@ public function __call($method, $args) { return call_user_func_array($this->{$method},$args); } - else - { - return parent::__call($method, $args); - } + + return parent::__call($method, $args); } } From 7774e3846c525ff65c6d9b86aacb1cc3bc229e3e Mon Sep 17 00:00:00 2001 From: Gabriel Caruso Date: Wed, 20 Dec 2017 17:53:55 -0200 Subject: [PATCH 2/2] Add extra line before return --- system/database/DB_result.php | 1 + 1 file changed, 1 insertion(+) diff --git a/system/database/DB_result.php b/system/database/DB_result.php index 821a0ea07b9..40b8fbb74ff 100644 --- a/system/database/DB_result.php +++ b/system/database/DB_result.php @@ -334,6 +334,7 @@ public function row($n = 0, $type = 'object') if ($type === 'object') return $this->row_object($n); elseif ($type === 'array') return $this->row_array($n); + return $this->custom_row_object($n, $type); }