Skip to content

Commit 07594ed

Browse files
committed
Remove Image\ImageWrapper::destroy method
This method has no operation in PHP 8.0. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent e5de6ef commit 07594ed

5 files changed

Lines changed: 10 additions & 99 deletions

File tree

libraries/classes/Controllers/Transformation/WrapperController.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,6 @@ public function __invoke(ServerRequest $request): void
176176

177177
$destImage = ImageWrapper::create($destWidth, $destHeight);
178178
if ($destImage === null) {
179-
$srcImage->destroy();
180-
181179
return;
182180
}
183181

@@ -188,9 +186,6 @@ public function __invoke(ServerRequest $request): void
188186
} else {
189187
$destImage->png();
190188
}
191-
192-
$destImage->destroy();
193-
$srcImage->destroy();
194189
}
195190

196191
/**

libraries/classes/Gis/GisVisualization.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,6 @@ public function asPng()
368368
// render and save it to variable
369369
ob_start();
370370
$image->png(null, 9, PNG_ALL_FILTERS);
371-
$image->destroy();
372371
$output = ob_get_clean();
373372

374373
// base64 encode
@@ -391,7 +390,6 @@ public function toFileAsPng($file_name): void
391390

392391
$this->writeToFile($file_name, 'image/png', 'png');
393392
$image->png(null, 9, PNG_ALL_FILTERS);
394-
$image->destroy();
395393
}
396394

397395
/**

libraries/classes/Image/ImageWrapper.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use function imagecopyresampled;
1414
use function imagecreatefromstring;
1515
use function imagecreatetruecolor;
16-
use function imagedestroy;
1716
use function imagefilledpolygon;
1817
use function imagefilledrectangle;
1918
use function imagejpeg;
@@ -55,14 +54,10 @@ public static function create(int $width, int $height, ?array $background = null
5554

5655
$backgroundColor = imagecolorallocate($image, $background['red'], $background['green'], $background['blue']);
5756
if ($backgroundColor === false) {
58-
imagedestroy($image);
59-
6057
return null;
6158
}
6259

6360
if (! imagefilledrectangle($image, 0, 0, $width - 1, $height - 1, $backgroundColor)) {
64-
imagedestroy($image);
65-
6661
return null;
6762
}
6863

@@ -128,11 +123,7 @@ public function copyResampled(
128123
);
129124
}
130125

131-
public function destroy(): bool
132-
{
133-
return true;
134-
}
135-
126+
/** @param list<int> $points */
136127
public function filledPolygon(array $points, int $color): bool
137128
{
138129
return imagefilledpolygon($this->image, $points, $color);

phpstan-baseline.neon

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -4770,71 +4770,6 @@ parameters:
47704770
count: 2
47714771
path: libraries/classes/Http/ServerRequest.php
47724772

4773-
-
4774-
message: "#^Method PhpMyAdmin\\\\Image\\\\ImageWrapper\\:\\:filledPolygon\\(\\) has parameter \\$points with no value type specified in iterable type array\\.$#"
4775-
count: 1
4776-
path: libraries/classes/Image/ImageWrapper.php
4777-
4778-
-
4779-
message: "#^Parameter \\#1 \\$dst_image of function imagecopyresampled expects GdImage, resource given\\.$#"
4780-
count: 1
4781-
path: libraries/classes/Image/ImageWrapper.php
4782-
4783-
-
4784-
message: "#^Parameter \\#1 \\$image of class PhpMyAdmin\\\\Image\\\\ImageWrapper constructor expects resource, GdImage given\\.$#"
4785-
count: 3
4786-
path: libraries/classes/Image/ImageWrapper.php
4787-
4788-
-
4789-
message: "#^Parameter \\#1 \\$image of function imagearc expects GdImage, resource given\\.$#"
4790-
count: 1
4791-
path: libraries/classes/Image/ImageWrapper.php
4792-
4793-
-
4794-
message: "#^Parameter \\#1 \\$image of function imagecolorallocate expects GdImage, resource given\\.$#"
4795-
count: 1
4796-
path: libraries/classes/Image/ImageWrapper.php
4797-
4798-
-
4799-
message: "#^Parameter \\#1 \\$image of function imagefilledpolygon expects GdImage, resource given\\.$#"
4800-
count: 1
4801-
path: libraries/classes/Image/ImageWrapper.php
4802-
4803-
-
4804-
message: "#^Parameter \\#1 \\$image of function imagejpeg expects GdImage, resource given\\.$#"
4805-
count: 1
4806-
path: libraries/classes/Image/ImageWrapper.php
4807-
4808-
-
4809-
message: "#^Parameter \\#1 \\$image of function imageline expects GdImage, resource given\\.$#"
4810-
count: 1
4811-
path: libraries/classes/Image/ImageWrapper.php
4812-
4813-
-
4814-
message: "#^Parameter \\#1 \\$image of function imagepng expects GdImage, resource given\\.$#"
4815-
count: 1
4816-
path: libraries/classes/Image/ImageWrapper.php
4817-
4818-
-
4819-
message: "#^Parameter \\#1 \\$image of function imagestring expects GdImage, resource given\\.$#"
4820-
count: 1
4821-
path: libraries/classes/Image/ImageWrapper.php
4822-
4823-
-
4824-
message: "#^Parameter \\#1 \\$image of function imagesx expects GdImage, resource given\\.$#"
4825-
count: 1
4826-
path: libraries/classes/Image/ImageWrapper.php
4827-
4828-
-
4829-
message: "#^Parameter \\#1 \\$image of function imagesy expects GdImage, resource given\\.$#"
4830-
count: 1
4831-
path: libraries/classes/Image/ImageWrapper.php
4832-
4833-
-
4834-
message: "#^Parameter \\#2 \\$src_image of function imagecopyresampled expects GdImage, resource given\\.$#"
4835-
count: 1
4836-
path: libraries/classes/Image/ImageWrapper.php
4837-
48384773
-
48394774
message: "#^Casting to int something that's already int\\.$#"
48404775
count: 2

psalm-baseline.xml

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2616,6 +2616,8 @@
26162616
<code>exportHeader</code>
26172617
</MixedMethodCall>
26182618
<PossiblyInvalidArgument>
2619+
<code>$this-&gt;export-&gt;dumpBuffer</code>
2620+
<code>$this-&gt;export-&gt;dumpBuffer</code>
26192621
<code>$whatStrucOrData</code>
26202622
<code>$whatStrucOrData</code>
26212623
<code>$whatStrucOrData</code>
@@ -2624,6 +2626,7 @@
26242626
<code>$whatStrucOrData</code>
26252627
</PossiblyInvalidArgument>
26262628
<PossiblyInvalidCast>
2629+
<code>$this-&gt;export-&gt;dumpBuffer</code>
26272630
<code>$whatStrucOrData</code>
26282631
<code>$whatStrucOrData</code>
26292632
<code>$whatStrucOrData</code>
@@ -8271,6 +8274,9 @@
82718274
</RedundantPropertyInitializationCheck>
82728275
</file>
82738276
<file src="libraries/classes/Gis/GisMultiPolygon.php">
8277+
<ArgumentTypeCoercion>
8278+
<code>$points_arr</code>
8279+
</ArgumentTypeCoercion>
82748280
<MixedArgument>
82758281
<code>$label_point[0]</code>
82768282
<code>$label_point[0]</code>
@@ -8464,6 +8470,9 @@
84648470
</RedundantPropertyInitializationCheck>
84658471
</file>
84668472
<file src="libraries/classes/Gis/GisPolygon.php">
8473+
<ArgumentTypeCoercion>
8474+
<code>$points_arr</code>
8475+
</ArgumentTypeCoercion>
84678476
<MixedArgument>
84688477
<code>$points_arr[2]</code>
84698478
<code>$points_arr[2]</code>
@@ -8943,30 +8952,13 @@
89438952
</UnusedMethod>
89448953
</file>
89458954
<file src="libraries/classes/Image/ImageWrapper.php">
8946-
<InvalidArgument>
8947-
<code>$image</code>
8948-
<code>$image</code>
8949-
<code>$image</code>
8950-
<code>$sourceImage-&gt;getImage()</code>
8951-
<code>$this-&gt;image</code>
8952-
<code>$this-&gt;image</code>
8953-
<code>$this-&gt;image</code>
8954-
<code>$this-&gt;image</code>
8955-
<code>$this-&gt;image</code>
8956-
<code>$this-&gt;image</code>
8957-
<code>$this-&gt;image</code>
8958-
<code>$this-&gt;image</code>
8959-
<code>$this-&gt;image</code>
8960-
<code>$this-&gt;image</code>
8961-
</InvalidArgument>
89628955
<PossiblyUnusedReturnValue>
89638956
<code>bool</code>
89648957
<code>bool</code>
89658958
<code>bool</code>
89668959
<code>bool</code>
89678960
<code>bool</code>
89688961
<code>bool</code>
8969-
<code>bool</code>
89708962
</PossiblyUnusedReturnValue>
89718963
<TooFewArguments>
89728964
<code>imagefilledpolygon($this-&gt;image, $points, $color)</code>

0 commit comments

Comments
 (0)