[HttpFoundation] updated File code

This commit is contained in:
Fabien Potencier 2019-01-15 08:33:14 +01:00
parent 5aa0967f9f
commit d7ee0ecc49
2 changed files with 6 additions and 14 deletions

View File

@ -55,18 +55,15 @@ class File extends \SplFileInfo
*/
public function guessExtension()
{
$type = $this->getMimeType();
$guesser = ExtensionGuesser::getInstance();
return $guesser->guess($type);
return ExtensionGuesser::getInstance()->guess($this->getMimeType());
}
/**
* Returns the mime type of the file.
*
* The mime type is guessed using a MimeTypeGuesser instance, which uses finfo(),
* mime_content_type() and the system binary "file" (in this order), depending on
* which of those are available.
* The mime type is guessed using a MimeTypeGuesserInterface instance,
* which uses finfo_file() then the "file" system binary,
* depending on which of those are available.
*
* @return string|null The guessed mime type (e.g. "application/pdf")
*
@ -74,9 +71,7 @@ class File extends \SplFileInfo
*/
public function getMimeType()
{
$guesser = MimeTypeGuesser::getInstance();
return $guesser->guess($this->getPathname());
return MimeTypeGuesser::getInstance()->guess($this->getPathname());
}
/**

View File

@ -140,10 +140,7 @@ class UploadedFile extends File
*/
public function guessClientExtension()
{
$type = $this->getClientMimeType();
$guesser = ExtensionGuesser::getInstance();
return $guesser->guess($type);
return ExtensionGuesser::getInstance()->guess($this->getClientMimeType());
}
/**