Browse Source

Remove unneeded else.

Mark Scherer 10 years ago
parent
commit
4a9249fe23

+ 2 - 1
src/Console/ConsoleOptionParser.php

@@ -581,7 +581,8 @@ class ConsoleOptionParser
         while (($token = array_shift($this->_tokens)) !== null) {
             if (isset($this->_subcommands[$token])) {
                 continue;
-            } elseif (substr($token, 0, 2) === '--') {
+            }
+            if (substr($token, 0, 2) === '--') {
                 $params = $this->_parseLongOption($token, $params);
             } elseif (substr($token, 0, 1) === '-') {
                 $params = $this->_parseShortOption($token, $params);

+ 2 - 1
src/Database/Expression/CaseExpression.php

@@ -130,7 +130,8 @@ class CaseExpression implements ExpressionInterface
                 $value = $keyValues[$k];
                 array_push($this->_values, $value);
                 continue;
-            } elseif ($value instanceof ExpressionInterface) {
+            }
+            if ($value instanceof ExpressionInterface) {
                 array_push($this->_values, $value);
                 continue;
             }

+ 2 - 1
src/Database/Log/QueryLogger.php

@@ -63,7 +63,8 @@ class QueryLogger
         $params = array_map(function ($p) {
             if ($p === null) {
                 return 'NULL';
-            } elseif (is_bool($p)) {
+            }
+            if (is_bool($p)) {
                 return $p ? '1' : '0';
             }
             return is_string($p) ? "'$p'" : $p;

+ 2 - 1
src/Database/Type/FloatType.php

@@ -104,7 +104,8 @@ class FloatType extends Type
         }
         if (is_numeric($value)) {
             return (float)$value;
-        } elseif (is_string($value) && $this->_useLocaleParser) {
+        }
+        if (is_string($value) && $this->_useLocaleParser) {
             return $this->_parseValue($value);
         }
         if (is_array($value)) {

+ 4 - 2
src/Error/Debugger.php

@@ -323,9 +323,11 @@ class Debugger
 
         if (strpos($path, APP) === 0) {
             return str_replace(APP, 'APP/', $path);
-        } elseif (strpos($path, CAKE_CORE_INCLUDE_PATH) === 0) {
+        }
+        if (strpos($path, CAKE_CORE_INCLUDE_PATH) === 0) {
             return str_replace(CAKE_CORE_INCLUDE_PATH, 'CORE', $path);
-        } elseif (strpos($path, ROOT) === 0) {
+        }
+        if (strpos($path, ROOT) === 0) {
             return str_replace(ROOT, 'ROOT', $path);
         }
 

+ 2 - 1
src/Event/EventManager.php

@@ -312,7 +312,8 @@ class EventManager
         $events = (array)$subscriber->implementedEvents();
         if (!empty($eventKey) && empty($events[$eventKey])) {
             return;
-        } elseif (!empty($eventKey)) {
+        }
+        if (!empty($eventKey)) {
             $events = [$eventKey => $events[$eventKey]];
         }
         foreach ($events as $key => $function) {

+ 2 - 1
src/Filesystem/File.php

@@ -338,7 +338,8 @@ class File
         }
         if (isset($this->info['extension'])) {
             return basename($this->name, '.' . $this->info['extension']);
-        } elseif ($this->name) {
+        }
+        if ($this->name) {
             return $this->name;
         }
         return false;

+ 4 - 2
src/Network/Request.php

@@ -332,7 +332,8 @@ class Request implements ArrayAccess
     {
         if (!empty($_SERVER['PATH_INFO'])) {
             return $_SERVER['PATH_INFO'];
-        } elseif (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '://') === false) {
+        }
+        if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '://') === false) {
             $uri = $_SERVER['REQUEST_URI'];
         } elseif (isset($_SERVER['REQUEST_URI'])) {
             $qPosition = strpos($_SERVER['REQUEST_URI'], '?');
@@ -559,7 +560,8 @@ class Request implements ArrayAccess
                     $ref = '/' . $ref;
                 }
                 return $ref;
-            } elseif (!$local) {
+            }
+            if (!$local) {
                 return $ref;
             }
         }

