1 | <?php |
||
15 | class ImageTransformer |
||
16 | { |
||
17 | use Utils\BasePathTrait; |
||
18 | use Utils\StorageTrait; |
||
19 | |||
20 | protected $sizes; |
||
21 | |||
22 | /** |
||
23 | * Define the available sizes, for example: |
||
24 | * [ |
||
25 | * 'small' => 'resizeCrop,50,50', |
||
26 | * 'medium' => 'resize,500', |
||
27 | * 'big' => 'resize,1000', |
||
28 | * ]. |
||
29 | * |
||
30 | * @param array $sizes |
||
31 | * |
||
32 | * @return self |
||
33 | */ |
||
34 | public function sizes(array $sizes) |
||
38 | |||
39 | /** |
||
40 | * Execute the middleware. |
||
41 | * |
||
42 | * @param RequestInterface $request |
||
43 | * @param ResponseInterface $response |
||
44 | * @param callable $next |
||
45 | * |
||
46 | * @return ResponseInterface |
||
47 | */ |
||
48 | public function __invoke(RequestInterface $request, ResponseInterface $response, callable $next) |
||
70 | |||
71 | /** |
||
72 | * Transform the image. |
||
73 | * |
||
74 | * @param string $file |
||
75 | * @param string $transform |
||
76 | * @param ResponseInterface $response |
||
77 | * |
||
78 | * @return ResponseInterface |
||
79 | */ |
||
80 | private function transform($file, $transform, ResponseInterface $response) |
||
106 | |||
107 | /** |
||
108 | * Parses the path and return the file and transform values. |
||
109 | * |
||
110 | * @param string $path |
||
111 | * |
||
112 | * @return null|array [file, transform] |
||
113 | */ |
||
114 | private function parsePath($path) |
||
126 | } |
||
127 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.