1 | <?php |
||
19 | class ResponsiveFactory |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * The image driver to use. |
||
24 | * Available drivers: 'gd' and 'imagick'. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $driver; |
||
29 | |||
30 | /** |
||
31 | * The source path to load images from. |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $sourcePath; |
||
36 | |||
37 | /** |
||
38 | * The public path to save rendered images. |
||
39 | * |
||
40 | * @var string |
||
41 | */ |
||
42 | protected $publicPath; |
||
43 | |||
44 | /** |
||
45 | * Enabled cache will stop generated images from being overwritten. |
||
46 | * |
||
47 | * @var bool |
||
48 | */ |
||
49 | private $enableCache; |
||
50 | |||
51 | /** |
||
52 | * Enable optimizers will run several image optimizers on the saved files. |
||
53 | * |
||
54 | * @var bool |
||
55 | */ |
||
56 | private $optimize; |
||
57 | |||
58 | /** |
||
59 | * @var bool |
||
60 | */ |
||
61 | private $async; |
||
62 | |||
63 | /** |
||
64 | * The Intervention image engine. |
||
65 | * |
||
66 | * @var ImageManager |
||
67 | */ |
||
68 | protected $engine; |
||
69 | |||
70 | /** |
||
71 | * @var Filesystem |
||
72 | */ |
||
73 | protected $fs; |
||
74 | |||
75 | /** |
||
76 | * @var Scaler |
||
77 | */ |
||
78 | protected $scaler; |
||
79 | |||
80 | /** |
||
81 | * @var Optimizer |
||
82 | */ |
||
83 | protected $optimizer; |
||
84 | |||
85 | /** |
||
86 | * @var Promise[] |
||
87 | */ |
||
88 | protected $promises; |
||
89 | |||
90 | /** |
||
91 | * ResponsiveFactory constructor. |
||
92 | * |
||
93 | * @param ResponsiveFactoryConfigurator $configurator |
||
94 | */ |
||
95 | public function __construct(ResponsiveFactoryConfigurator $configurator = null) { |
||
112 | |||
113 | /** |
||
114 | * @param string $src |
||
115 | * |
||
116 | * @return ResponsiveImage |
||
117 | * @throws FileNotFoundException |
||
118 | */ |
||
119 | public function create($src) { |
||
170 | |||
171 | /** |
||
172 | * Create scaled image files and add them as sources to a Responsive Image, based on an array of file sizes: |
||
173 | * [ |
||
174 | * width => height, |
||
175 | * ... |
||
176 | * ] |
||
177 | * |
||
178 | * @param array $sizes |
||
179 | * @param Image $imageObject |
||
180 | * @param ResponsiveImage $responsiveImage |
||
181 | * |
||
182 | * @return ResponsiveImage |
||
183 | * |
||
184 | * @TODO: refactor code duplication |
||
185 | */ |
||
186 | public function createScaledImages(Image $imageObject, ResponsiveImage $responsiveImage, array $sizes) : ResponsiveImage { |
||
232 | |||
233 | /** |
||
234 | * Scale an image and save it. |
||
235 | * |
||
236 | * @param string $path |
||
237 | * @param Image $imageObject |
||
238 | * @param $width |
||
239 | * @param $height |
||
240 | * |
||
241 | * @return Image |
||
242 | */ |
||
243 | public function scaleImage(string $path, Image $imageObject, $width, $height) : Image { |
||
250 | |||
251 | /** |
||
252 | * Save the image file contents to a path |
||
253 | * |
||
254 | * @param string $path |
||
255 | * @param string $image |
||
256 | */ |
||
257 | public function saveImageFile(string $path, string $image) { |
||
262 | |||
263 | /** |
||
264 | * Optimize all sources of a Responsive Image |
||
265 | * |
||
266 | * @param ResponsiveImage $responsiveImage |
||
267 | * |
||
268 | * @return ResponsiveImage |
||
269 | */ |
||
270 | public function optimizeResponsiveImage(ResponsiveImage $responsiveImage) : ResponsiveImage { |
||
277 | |||
278 | /** |
||
279 | * @param string $directory |
||
280 | * @param string $path |
||
281 | * |
||
282 | * @return SplFileInfo |
||
283 | */ |
||
284 | private function getImageFile(string $directory, string $path) : SplFileInfo { |
||
290 | |||
291 | /** |
||
292 | * @param string $driver |
||
293 | * |
||
294 | * @return ResponsiveFactory |
||
295 | */ |
||
296 | public function setDriver($driver) : ResponsiveFactory { |
||
301 | |||
302 | /** |
||
303 | * @param string $publicPath |
||
304 | * |
||
305 | * @return ResponsiveFactory |
||
306 | */ |
||
307 | public function setPublicPath($publicPath) : ResponsiveFactory { |
||
312 | |||
313 | /** |
||
314 | * @param boolean $enableCache |
||
315 | * |
||
316 | * @return ResponsiveFactory |
||
317 | */ |
||
318 | public function setEnableCache($enableCache) : ResponsiveFactory { |
||
323 | |||
324 | /** |
||
325 | * @param string $sourcePath |
||
326 | * |
||
327 | * @return ResponsiveFactory |
||
328 | */ |
||
329 | public function setSourcePath($sourcePath) : ResponsiveFactory { |
||
334 | |||
335 | /** |
||
336 | * @param Scaler $scaler |
||
337 | * |
||
338 | * @return ResponsiveFactory |
||
339 | */ |
||
340 | public function setScaler($scaler) : ResponsiveFactory { |
||
345 | |||
346 | /** |
||
347 | * @param bool $optimize |
||
348 | * |
||
349 | * @return ResponsiveFactory |
||
350 | */ |
||
351 | public function setOptimize(bool $optimize) : ResponsiveFactory { |
||
356 | |||
357 | /** |
||
358 | * @param bool $async |
||
359 | * |
||
360 | * @return ResponsiveFactory |
||
361 | */ |
||
362 | public function setAsync(bool $async) : ResponsiveFactory { |
||
367 | |||
368 | /** |
||
369 | * @return string |
||
370 | */ |
||
371 | public function getPublicPath() : string { |
||
374 | |||
375 | } |
||
376 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: