guessMimeType declaration not compatible with Symfony interface

Created on 29 December 2020, over 3 years ago
Updated 5 June 2024, 3 months ago

Problem/Motivation

This issue I believe is after this update: https://git.drupalcode.org/project/drupal/commit/c8cc155#9013c0bcc39d0f1...

I ran into an issue after upgrading to Drupal 9.1.0, and attempting to run drush cr -y using PHP 7.3.9.

It also happens with drush st and probably all drush commands.

he issue is that two class methods updated in Drupal 9.1.0 are lacking the type hint string that the interface has in the declaration.

  • \Drupal\Core\ProxyClass\File\MimeType\ExtensionMimeTypeGuesser::guessMimeType($path)
  • \Drupal\Core\File\MimeType\MimeTypeGuesser::guessMimeType($path)

They should be updated to match the interface \Symfony\Component\Mime\MimeTypeGuesserInterface::guessMimeType(string $path): ?string

Without this running drush commands you get a PHP fatal error:

PHP Fatal error: Declaration of Drupal\Core\ProxyClass\File\MimeType\ExtensionMimeTypeGuesser::guessMimeType($path): string must be compatible with Symfony\Component\Mime\MimeTypeGuesserInterface::guessMimeType(string $path): ?string in /Users/nathanandersen/dev/mdb/web/core/lib/Drupal/Core/ProxyClass/File/MimeType/ExtensionMimeTypeGuesser.php on line 15

and

PHP Fatal error:  Declaration of Drupal\Core\File\MimeType\MimeTypeGuesser::guessMimeType($path): ?string must be compatible with Symfony\Component\Mime\MimeTypeGuesserInterface::guessMimeType(string $path): ?string in /Users/nathanandersen/dev/mdb/web/core/lib/Drupal/Core/File/MimeType/MimeTypeGuesser.php on line 14
 [warning] Drush command terminated abnormally.

Steps to reproduce

For me, it was updating to Drupal 9.1.0 using PHP 7.3.9.

The code was updated recently in 9.1.0: #3055193: [Symfony 5] The "Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser" class is deprecated since Symfony 4.3, use "Symfony\Component\Mime\MimeTypes" instead. β†’

Proposed resolution

add "string" declaration.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Closed: outdated

Version

11.0 πŸ”₯

Component
OtherΒ  β†’

Last updated about 7 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States oknate Greater New York City Area

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024