Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Symfony/Component/HttpFoundation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ CHANGELOG
`__construct()` instead)
* added `Request::preferSafeContent()` and `Response::setContentSafe()` to handle "safe" HTTP preference
according to [RFC 8674](https://tools.ietf.org/html/rfc8674)
* made the Mime component an optional dependency

5.0.0
-----
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/HttpFoundation/File/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ public function __construct(string $path, bool $checkPath = true)
*/
public function guessExtension()
{
if (!class_exists(MimeTypes::class)) {
throw new \LogicException('You cannot guess the extension as the Mime component is not installed. Try running "composer require symfony/mime".');
}

return MimeTypes::getDefault()->getExtensions($this->getMimeType())[0] ?? null;
}

Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/HttpFoundation/File/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ public function getClientMimeType()
*/
public function guessClientExtension()
{
if (!class_exists(MimeTypes::class)) {
throw new \LogicException('You cannot guess the extension as the Mime component is not installed. Try running "composer require symfony/mime".');
}

return MimeTypes::getDefault()->getExtensions($this->getClientMimeType())[0] ?? null;
}

Expand Down
5 changes: 4 additions & 1 deletion src/Symfony/Component/HttpFoundation/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
],
"require": {
"php": "^7.2.5",
"symfony/mime": "^4.4|^5.0",
"symfony/polyfill-mbstring": "~1.1"
},
"require-dev": {
"predis/predis": "~1.0",
"symfony/mime": "^4.4|^5.0",
"symfony/expression-language": "^4.4|^5.0"
},
"suggest" : {
"symfony/mime": "To use the file extension guesser"
},
"autoload": {
"psr-4": { "Symfony\\Component\\HttpFoundation\\": "" },
"exclude-from-classmap": [
Expand Down