+ 6 - 7
src/ORM/Association/HasMany.php

@@ -442,16 +442,15 @@ class HasMany extends Association
                     $ok = $ok && $target->delete($assoc, $options);
                 }
                 return $ok;
-            } else {
-                $target->deleteAll($conditions);
-                return true;
             }
-        } else {
-            $updateFields = array_fill_keys($foreignKey, null);
-            $target->updateAll($updateFields, $conditions);
-            return true;
 
+            $target->deleteAll($conditions);
+            return true;
         }
+
+        $updateFields = array_fill_keys($foreignKey, null);
+        $target->updateAll($updateFields, $conditions);
+        return true;
     }
 
     /**

+ 2 - 1
src/ORM/Behavior/TreeBehavior.php

@@ -911,7 +911,8 @@ class TreeBehavior extends Behavior
 
         if (is_array($config['scope'])) {
             return $query->where($config['scope']);
-        } elseif (is_callable($config['scope'])) {
+        }
+        if (is_callable($config['scope'])) {
             return $config['scope']($query);
         }
 

+ 2 - 1
src/Routing/Route/Route.php

@@ -499,7 +499,8 @@ class Route
             $numeric = is_numeric($key);
             if ($numeric && isset($defaults[$key]) && $defaults[$key] == $value) {
                 continue;
-            } elseif ($numeric) {
+            }
+            if ($numeric) {
                 $pass[] = $value;
                 unset($url[$key]);
                 continue;

+ 2 - 1
src/Routing/Router.php

@@ -571,7 +571,8 @@ class Router
                 $output = static::fullBaseUrl() . $output;
             }
             return $output;
-        } elseif (is_array($url)) {
+        }
+        if (is_array($url)) {
             if (isset($url['_full']) && $url['_full'] === true) {
                 $full = true;
                 unset($url['_full']);

+ 12 - 9
src/Shell/Task/ExtractTask.php

@@ -133,10 +133,12 @@ class ExtractTask extends Shell
                 $this->err('Extract Aborted');
                 $this->_stop();
                 return;
-            } elseif (strtoupper($response) === 'D' && count($this->_paths)) {
+            }
+            if (strtoupper($response) === 'D' && count($this->_paths)) {
                 $this->out();
                 return;
-            } elseif (strtoupper($response) === 'D') {
+            }
+            if (strtoupper($response) === 'D') {
                 $this->err('<warning>No directories selected.</warning> Please choose a directory.');
             } elseif (is_dir($response)) {
                 $this->_paths[] = $response;
@@ -205,16 +207,17 @@ class ExtractTask extends Shell
                     $this->err('Extract Aborted');
                     $this->_stop();
                     return;
-                } elseif ($this->_isPathUsable($response)) {
+                }
+                if ($this->_isPathUsable($response)) {
                     $this->_output = $response . DS;
                     break;
-                } else {
-                    $this->err('');
-                    $this->err(
-                        '<error>The directory path you supplied was ' .
-                        'not found. Please try again.</error>'
-                    );
                 }
+
+                $this->err('');
+                $this->err(
+                    '<error>The directory path you supplied was ' .
+                    'not found. Please try again.</error>'
+                );
                 $this->out();
             }
         }

+ 19 - 19
src/TestSuite/TestCase.php

@@ -398,27 +398,27 @@ abstract class TestCase extends PHPUnit_Framework_TestCase
                         $attrs[] = $matches[1];
                         $explanations[] = sprintf('Regex "%s" matches', $matches[1]);
                         continue;
+                    }
+
+                    $quotes = '["\']';
+                    if (is_numeric($attr)) {
+                        $attr = $val;
+                        $val = '.+?';
+                        $explanations[] = sprintf('Attribute "%s" present', $attr);
+                    } elseif (!empty($val) && preg_match('/^preg\:\/(.+)\/$/i', $val, $matches)) {
+                        $val = str_replace(
+                            ['.*', '.+'],
+                            ['.*?', '.+?'],
+                            $matches[1]
+                        );
+                        $quotes = $val !== $matches[1] ? '["\']' : '["\']?';
+
+                        $explanations[] = sprintf('Attribute "%s" matches "%s"', $attr, $val);
                     } else {
-                        $quotes = '["\']';
-                        if (is_numeric($attr)) {
-                            $attr = $val;
-                            $val = '.+?';
-                            $explanations[] = sprintf('Attribute "%s" present', $attr);
-                        } elseif (!empty($val) && preg_match('/^preg\:\/(.+)\/$/i', $val, $matches)) {
-                            $val = str_replace(
-                                ['.*', '.+'],
-                                ['.*?', '.+?'],
-                                $matches[1]
-                            );
-                            $quotes = $val !== $matches[1] ? '["\']' : '["\']?';
-
-                            $explanations[] = sprintf('Attribute "%s" matches "%s"', $attr, $val);
-                        } else {
-                            $explanations[] = sprintf('Attribute "%s" == "%s"', $attr, $val);
-                            $val = preg_quote($val, '/');
-                        }
-                        $attrs[] = '[\s]+' . preg_quote($attr, '/') . '=' . $quotes . $val . $quotes;
+                        $explanations[] = sprintf('Attribute "%s" == "%s"', $attr, $val);
+                        $val = preg_quote($val, '/');
                     }
+                    $attrs[] = '[\s]+' . preg_quote($attr, '/') . '=' . $quotes . $val . $quotes;
                     $i++;
                 }
                 if ($attrs) {

+ 3 - 3
src/Utility/Text.php

@@ -604,10 +604,10 @@ class Text
 
                     $truncate .= mb_substr($tag[3], 0, $left + $entitiesLength);
                     break;
-                } else {
-                    $truncate .= $tag[3];
-                    $totalLength += $contentLength;
                 }
+
+                $truncate .= $tag[3];
+                $totalLength += $contentLength;
                 if ($totalLength >= $length) {
                     break;
                 }

+ 2 - 1
src/View/Form/EntityContext.php

@@ -221,7 +221,8 @@ class EntityContext implements ContextInterface
 
         if ($entity instanceof EntityInterface) {
             return $entity->get(array_pop($parts));
-        } elseif (is_array($entity)) {
+        }
+        if (is_array($entity)) {
             $key = array_pop($parts);
             return isset($entity[$key]) ? $entity[$key] : null;
         }

+ 2 - 1
src/View/Helper/FormHelper.php

@@ -635,7 +635,8 @@ class FormHelper extends Helper
             if (!in_array($field, $this->fields)) {
                 if ($value !== null) {
                     return $this->fields[$field] = $value;
-                } elseif (isset($this->fields[$field]) && $value === null) {
+                }
+                if (isset($this->fields[$field]) && $value === null) {
                     unset($this->fields[$field]);
                 }
                 $this->fields[] = $field;

+ 2 - 1
src/View/Helper/RssHelper.php

@@ -218,7 +218,8 @@ class RssHelper extends Helper
                         }
                         $elements[$key] = implode('', $categories);
                         continue 2;
-                    } elseif (is_array($val) && isset($val['domain'])) {
+                    }
+                    if (is_array($val) && isset($val['domain'])) {
                         $attrib['domain'] = $val['domain'];
                     }
                     break;

+ 2 - 1
src/View/SerializedView.php

@@ -86,7 +86,8 @@ class SerializedView extends View
 
         if ($serialize !== false) {
             return $this->_serialize($serialize);
-        } elseif ($view !== false && $this->_getViewFileName($view)) {
+        }
+        if ($view !== false && $this->_getViewFileName($view)) {
             return parent::render($view, false);
         }
     }