From 1e8cd6d34d879aafeccf29a5729c9af60e595b07 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 9 Jun 2011 12:42:42 +0200 Subject: [PATCH] [HttpFoundation] removed the leading . for extensions --- UPDATE.md | 3 +++ src/Symfony/Component/HttpFoundation/File/File.php | 8 ++++---- .../Component/HttpFoundation/File/UploadedFile.php | 2 +- .../Tests/Component/HttpFoundation/File/FileTest.php | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/UPDATE.md b/UPDATE.md index 34854e33ce..38ac238c91 100644 --- a/UPDATE.md +++ b/UPDATE.md @@ -9,6 +9,9 @@ timeline closely anyway. beta4 to beta5 -------------- +* The `Symfony\Component\HttpFoundation\File\File::getExtension()` and + `guessExtension()` methods do not return the extension with a `.` anymore. + * The `em` option of the Doctrine `EntityType` class now takes the entity manager name instead of the EntityManager instance. If you don't pass this option, the default Entity Manager will be used as before. diff --git a/src/Symfony/Component/HttpFoundation/File/File.php b/src/Symfony/Component/HttpFoundation/File/File.php index 09497a00f1..33bfcdd961 100644 --- a/src/Symfony/Component/HttpFoundation/File/File.php +++ b/src/Symfony/Component/HttpFoundation/File/File.php @@ -484,21 +484,21 @@ class File } /** - * Returns the file extension (with dot). + * Returns the file extension. * * @return string */ public function getExtension() { if ($ext = pathinfo($this->getName(), PATHINFO_EXTENSION)) { - return '.'.$ext; + return $ext; } return ''; } /** - * Returns the extension based on the mime type (with dot). + * Returns the extension based on the mime type. * * If the mime type is unknown, returns null. * @@ -509,7 +509,7 @@ class File $type = $this->getMimeType(); if (isset(self::$defaultExtensions[$type])) { - return '.'.self::$defaultExtensions[$type]; + return self::$defaultExtensions[$type]; } return null; diff --git a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php index 148827b38e..b463add604 100644 --- a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php +++ b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php @@ -116,7 +116,7 @@ class UploadedFile extends File } if ($ext = pathinfo($this->getOriginalName(), PATHINFO_EXTENSION)) { - return '.'.$ext; + return $ext; } return ''; diff --git a/tests/Symfony/Tests/Component/HttpFoundation/File/FileTest.php b/tests/Symfony/Tests/Component/HttpFoundation/File/FileTest.php index 67c2d842b3..21db21c0cc 100644 --- a/tests/Symfony/Tests/Component/HttpFoundation/File/FileTest.php +++ b/tests/Symfony/Tests/Component/HttpFoundation/File/FileTest.php @@ -47,7 +47,7 @@ class FileTest extends \PHPUnit_Framework_TestCase public function testGetExtensionReturnsExtensionWithDot() { - $this->assertEquals('.gif', $this->file->getExtension()); + $this->assertEquals('gif', $this->file->getExtension()); } public function testGetDirectoryReturnsDirectoryName() @@ -78,7 +78,7 @@ class FileTest extends \PHPUnit_Framework_TestCase MimeTypeGuesser::getInstance()->register($guesser); - $this->assertEquals('.gif', $file->guessExtension()); + $this->assertEquals('gif', $file->guessExtension()); } public function testConstructWhenFileNotExists()