From d76f1e6ef7a3e71c4de4ae51c064eae604eb87c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFck=20Piera?= Date: Sun, 11 Oct 2026 18:53:24 +0200 Subject: [PATCH 1/2] Fix non-integer exception codes and duplicated gif entries --- CHANGELOG.md | 1 + DependencyInjection/GifExceptionExtension.php | 9 --------- EventListener/ReplaceImageListener.php | 7 ++++--- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 190f9de..025091f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Added support for Symfony 8.2 * Replaced the `gifexception:optimize` command and `bin/optimizer.php` by the `castor optimize` task * Upgraded the test suite to PHPUnit 11 +* Fixed a `TypeError` when the exception code is not an integer ## 1.11.1 (2026-05-26) diff --git a/DependencyInjection/GifExceptionExtension.php b/DependencyInjection/GifExceptionExtension.php index 8257536..dc5442c 100644 --- a/DependencyInjection/GifExceptionExtension.php +++ b/DependencyInjection/GifExceptionExtension.php @@ -38,15 +38,6 @@ public function load(array $configs, ContainerBuilder $container): void } } - $pattern = __DIR__ . '/../Resources/public/images/other/*.gif'; - $images = glob($pattern); - - if ($images) { - foreach ($images as $path) { - $gifs['other'][] = basename($path); - } - } - $container->getDefinition('gif_exception.listener.replace_image')->replaceArgument(0, $gifs); } } diff --git a/EventListener/ReplaceImageListener.php b/EventListener/ReplaceImageListener.php index 8e728f4..c8cdcbb 100644 --- a/EventListener/ReplaceImageListener.php +++ b/EventListener/ReplaceImageListener.php @@ -43,12 +43,13 @@ public function onKernelResponse(ResponseEvent $event): void // Status code is not set by the exception controller but only by the // kernel at the very end. - // So lets use the status code from the flatten exception instead. + // So lets use the status code from the exception instead. // Unless it comes from a fatal error handler or exception base class if (method_exists($exception, 'getStatusCode')) { - $statusCode = $exception->getStatusCode(); + $statusCode = (int) $exception->getStatusCode(); } else { - $statusCode = $exception->getCode(); + // getCode() may return a string (e.g. \PDOException), not a HTTP status + $statusCode = (int) $exception->getCode(); } $dir = $this->getGifDir($statusCode); From 922895e03e21de4e8702ea5267d8bc2ecbc75d0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFck=20Piera?= Date: Sun, 11 Oct 2026 18:53:24 +0200 Subject: [PATCH 2/2] Drop unused doctrine/annotations and target PHP 8.2 in CS rules --- .php-cs-fixer.php | 2 +- README.md | 2 +- composer.json | 1 - tests/app/public/index.php | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 751335c..0089bfb 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -30,7 +30,7 @@ return (new PhpCsFixer\Config()) ->setRiskyAllowed(true) ->setRules([ - '@PHP74Migration' => true, + '@PHP82Migration' => true, '@PhpCsFixer' => true, '@Symfony' => true, '@Symfony:risky' => true, diff --git a/README.md b/README.md index da70380..80885ad 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ The GhostBuster of your exception page! -It displays a GIF instead of Symfony's ghost on exception page and it's compatible with Symfony versions from 5.4 to 8.2. +It displays a GIF instead of Symfony's ghost on exception page and it's compatible with Symfony versions from 6.4 to 8.2. Here is what it looks like : ![Demo Symfony 4.4](Resources/doc/images/demo.gif) diff --git a/composer.json b/composer.json index 6450ee2..43caa91 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,6 @@ "symfony/twig-bundle": "^6.4 || ^7.3 || ^8.0" }, "require-dev": { - "doctrine/annotations": "^2.0", "friendsofphp/php-cs-fixer": "^3.17", "phpstan/phpstan": "^2.1", "phpunit/phpunit": "^11.5", diff --git a/tests/app/public/index.php b/tests/app/public/index.php index 5bffb0b..c8c42d8 100644 --- a/tests/app/public/index.php +++ b/tests/app/public/index.php @@ -18,7 +18,7 @@ $_SERVER['APP_ENV'] ??= 'test'; $_SERVER['APP_DEBUG'] = 1; -umask(0000); +umask(0o000); Debug::enable();