Преглед на файлове

[HttpFoundation] Removed useless else

Pascal Borreli преди 14 години
родител
ревизия
fc42cc5066

+ 4 - 4
src/Symfony/Component/HttpFoundation/File/File.php

@@ -519,9 +519,9 @@ class File
     {
         if ($ext = pathinfo($this->getName(), \PATHINFO_EXTENSION)) {
             return '.' . $ext;
-        } else {
-            return '';
         }
+
+        return '';
     }
 
     /**
@@ -537,9 +537,9 @@ class File
 
         if (isset(self::$defaultExtensions[$type])) {
             return '.' . self::$defaultExtensions[$type];
-        } else {
-            return $this->getExtension();
         }
+
+        return $this->getExtension();
     }
 
     /**

+ 4 - 4
src/Symfony/Component/HttpFoundation/HeaderBag.php

@@ -96,16 +96,16 @@ class HeaderBag
         if (!array_key_exists($key, $this->headers)) {
             if (null === $default) {
                 return $first ? null : array();
-            } else {
-                return $first ? $default : array($default);
             }
+
+            return $first ? $default : array($default);
         }
 
         if ($first) {
             return count($this->headers[$key]) ? $this->headers[$key][0] : $default;
-        } else {
-            return $this->headers[$key];
         }
+
+        return $this->headers[$key];
     }
 
     /**

+ 2 - 2
src/Symfony/Component/HttpFoundation/Request.php

@@ -436,9 +436,9 @@ class Request
 
         if (('http' == $scheme && $port == 80) || ('https' == $scheme && $port == 443)) {
             return $name;
-        } else {
-            return $name.':'.$port;
         }
+
+        return $name.':'.$port;
     }
 
     public function getRequestUri()

+ 10 - 10
src/Symfony/Component/HttpFoundation/SessionStorage/PdoSessionStorage.php

@@ -171,18 +171,18 @@ class PdoSessionStorage extends NativeSessionStorage
 
             if (count($sessionRows) == 1) {
                 return $sessionRows[0][0];
-            } else {
-                // session does not exist, create it
-                $sql = 'INSERT INTO '.$db_table.'('.$db_id_col.', '.$db_data_col.', '.$db_time_col.') VALUES (?, ?, ?)';
+            }
 
-                $stmt = $this->db->prepare($sql);
-                $stmt->bindParam(1, $id, \PDO::PARAM_STR);
-                $stmt->bindValue(2, '', \PDO::PARAM_STR);
-                $stmt->bindValue(3, time(), \PDO::PARAM_INT);
-                $stmt->execute();
+            // session does not exist, create it
+            $sql = 'INSERT INTO '.$db_table.'('.$db_id_col.', '.$db_data_col.', '.$db_time_col.') VALUES (?, ?, ?)';
 
-                return '';
-            }
+            $stmt = $this->db->prepare($sql);
+            $stmt->bindParam(1, $id, \PDO::PARAM_STR);
+            $stmt->bindValue(2, '', \PDO::PARAM_STR);
+            $stmt->bindValue(3, time(), \PDO::PARAM_INT);
+            $stmt->execute();
+
+            return '';
         } catch (\PDOException $e) {
             throw new \RuntimeException(sprintf('PDOException was thrown when trying to manipulate session data: %s', $e->getMessage()), 0, $e);
         }