Problem/Motivation
While working on upgrades to Drupal 10 Upgrade status provided these errors as needing to be resolved manually:
FILE: web/modules/contrib/smtp/src/Plugin/Mail/SMTPMailSystem.php
STATUS LINE MESSAGE
--------------------------------------------------------------------------------
Check manually 120 Parameter $mime_type_guesser of method
Drupal\smtp\Plugin\Mail\SMTPMailSystem::__construct() has
typehint with deprecated interface
Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuess
erInterface: since Symfony 4.3, use {@link
MimeTypesInterface} instead
--------------------------------------------------------------------------------
Steps to reproduce
Proposed resolution
Use \Symfony\Component\Mime\MimeTypeGuesserInterface in the docblock
Remaining tasks
Use MimeTypeGuesserInterface typehint for $mime_type_guesser constructor parameter
Comments
Comment #2
klimpComment #3
tr commentedIt seems that the type hint was deliberately chosen so that this code would work in D8, D9, and D10. Changing the type hint like you propose will break D8 compatibility. Update status is giving you a false positive in this case - it's not actually wrong.
(And, if you are going to change the type hint in the @param then the constructor argument should also be type hinted. Right now it is not, again to allow this code to work with D8, D9, and D10.)
See the commit at https://git.drupalcode.org/project/smtp/-/commit/a46b2f8a0d0a8e9cfcbeb85...
Unfortunately, there is no issue associated with that commit, so no explanation of what was being done and why. I personally think it's a mistake to add and keep D8-specific workaround in the current branch, as D8 has been end-of-life for almost two years now. If D8 compatibility is to be maintained in the 8.x-1.x branch, then I would suggest a new branch for D9+ should be opened going forward so that some of the D8 legacy code can be dropped.
Comment #4
japerrySince the SMTP module is fairly simple, my personal preference is to maintain backward compatibility, if possible, to ease the ability for sites to upgrade. However, with D9 EOL coming soon, the next release of SMTP will probably be the last that supports Drupal 8.
Comment #5
bluegeek9 commentedI understand this issue has not been updated is a couple years.
Drupal 8 is no longer supported.
$mime_type_guesser has the correct typehints.
@param \Symfony\Component\Mime\MimeTypeGuesserInterface $mime_type_guesser