Skip to content

Commit d7ee0ec

Browse files
committed
[HttpFoundation] updated File code
1 parent 5aa0967 commit d7ee0ec

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

src/Symfony/Component/HttpFoundation/File/File.php

+5-10
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,23 @@ public function __construct(string $path, bool $checkPath = true)
5555
*/
5656
public function guessExtension()
5757
{
58-
$type = $this->getMimeType();
59-
$guesser = ExtensionGuesser::getInstance();
60-
61-
return $guesser->guess($type);
58+
return ExtensionGuesser::getInstance()->guess($this->getMimeType());
6259
}
6360

6461
/**
6562
* Returns the mime type of the file.
6663
*
67-
* The mime type is guessed using a MimeTypeGuesser instance, which uses finfo(),
68-
* mime_content_type() and the system binary "file" (in this order), depending on
69-
* which of those are available.
64+
* The mime type is guessed using a MimeTypeGuesserInterface instance,
65+
* which uses finfo_file() then the "file" system binary,
66+
* depending on which of those are available.
7067
*
7168
* @return string|null The guessed mime type (e.g. "application/pdf")
7269
*
7370
* @see MimeTypeGuesser
7471
*/
7572
public function getMimeType()
7673
{
77-
$guesser = MimeTypeGuesser::getInstance();
78-
79-
return $guesser->guess($this->getPathname());
74+
return MimeTypeGuesser::getInstance()->guess($this->getPathname());
8075
}
8176

8277
/**

src/Symfony/Component/HttpFoundation/File/UploadedFile.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,7 @@ public function getClientMimeType()
140140
*/
141141
public function guessClientExtension()
142142
{
143-
$type = $this->getClientMimeType();
144-
$guesser = ExtensionGuesser::getInstance();
145-
146-
return $guesser->guess($type);
143+
return ExtensionGuesser::getInstance()->guess($this->getClientMimeType());
147144
}
148145

149146
/**

0 commit comments

Comments
 (0)