Przeglądaj źródła

[HttpFoundation] fixed CS

Fabien Potencier 14 lat temu
rodzic
commit
a26de5ba58

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

@@ -491,7 +491,7 @@ class File
     public function getExtension()
     {
         if ($ext = pathinfo($this->getName(), PATHINFO_EXTENSION)) {
-            return '.' . $ext;
+            return '.'.$ext;
         }
 
         return '';
@@ -509,7 +509,7 @@ class File
         $type = $this->getMimeType();
 
         if (isset(self::$defaultExtensions[$type])) {
-            return '.' . self::$defaultExtensions[$type];
+            return '.'.self::$defaultExtensions[$type];
         }
 
         return $this->getExtension();
@@ -566,26 +566,6 @@ class File
         return $size;
     }
 
-    /**
-     * Moves the file to a new directory and gives it a new filename
-     *
-     * @param string $directory The new directory
-     * @param string $filename  The new file name
-     *
-     * @throws FileException When the file could not be moved
-     */
-    protected function doMove($directory, $filename)
-    {
-        $newPath = $directory . DIRECTORY_SEPARATOR . $filename;
-
-        if (!@rename($this->getPath(), $newPath)) {
-            $error = error_get_last();
-            throw new FileException(sprintf('Could not move file %s to %s (%s)', $this->getPath(), $newPath, strip_tags($error['message'])));
-        }
-
-        $this->path = realpath($newPath);
-    }
-
     /**
      * Moves the file to a new location.
      *
@@ -610,4 +590,24 @@ class File
     {
         $this->doMove($this->getDirectory(), $name);
     }
+
+    /**
+     * Moves the file to a new directory and gives it a new filename
+     *
+     * @param string $directory The new directory
+     * @param string $filename  The new file name
+     *
+     * @throws FileException When the file could not be moved
+     */
+    protected function doMove($directory, $filename)
+    {
+        $newPath = $directory.DIRECTORY_SEPARATOR.$filename;
+
+        if (!@rename($this->getPath(), $newPath)) {
+            $error = error_get_last();
+            throw new FileException(sprintf('Could not move file %s to %s (%s)', $this->getPath(), $newPath, strip_tags($error['message'])));
+        }
+
+        $this->path = realpath($newPath);
+    }
 }

+ 13 - 13
src/Symfony/Component/HttpFoundation/File/UploadedFile.php

@@ -172,35 +172,35 @@ class UploadedFile extends File
     /**
      * @inheritDoc
      */
-    protected function doMove($directory, $filename)
+    public function move($directory, $name = null)
     {
         if ($this->moved) {
-            return parent::doMove($directory, $filename);
+            return parent::move($directory, $name);
         }
 
-        $newPath = $directory . DIRECTORY_SEPARATOR . $filename;
+        $this->doMove($directory, $this->originalName);
 
-        if (!move_uploaded_file($this->getPath(), $newPath)) {
-            throw new FileException(sprintf('Could not move file %s to %s', $this->getPath(), $newPath));
+        if (null !== $name) {
+            $this->rename($name);
         }
-
-        $this->moved = true;
-        $this->path = realpath($newPath);
     }
 
     /**
      * @inheritDoc
      */
-    public function move($directory, $name = null)
+    protected function doMove($directory, $filename)
     {
         if ($this->moved) {
-            return parent::move($directory, $name);
+            return parent::doMove($directory, $filename);
         }
 
-        $this->doMove($directory, $this->originalName);
+        $newPath = $directory.DIRECTORY_SEPARATOR.$filename;
 
-        if (null !== $name) {
-            $this->rename($name);
+        if (!move_uploaded_file($this->getPath(), $newPath)) {
+            throw new FileException(sprintf('Could not move file %s to %s', $this->getPath(), $newPath));
         }
+
+        $this->moved = true;
+        $this->path = realpath($newPath);
     }
 }