1 | <?php |
||
7 | abstract class AbstractImage |
||
8 | { |
||
9 | protected const POSITIONS = [ |
||
10 | 'NORTHWEST' => ['x' => 0, 'y' => 0, 'padX' => 10, 'padY' => 10], |
||
11 | 'NORTH' => ['x' => 1, 'y' => 0, 'padX' => 0, 'padY' => 10], |
||
12 | 'NORTHEAST' => ['x' => 2, 'y' => 0, 'padX' => -10, 'padY' => 10], |
||
13 | 'WEST' => ['x' => 0, 'y' => 1, 'padX' => 10, 'padY' => 0], |
||
14 | 'CENTER' => ['x' => 1, 'y' => 1, 'padX' => 0, 'padY' => 0], |
||
15 | 'EAST' => ['x' => 2, 'y' => 1, 'padX' => -10, 'padY' => 0], |
||
16 | 'SOUTHWEST' => ['x' => 0, 'y' => 2, 'padX' => 10, 'padY' => -10], |
||
17 | 'SOUTH' => ['x' => 1, 'y' => 2, 'padX' => 0, 'padY' => -10], |
||
18 | 'SOUTHEAST' => ['x' => 2, 'y' => 2, 'padX' => -10, 'padY' => -10] |
||
19 | ]; |
||
20 | |||
21 | protected $width; |
||
22 | |||
23 | protected $height; |
||
24 | |||
25 | abstract public function getImage(); |
||
26 | |||
27 | /** |
||
28 | * @param string $mode |
||
29 | * @param int $param |
||
30 | * @return ImageInterface |
||
31 | * @throws \Exception |
||
32 | */ |
||
33 | public function resizeBy(string $mode, int $param): ImageInterface |
||
46 | |||
47 | /** |
||
48 | * @param int $width |
||
49 | * @return ImageInterface |
||
50 | */ |
||
51 | public function resizeByWidth(int $width): ImageInterface |
||
55 | |||
56 | abstract protected function resize(int $width, int $height): ImageInterface; |
||
57 | |||
58 | public function getHeight(): int |
||
62 | |||
63 | protected function setHeight(int $height): void |
||
67 | |||
68 | public function getWidth(): int |
||
72 | |||
73 | protected function setWidth(int $width): void |
||
77 | |||
78 | /** |
||
79 | * @param int $height |
||
80 | * @return ImageInterface |
||
81 | */ |
||
82 | public function resizeByHeight(int $height): ImageInterface |
||
86 | |||
87 | /** |
||
88 | * @param int $percent |
||
89 | * @return ImageInterface |
||
90 | */ |
||
91 | public function resizeByPercent(int $percent): ImageInterface |
||
97 | |||
98 | /** |
||
99 | * @param Image $watermark |
||
100 | * @param string $position |
||
101 | * @return ImageInterface |
||
102 | * @throws \Exception |
||
103 | */ |
||
104 | public function watermark(Image $watermark, string $position): ImageInterface |
||
116 | |||
117 | abstract protected function prepareWatermark(Image $watermark, int $x, int $y): ImageInterface; |
||
118 | |||
119 | public function thumbnail(int $width, int $height): ImageInterface |
||
130 | |||
131 | abstract protected function prepareThumbnail(int $width, int $height): ImageInterface; |
||
132 | |||
133 | public function getBase64(): string |
||
138 | |||
139 | abstract public function __toString(): string; |
||
140 | |||
141 | abstract protected function setImage($image): void; |
||
142 | |||
143 | abstract protected function setSizes(): void; |
||
144 | |||
145 | /** |
||
146 | * @param string $image |
||
147 | * @throws \Exception |
||
148 | */ |
||
149 | protected function init(string $image): void |
||
165 | |||
166 | /** |
||
167 | * @param string $base64 |
||
168 | * @throws \Exception |
||
169 | */ |
||
170 | protected function getImageByBase64(string $base64): void |
||
174 | |||
175 | abstract protected function tmp(string $source): ImageInterface; |
||
176 | |||
177 | /** |
||
178 | * @param string $url |
||
179 | * @return \Exception|null |
||
180 | * @throws \Exception |
||
181 | */ |
||
182 | protected function getImageByURL(string $url): ?\Exception |
||
197 | } |
||
198 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.