Skip to content

Commit 2cc7ebe

Browse files
authored
Merge pull request #7765 from ping-yee/230802-phpstan-image
2 parents 04b70af + 7ecc708 commit 2cc7ebe

File tree

4 files changed

+62
-80
lines changed

4 files changed

+62
-80
lines changed

phpstan-baseline.php

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,71 +1196,6 @@
11961196
'count' => 1,
11971197
'path' => __DIR__ . '/system/I18n/TimeLegacy.php',
11981198
];
1199-
$ignoreErrors[] = [
1200-
'message' => '#^Method CodeIgniter\\\\Images\\\\Exceptions\\\\ImageException\\:\\:forEXIFUnsupported\\(\\) has no return type specified\\.$#',
1201-
'count' => 1,
1202-
'path' => __DIR__ . '/system/Images/Exceptions/ImageException.php',
1203-
];
1204-
$ignoreErrors[] = [
1205-
'message' => '#^Method CodeIgniter\\\\Images\\\\Exceptions\\\\ImageException\\:\\:forFileNotSupported\\(\\) has no return type specified\\.$#',
1206-
'count' => 1,
1207-
'path' => __DIR__ . '/system/Images/Exceptions/ImageException.php',
1208-
];
1209-
$ignoreErrors[] = [
1210-
'message' => '#^Method CodeIgniter\\\\Images\\\\Exceptions\\\\ImageException\\:\\:forImageProcessFailed\\(\\) has no return type specified\\.$#',
1211-
'count' => 1,
1212-
'path' => __DIR__ . '/system/Images/Exceptions/ImageException.php',
1213-
];
1214-
$ignoreErrors[] = [
1215-
'message' => '#^Method CodeIgniter\\\\Images\\\\Exceptions\\\\ImageException\\:\\:forInvalidDirection\\(\\) has no return type specified\\.$#',
1216-
'count' => 1,
1217-
'path' => __DIR__ . '/system/Images/Exceptions/ImageException.php',
1218-
];
1219-
$ignoreErrors[] = [
1220-
'message' => '#^Method CodeIgniter\\\\Images\\\\Exceptions\\\\ImageException\\:\\:forInvalidImageCreate\\(\\) has no return type specified\\.$#',
1221-
'count' => 1,
1222-
'path' => __DIR__ . '/system/Images/Exceptions/ImageException.php',
1223-
];
1224-
$ignoreErrors[] = [
1225-
'message' => '#^Method CodeIgniter\\\\Images\\\\Exceptions\\\\ImageException\\:\\:forInvalidImageLibraryPath\\(\\) has no return type specified\\.$#',
1226-
'count' => 1,
1227-
'path' => __DIR__ . '/system/Images/Exceptions/ImageException.php',
1228-
];
1229-
$ignoreErrors[] = [
1230-
'message' => '#^Method CodeIgniter\\\\Images\\\\Exceptions\\\\ImageException\\:\\:forInvalidPath\\(\\) has no return type specified\\.$#',
1231-
'count' => 1,
1232-
'path' => __DIR__ . '/system/Images/Exceptions/ImageException.php',
1233-
];
1234-
$ignoreErrors[] = [
1235-
'message' => '#^Method CodeIgniter\\\\Images\\\\Exceptions\\\\ImageException\\:\\:forMissingAngle\\(\\) has no return type specified\\.$#',
1236-
'count' => 1,
1237-
'path' => __DIR__ . '/system/Images/Exceptions/ImageException.php',
1238-
];
1239-
$ignoreErrors[] = [
1240-
'message' => '#^Method CodeIgniter\\\\Images\\\\Exceptions\\\\ImageException\\:\\:forMissingImage\\(\\) has no return type specified\\.$#',
1241-
'count' => 1,
1242-
'path' => __DIR__ . '/system/Images/Exceptions/ImageException.php',
1243-
];
1244-
$ignoreErrors[] = [
1245-
'message' => '#^Method CodeIgniter\\\\Images\\\\Exceptions\\\\ImageException\\:\\:forSaveFailed\\(\\) has no return type specified\\.$#',
1246-
'count' => 1,
1247-
'path' => __DIR__ . '/system/Images/Exceptions/ImageException.php',
1248-
];
1249-
$ignoreErrors[] = [
1250-
'message' => '#^Method CodeIgniter\\\\Images\\\\Handlers\\\\BaseHandler\\:\\:_text\\(\\) has no return type specified\\.$#',
1251-
'count' => 1,
1252-
'path' => __DIR__ . '/system/Images/Handlers/BaseHandler.php',
1253-
];
1254-
$ignoreErrors[] = [
1255-
'message' => '#^Method CodeIgniter\\\\Images\\\\Handlers\\\\BaseHandler\\:\\:ensureResource\\(\\) has no return type specified\\.$#',
1256-
'count' => 1,
1257-
'path' => __DIR__ . '/system/Images/Handlers/BaseHandler.php',
1258-
];
1259-
$ignoreErrors[] = [
1260-
'message' => '#^Method CodeIgniter\\\\Images\\\\Handlers\\\\BaseHandler\\:\\:reproportion\\(\\) has no return type specified\\.$#',
1261-
'count' => 1,
1262-
'path' => __DIR__ . '/system/Images/Handlers/BaseHandler.php',
1263-
];
12641199
$ignoreErrors[] = [
12651200
'message' => '#^Property CodeIgniter\\\\Images\\\\Handlers\\\\BaseHandler\\:\\:\\$image \\(CodeIgniter\\\\Images\\\\Image\\) in empty\\(\\) is not falsy\\.$#',
12661201
'count' => 1,
@@ -1271,21 +1206,6 @@
12711206
'count' => 2,
12721207
'path' => __DIR__ . '/system/Images/Handlers/ImageMagickHandler.php',
12731208
];
1274-
$ignoreErrors[] = [
1275-
'message' => '#^Method CodeIgniter\\\\Images\\\\Handlers\\\\ImageMagickHandler\\:\\:_text\\(\\) has no return type specified\\.$#',
1276-
'count' => 1,
1277-
'path' => __DIR__ . '/system/Images/Handlers/ImageMagickHandler.php',
1278-
];
1279-
$ignoreErrors[] = [
1280-
'message' => '#^Method CodeIgniter\\\\Images\\\\Handlers\\\\ImageMagickHandler\\:\\:ensureResource\\(\\) has no return type specified\\.$#',
1281-
'count' => 1,
1282-
'path' => __DIR__ . '/system/Images/Handlers/ImageMagickHandler.php',
1283-
];
1284-
$ignoreErrors[] = [
1285-
'message' => '#^Method CodeIgniter\\\\Images\\\\Handlers\\\\ImageMagickHandler\\:\\:supportedFormatCheck\\(\\) has no return type specified\\.$#',
1286-
'count' => 1,
1287-
'path' => __DIR__ . '/system/Images/Handlers/ImageMagickHandler.php',
1288-
];
12891209
$ignoreErrors[] = [
12901210
'message' => '#^PHPDoc type string\\|null of property CodeIgniter\\\\Images\\\\Handlers\\\\ImageMagickHandler\\:\\:\\$resource is not covariant with PHPDoc type resource\\|null of overridden property CodeIgniter\\\\Images\\\\Handlers\\\\BaseHandler\\:\\:\\$resource\\.$#',
12911211
'count' => 1,

system/Images/Exceptions/ImageException.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,51 +16,101 @@
1616

1717
class ImageException extends FrameworkException implements ExceptionInterface
1818
{
19+
/**
20+
* Thrown when the image is not found.
21+
*
22+
* @return static
23+
*/
1924
public static function forMissingImage()
2025
{
2126
return new static(lang('Images.sourceImageRequired'));
2227
}
2328

29+
/**
30+
* Thrown when the file specific is not following the role.
31+
*
32+
* @return static
33+
*/
2434
public static function forFileNotSupported()
2535
{
2636
return new static(lang('Images.fileNotSupported'));
2737
}
2838

39+
/**
40+
* Thrown when the angle is undefined.
41+
*
42+
* @return static
43+
*/
2944
public static function forMissingAngle()
3045
{
3146
return new static(lang('Images.rotationAngleRequired'));
3247
}
3348

49+
/**
50+
* Thrown when the direction property is invalid.
51+
*
52+
* @return static
53+
*/
3454
public static function forInvalidDirection(?string $dir = null)
3555
{
3656
return new static(lang('Images.invalidDirection', [$dir]));
3757
}
3858

59+
/**
60+
* Thrown when the path property is invalid.
61+
*
62+
* @return static
63+
*/
3964
public static function forInvalidPath()
4065
{
4166
return new static(lang('Images.invalidPath'));
4267
}
4368

69+
/**
70+
* Thrown when the EXIF function is not supported.
71+
*
72+
* @return static
73+
*/
4474
public static function forEXIFUnsupported()
4575
{
4676
return new static(lang('Images.exifNotSupported'));
4777
}
4878

79+
/**
80+
* Thrown when the image specific is invalid.
81+
*
82+
* @return static
83+
*/
4984
public static function forInvalidImageCreate(?string $extra = null)
5085
{
5186
return new static(lang('Images.unsupportedImageCreate') . ' ' . $extra);
5287
}
5388

89+
/**
90+
* Thrown when the image save failed.
91+
*
92+
* @return static
93+
*/
5494
public static function forSaveFailed()
5595
{
5696
return new static(lang('Images.saveFailed'));
5797
}
5898

99+
/**
100+
* Thrown when the image library path is invalid.
101+
*
102+
* @return static
103+
*/
59104
public static function forInvalidImageLibraryPath(?string $path = null)
60105
{
61106
return new static(lang('Images.libPathInvalid', [$path]));
62107
}
63108

109+
/**
110+
* Thrown when the image process failed.
111+
*
112+
* @return static
113+
*/
64114
public static function forImageProcessFailed()
65115
{
66116
return new static(lang('Images.imageProcessFailed'));

system/Images/Handlers/BaseHandler.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ public function withFile(string $path)
156156

157157
/**
158158
* Make the image resource object if needed
159+
*
160+
* @return void
159161
*/
160162
abstract protected function ensureResource();
161163

@@ -422,6 +424,8 @@ public function text(string $text, array $options = [])
422424

423425
/**
424426
* Handler-specific method for overlaying text on an image.
427+
*
428+
* @return void
425429
*/
426430
abstract protected function _text(string $text, array $options = []);
427431

@@ -722,6 +726,8 @@ public function __call(string $name, array $args = [])
722726
*
723727
* This function lets us re-proportion the width/height
724728
* if users choose to maintain the aspect ratio when resizing.
729+
*
730+
* @return void
725731
*/
726732
protected function reproportion()
727733
{

system/Images/Handlers/ImageMagickHandler.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ protected function getResourcePath()
290290
/**
291291
* Make the image resource object if needed
292292
*
293+
* @return void
294+
*
293295
* @throws Exception
294296
*/
295297
protected function ensureResource()
@@ -302,6 +304,8 @@ protected function ensureResource()
302304
/**
303305
* Check if given image format is supported
304306
*
307+
* @return void
308+
*
305309
* @throws ImageException
306310
*/
307311
protected function supportedFormatCheck()
@@ -318,6 +322,8 @@ protected function supportedFormatCheck()
318322
/**
319323
* Handler-specific method for overlaying text on an image.
320324
*
325+
* @return void
326+
*
321327
* @throws Exception
322328
*/
323329
protected function _text(string $text, array $options = [])

0 commit comments

Comments
 (0)