I am splitting of a side issue from #3055193: [Symfony 5] The "Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser" class is deprecated since Symfony 4.3, use "Symfony\Component\Mime\MimeTypes" instead.
There is a non-obvious aspect to Symfony 5 modernisation.
The APIs are starting to enforce parameter and return types. [ PHP7 concepts ]
In the main issue for example
When Drupal autogenerates new core/lib/Drupal/Core/ProxyClass/ classes.
Errors are being produced because the copied methods do no match the modern interface definition.
https://www.drupal.org/project/drupal/issues/3055193#comment-13537884
looking at
+ * {@inheritdoc}
+ */
+ public function getMimeTypes(string $ext) : array
+ {
+ return $this->lazyLoadItself()->getMimeTypes($ext);
+ }
The string type and array return type are important. For compatibility.
This issue
a) Augments the ProxyBuilder to copy over types if present.
b) Modifies the ProxyBuilderTest.
Comment | File | Size | Author |
---|---|---|---|
#6 | interdiff-3125234-5-6.txt | 1.81 KB | martin107 |
#6 | 3125234-6.patch | 2.27 KB | martin107 |
Comments
Comment #2
martin107 CreditAttribution: martin107 as a volunteer commentedHere is the patch.
Comment #3
martin107 CreditAttribution: martin107 as a volunteer commentedComment #5
martin107 CreditAttribution: martin107 as a volunteer commentedWow life on the bleeding edge of PHP
I was testing locally with php7.3.x
both
$reflection_method->getReturnType();
and
$parameter->getType()
trigger deprecation warnings in php 7.4
what is missing is an additional ->getName()
Comment #6
martin107 CreditAttribution: martin107 as a volunteer commentedAll credit to longwave during this review, for driving this change.
https://www.drupal.org/project/drupal/issues/3055193#comment-13544389
1) I have changed my position on this styling ...
I was going to for two spaces
but after looking at
a) the offical php code examples ( https://www.php.net/manual/en/functions.returning-values.php )
b) The Symfony convention.
for example
vendor/symfony/serializer/Normalizer/GetSetMethodNormalizer.php:
c) The Wordpress coding standard
They all favour the one space solution :-
This seems to disambiguate nicely in relation to this two space situation
Comment #7
longwaveReviewed in the other issue around return type coding style, I think this looks good now and can go in separately from that issue.
Comment #10
catchCommitted/pushed to 9.1.x/9.0.x, thanks!