File tree 1 file changed +6
-15
lines changed
src/Symfony/Component/HttpFoundation/File/MimeType
1 file changed +6
-15
lines changed Original file line number Diff line number Diff line change @@ -80,13 +80,8 @@ public static function reset()
80
80
*/
81
81
private function __construct ()
82
82
{
83
- if (FileBinaryMimeTypeGuesser::isSupported ()) {
84
- $ this ->register (new FileBinaryMimeTypeGuesser ());
85
- }
86
-
87
- if (FileinfoMimeTypeGuesser::isSupported ()) {
88
- $ this ->register (new FileinfoMimeTypeGuesser ());
89
- }
83
+ $ this ->register (new FileBinaryMimeTypeGuesser ());
84
+ $ this ->register (new FileinfoMimeTypeGuesser ());
90
85
}
91
86
92
87
/**
@@ -125,18 +120,14 @@ public function guess($path)
125
120
throw new AccessDeniedException ($ path );
126
121
}
127
122
128
- if (!$ this ->guessers ) {
129
- $ msg = 'Unable to guess the mime type as no guessers are available ' ;
130
- if (!FileinfoMimeTypeGuesser::isSupported ()) {
131
- $ msg .= ' (Did you enable the php_fileinfo extension?) ' ;
132
- }
133
- throw new \LogicException ($ msg );
134
- }
135
-
136
123
foreach ($ this ->guessers as $ guesser ) {
137
124
if (null !== $ mimeType = $ guesser ->guess ($ path )) {
138
125
return $ mimeType ;
139
126
}
140
127
}
128
+
129
+ if (2 === \count ($ this ->guessers ) && !FileBinaryMimeTypeGuesser::isSupported () && !FileinfoMimeTypeGuesser::isSupported ()) {
130
+ throw new \LogicException ('Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?) ' );
131
+ }
141
132
}
142
133
}
You can’t perform that action at this time.
0 commit comments