Closed mvhirsch closed 9 months ago
When looking about getBox
usage, we always pass an array with all the key
array{
* width: int|null,
* height: int|null,
* quality: int,
* format: string,
* constraint: bool,
* resizer: string|null,
* resizer_options: array<string, string|bool|int|null>,
* }
So it seems natural require to supports those keys if you implement the interface.
You might decide to use different width/height based on the quality or the format for instance.
If the issue is about one call in your test, you should test your method in real condition, by adding.
'quality' => 80,
'format' => 'jpg',
'constraint' => true,
'resizer' => null,
'resizer_options' => [],
in your array.
It doesn't seems worth to change the signature of the interface for this.
Environment
sonata-project/media-bundle
^4.6PHP version
Subject
I've implemented my own Resizer. After writing a simple test, PHPStan now complains that my test code looks wrong:
ResizerInterface::getBox
declares$settings
to be aFormatOptions
(imported fromMediaProviderInterface
):https://github.com/sonata-project/SonataMediaBundle/blob/bc844058947e62c10f20edb3d94620e292582231/src/Resizer/ResizerInterface.php#L33-L38
https://github.com/sonata-project/SonataMediaBundle/blob/bc844058947e62c10f20edb3d94620e292582231/src/Provider/MediaProviderInterface.php#L27-L35
As far as I can tell, no implemented Resizer uses any other array keys than
width
andheight
.Minimal repository with the bug
Steps to reproduce
Expected results
No PHPStan errors reported.
Actual results