From 38f9111b48681de86b3b12f3371743adcc65a978 Mon Sep 17 00:00:00 2001 From: King <97401913+sgr1806-20@users.noreply.github.com> Date: Tue, 24 Nov 2026 11:22:39 +0530 Subject: [PATCH 01/14] Add forMissingExtension method to ImageException Add method for handling missing PHP extensions in ImageException. --- system/Images/Exceptions/ImageException.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/system/Images/Exceptions/ImageException.php b/system/Images/Exceptions/ImageException.php index 46651fbf706d..53c015cafa67 100644 --- a/system/Images/Exceptions/ImageException.php +++ b/system/Images/Exceptions/ImageException.php @@ -27,6 +27,16 @@ public static function forMissingImage() return new static(lang('Images.sourceImageRequired')); } + /** + * Thrown when a required PHP extension is not loaded. + * + * @return static + */ + public static function forMissingExtension(string $extension) + { + return new static(lang('Images.missingExtension', [$extension])); + } + /** * Thrown when the file specific is not following the role. * From a18f3aa7b98e04e975f67a267469b5757ad5381b Mon Sep 17 00:00:00 2001 From: King <97401913+sgr1806-20@users.noreply.github.com> Date: Tue, 24 Nov 2026 11:24:03 +0530 Subject: [PATCH 02/14] Add missing extension error message to Images.php --- system/Language/en/Images.php | 1 + 1 file changed, 1 insertion(+) diff --git a/system/Language/en/Images.php b/system/Language/en/Images.php index 2302cfb89018..3c310de717ba 100644 --- a/system/Language/en/Images.php +++ b/system/Language/en/Images.php @@ -15,6 +15,7 @@ return [ 'sourceImageRequired' => 'You must specify a source image in your preferences.', 'gdRequired' => 'The GD image library is required to use this feature.', + 'missingExtension' => 'The framework needs the following extension(s) installed and loaded: "{0}".', 'gdRequiredForProps' => 'Your server must support the GD image library in order to determine the image properties.', 'gifNotSupported' => 'GIF images are often not supported due to licensing restrictions. You may have to use JPG or PNG images instead.', 'jpgNotSupported' => 'JPG images are not supported.', From aec2f08357a58defc847365cc293d01d2068f250 Mon Sep 17 00:00:00 2001 From: King <97401913+sgr1806-20@users.noreply.github.com> Date: Tue, 24 Nov 2026 11:25:07 +0530 Subject: [PATCH 03/14] Add test for missing GD extension exception message --- tests/system/Images/GDHandlerTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/system/Images/GDHandlerTest.php b/tests/system/Images/GDHandlerTest.php index 3be342550072..513b7e38ba85 100644 --- a/tests/system/Images/GDHandlerTest.php +++ b/tests/system/Images/GDHandlerTest.php @@ -553,4 +553,15 @@ public function testProcessUnsupportedImageType(): void // resize() calls ensureResource() -> getImageResource(), which should throw $this->handler->resize(10, 10); } + + + public function testForMissingExtensionReturnsExpectedMessage(): void + { + $exception = ImageException::forMissingExtension('GD'); + + $this->assertSame( + 'The framework needs the following extension(s) installed and loaded: "GD".', + $exception->getMessage(), + ); + } } From c3adbe202f4d7bcf23aa241c8a078749138f733d Mon Sep 17 00:00:00 2001 From: King <97401913+sgr1806-20@users.noreply.github.com> Date: Tue, 24 Nov 2026 11:33:00 +0530 Subject: [PATCH 04/14] Remove unnecessary blank line in GDHandlerTest --- tests/system/Images/GDHandlerTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/system/Images/GDHandlerTest.php b/tests/system/Images/GDHandlerTest.php index 513b7e38ba85..e135bf80dc28 100644 --- a/tests/system/Images/GDHandlerTest.php +++ b/tests/system/Images/GDHandlerTest.php @@ -553,7 +553,6 @@ public function testProcessUnsupportedImageType(): void // resize() calls ensureResource() -> getImageResource(), which should throw $this->handler->resize(10, 10); } - public function testForMissingExtensionReturnsExpectedMessage(): void { From f2bb3789f15b7a886583c472c322505f425366af Mon Sep 17 00:00:00 2001 From: King <97401913+sgr1806-20@users.noreply.github.com> Date: Tue, 24 Nov 2026 11:47:14 +0530 Subject: [PATCH 05/14] Fix formatting in ImageException.php --- system/Images/Exceptions/ImageException.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Images/Exceptions/ImageException.php b/system/Images/Exceptions/ImageException.php index 53c015cafa67..5ef8365bf1a2 100644 --- a/system/Images/Exceptions/ImageException.php +++ b/system/Images/Exceptions/ImageException.php @@ -36,7 +36,7 @@ public static function forMissingExtension(string $extension) { return new static(lang('Images.missingExtension', [$extension])); } - + /** * Thrown when the file specific is not following the role. * From 44f7c836711685261b4ed197a1567bccefc6c35a Mon Sep 17 00:00:00 2001 From: King <97401913+sgr1806-20@users.noreply.github.com> Date: Tue, 24 Nov 2026 11:48:06 +0530 Subject: [PATCH 06/14] Fix formatting in GDHandlerTest.php --- tests/system/Images/GDHandlerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/Images/GDHandlerTest.php b/tests/system/Images/GDHandlerTest.php index e135bf80dc28..932ae2518f34 100644 --- a/tests/system/Images/GDHandlerTest.php +++ b/tests/system/Images/GDHandlerTest.php @@ -553,7 +553,7 @@ public function testProcessUnsupportedImageType(): void // resize() calls ensureResource() -> getImageResource(), which should throw $this->handler->resize(10, 10); } - + public function testForMissingExtensionReturnsExpectedMessage(): void { $exception = ImageException::forMissingExtension('GD'); From bf749a2b01c0415a9886bd4ccd633e8ec2900ff0 Mon Sep 17 00:00:00 2001 From: King <97401913+sgr1806-20@users.noreply.github.com> Date: Tue, 24 Nov 2026 12:38:32 +0530 Subject: [PATCH 07/14] Remove forMissingExtension method from ImageException Removed the forMissingExtension method from ImageException. --- system/Images/Exceptions/ImageException.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/system/Images/Exceptions/ImageException.php b/system/Images/Exceptions/ImageException.php index 5ef8365bf1a2..46651fbf706d 100644 --- a/system/Images/Exceptions/ImageException.php +++ b/system/Images/Exceptions/ImageException.php @@ -27,16 +27,6 @@ public static function forMissingImage() return new static(lang('Images.sourceImageRequired')); } - /** - * Thrown when a required PHP extension is not loaded. - * - * @return static - */ - public static function forMissingExtension(string $extension) - { - return new static(lang('Images.missingExtension', [$extension])); - } - /** * Thrown when the file specific is not following the role. * From 5aec06d6b838558403f9a3c0572c845e9bc2f3ab Mon Sep 17 00:00:00 2001 From: King <97401913+sgr1806-20@users.noreply.github.com> Date: Tue, 24 Nov 2026 12:39:19 +0530 Subject: [PATCH 08/14] Remove missing extension error message Removed the missing extension error message from language settings. --- system/Language/en/Images.php | 1 - 1 file changed, 1 deletion(-) diff --git a/system/Language/en/Images.php b/system/Language/en/Images.php index 3c310de717ba..2302cfb89018 100644 --- a/system/Language/en/Images.php +++ b/system/Language/en/Images.php @@ -15,7 +15,6 @@ return [ 'sourceImageRequired' => 'You must specify a source image in your preferences.', 'gdRequired' => 'The GD image library is required to use this feature.', - 'missingExtension' => 'The framework needs the following extension(s) installed and loaded: "{0}".', 'gdRequiredForProps' => 'Your server must support the GD image library in order to determine the image properties.', 'gifNotSupported' => 'GIF images are often not supported due to licensing restrictions. You may have to use JPG or PNG images instead.', 'jpgNotSupported' => 'JPG images are not supported.', From 43d3cfa00ceb0fcee02eb931f9a428726970e4e0 Mon Sep 17 00:00:00 2001 From: King <97401913+sgr1806-20@users.noreply.github.com> Date: Tue, 24 Nov 2026 12:40:31 +0530 Subject: [PATCH 09/14] Delete testForMissingExtensionReturnsExpectedMessage Removed test for missing GD extension. --- tests/system/Images/GDHandlerTest.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tests/system/Images/GDHandlerTest.php b/tests/system/Images/GDHandlerTest.php index 932ae2518f34..3be342550072 100644 --- a/tests/system/Images/GDHandlerTest.php +++ b/tests/system/Images/GDHandlerTest.php @@ -553,14 +553,4 @@ public function testProcessUnsupportedImageType(): void // resize() calls ensureResource() -> getImageResource(), which should throw $this->handler->resize(10, 10); } - - public function testForMissingExtensionReturnsExpectedMessage(): void - { - $exception = ImageException::forMissingExtension('GD'); - - $this->assertSame( - 'The framework needs the following extension(s) installed and loaded: "GD".', - $exception->getMessage(), - ); - } } From 486c847e86155b01ad9dbe1f15d3e4cc3eb64c50 Mon Sep 17 00:00:00 2001 From: King <97401913+sgr1806-20@users.noreply.github.com> Date: Tue, 24 Nov 2026 12:44:10 +0530 Subject: [PATCH 10/14] Throw RuntimeException for missing GD extension --- system/Images/Handlers/GDHandler.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/system/Images/Handlers/GDHandler.php b/system/Images/Handlers/GDHandler.php index 705d1b5d4156..febfec7762c6 100644 --- a/system/Images/Handlers/GDHandler.php +++ b/system/Images/Handlers/GDHandler.php @@ -17,6 +17,7 @@ use Config\Images; use GdImage; use Override; +use RuntimeException; /** * Image handler for GD package @@ -35,7 +36,10 @@ public function __construct($config = null) parent::__construct($config); if (! extension_loaded('gd')) { - throw ImageException::forMissingExtension('GD'); // @codeCoverageIgnore + throw new RuntimeException(sprintf( + 'The "%s" handler requires the "gd" PHP extension.', + static::class, + )); } } From f973ed7a79c66dda10492dc13eff40f5f25467df Mon Sep 17 00:00:00 2001 From: King <97401913+sgr1806-20@users.noreply.github.com> Date: Tue, 24 Nov 2026 13:18:38 +0530 Subject: [PATCH 11/14] Delete utils/phpstan-baseline/staticMethod.notFound.neon PHPStan fails when an ignored error no longer occurs ("unmatched ignore") --- utils/phpstan-baseline/staticMethod.notFound.neon | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 utils/phpstan-baseline/staticMethod.notFound.neon diff --git a/utils/phpstan-baseline/staticMethod.notFound.neon b/utils/phpstan-baseline/staticMethod.notFound.neon deleted file mode 100644 index ee77d25a47cc..000000000000 --- a/utils/phpstan-baseline/staticMethod.notFound.neon +++ /dev/null @@ -1,8 +0,0 @@ -# total 1 error - -parameters: - ignoreErrors: - - - message: '#^Call to an undefined static method CodeIgniter\\Images\\Exceptions\\ImageException\:\:forMissingExtension\(\)\.$#' - count: 1 - path: ../../system/Images/Handlers/GDHandler.php From 3c9a9f4dadeef06ed1084ec47e580c323728346e Mon Sep 17 00:00:00 2001 From: King <97401913+sgr1806-20@users.noreply.github.com> Date: Tue, 24 Nov 2026 13:19:05 +0530 Subject: [PATCH 12/14] Remove staticMethod.notFound.neon from PHPStan baseline --- utils/phpstan-baseline/loader.neon | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 9a9653cc3c2e..0ca6f8f74ff5 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -8,4 +8,3 @@ includes: - missingType.callable.neon - property.defaultValue.neon - property.phpDocType.neon - - staticMethod.notFound.neon From 50c559603b4db49786d155efc6c86191d95dd9e2 Mon Sep 17 00:00:00 2001 From: King <97401913+sgr1806-20@users.noreply.github.com> Date: Tue, 24 Nov 2026 18:23:50 +0530 Subject: [PATCH 13/14] fix: use the framework RuntimeException and regenerate the PHPStan baseline - GDHandler now throws CodeIgniter\Exceptions\RuntimeException - utils/phpstan-baseline regenerated with composer phpstan:baseline --- system/Images/Handlers/GDHandler.php | 2 +- utils/phpstan-baseline/loader.neon | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/Images/Handlers/GDHandler.php b/system/Images/Handlers/GDHandler.php index febfec7762c6..b7497b2e8255 100644 --- a/system/Images/Handlers/GDHandler.php +++ b/system/Images/Handlers/GDHandler.php @@ -13,11 +13,11 @@ namespace CodeIgniter\Images\Handlers; +use CodeIgniter\Exceptions\RuntimeException; use CodeIgniter\Images\Exceptions\ImageException; use Config\Images; use GdImage; use Override; -use RuntimeException; /** * Image handler for GD package diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 0ca6f8f74ff5..c3f82af9dbf4 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,4 +1,4 @@ -# total 38 errors +# total 37 errors includes: - arguments.count.neon From e39dec73b180c4a9ff702721b73b6d699c97742c Mon Sep 17 00:00:00 2001 From: King <97401913+sgr1806-20@users.noreply.github.com> Date: Wed, 25 Nov 2026 13:12:39 +0530 Subject: [PATCH 14/14] refactor: use the framework RuntimeException in ImageMagickHandler as well --- system/Images/Handlers/ImageMagickHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Images/Handlers/ImageMagickHandler.php b/system/Images/Handlers/ImageMagickHandler.php index 5dc24fe358f0..523f75534e74 100644 --- a/system/Images/Handlers/ImageMagickHandler.php +++ b/system/Images/Handlers/ImageMagickHandler.php @@ -13,6 +13,7 @@ namespace CodeIgniter\Images\Handlers; +use CodeIgniter\Exceptions\RuntimeException; use CodeIgniter\Images\Exceptions\ImageException; use Config\Images; use Imagick; @@ -22,7 +23,6 @@ use ImagickPixel; use ImagickPixelException; use Override; -use RuntimeException; /** * Image handler for Imagick extension.