8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 44395ab commit 6c7b026Copy full SHA for 6c7b026
src/Symfony/Component/Mime/FileinfoMimeTypeGuesser.php
@@ -21,6 +21,8 @@
21
*/
22
class FileinfoMimeTypeGuesser implements MimeTypeGuesserInterface
23
{
24
+ private static $finfoCache = [];
25
+
26
/**
27
* @param string|null $magicFile A magic file to use with the finfo instance
28
*
@@ -46,7 +48,7 @@ public function guessMimeType(string $path): ?string
46
48
throw new LogicException(\sprintf('The "%s" guesser is not supported.', __CLASS__));
47
49
}
50
- if (false === $finfo = new \finfo(\FILEINFO_MIME_TYPE, $this->magicFile)) {
51
+ if (false === $finfo = self::$finfoCache[$this->magicFile] ??= new \finfo(\FILEINFO_MIME_TYPE, $this->magicFile)) {
52
return null;
53
54
$mimeType = $finfo->file($path);
0 commit comments