Skip to content

Commit

Permalink
bug #29975 [Mime] fix adding extensions when creating a MimeTypes ins…
Browse files Browse the repository at this point in the history
…tance (nicolas-grekas)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[Mime] fix adding extensions when creating a MimeTypes instance

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

6c7d034 [Mime] fix adding extensions when creating a MimeTypes instance
  • Loading branch information
nicolas-grekas committed Jan 25, 2019
2 parents 8edddfa + 6c7d034 commit 0901bbe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Symfony/Component/Mime/MimeTypes.php
Expand Up @@ -34,13 +34,14 @@
*/
final class MimeTypes implements MimeTypesInterface
{
private $extensions = [];
private $guessers = [];
private static $default;

public function __construct(array $map = [])
{
foreach ($map as $mimeType => $extensions) {
self::$extensions[$mimeType] = $extensions;
$this->extensions[$mimeType] = $extensions;
}
$this->registerGuesser(new FileBinaryMimeTypeGuesser());
$this->registerGuesser(new FileinfoMimeTypeGuesser());
Expand Down Expand Up @@ -71,7 +72,7 @@ public function registerGuesser(MimeTypeGuesserInterface $guesser)
*/
public function getExtensions(string $mimeType): array
{
return self::$map[$mimeType] ?? [];
return $this->extensions[$mimeType] ?? self::$map[$mimeType] ?? [];
}

/**
Expand Down

0 comments on commit 0901bbe

Please sign in to comment.