diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75ed398..3425e9a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,17 +58,17 @@ jobs: exclude: - php-version: "8.1" symfony: '8.0.*' - operating-system: "ubuntu-latest" - php-version: "8.2" symfony: '8.0.*' - operating-system: "ubuntu-latest" - php-version: "8.3" symfony: '8.0.*' - operating-system: "ubuntu-latest" steps: - name: Checkout uses: actions/checkout@v3 + - name: Install gifsicle + run: sudo apt-get update && sudo apt-get install -y gifsicle + - name: Setup PHP, with composer and extensions uses: shivammathur/setup-php@v2 with: @@ -84,7 +84,7 @@ jobs: run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache composer dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ github.sha }} diff --git a/Command/GifOptimizerCommand.php b/Command/GifOptimizerCommand.php index cc958e3..e0e244d 100644 --- a/Command/GifOptimizerCommand.php +++ b/Command/GifOptimizerCommand.php @@ -63,12 +63,16 @@ protected function initialize(InputInterface $input, OutputInterface $output): v $optimizationLevel = $input->getOption('optimization_level'); $width = $input->getOption('resize_width'); + if (!is_numeric($width)) { + throw new \Exception('Invalid width.'); + } + $this->optimizer = OptimizerChainFactory::create() ->setOptimizers([ new Gifsicle([ '-b', $optimizationLevel, - '--resize-width=' . $width, + \sprintf('--resize-width=%s', (string) $width), ]), ]) ; @@ -79,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $imageDir = $input->getArgument('image_dir'); if (!\is_string($imageDir) || !is_dir($imageDir)) { - throw new \RuntimeException($imageDir . ' is not a valid directory'); + throw new \RuntimeException('image_dir is not a valid directory'); } $pattern = $imageDir . '/*/*.gif'; diff --git a/EventListener/ReplaceImageListener.php b/EventListener/ReplaceImageListener.php index 8c476d3..538758b 100644 --- a/EventListener/ReplaceImageListener.php +++ b/EventListener/ReplaceImageListener.php @@ -37,7 +37,7 @@ public function onKernelResponse(ResponseEvent $event): void } $exception = $event->getRequest()->attributes->get('exception'); - if (!($exception instanceof \Throwable)) { + if (!$exception instanceof \Throwable) { return; } diff --git a/Resources/public/images/403/dog-cat-stairs.gif b/Resources/public/images/403/dog-cat-stairs.gif index 32e3826..56c77cd 100644 Binary files a/Resources/public/images/403/dog-cat-stairs.gif and b/Resources/public/images/403/dog-cat-stairs.gif differ diff --git a/Resources/public/images/403/gandalf.gif b/Resources/public/images/403/gandalf.gif index 804916f..5fbd133 100644 Binary files a/Resources/public/images/403/gandalf.gif and b/Resources/public/images/403/gandalf.gif differ diff --git a/Resources/public/images/403/goat-motorbike.gif b/Resources/public/images/403/goat-motorbike.gif index 0e712c1..04d73c1 100644 Binary files a/Resources/public/images/403/goat-motorbike.gif and b/Resources/public/images/403/goat-motorbike.gif differ diff --git a/Resources/public/images/403/men-in-black-flash.gif b/Resources/public/images/403/men-in-black-flash.gif index 42ec1a2..64104c1 100644 Binary files a/Resources/public/images/403/men-in-black-flash.gif and b/Resources/public/images/403/men-in-black-flash.gif differ diff --git a/Resources/public/images/404/confused-travolta.gif b/Resources/public/images/404/confused-travolta.gif index bb97f6e..cf1a80f 100644 Binary files a/Resources/public/images/404/confused-travolta.gif and b/Resources/public/images/404/confused-travolta.gif differ diff --git a/Resources/public/images/404/looping-bird.gif b/Resources/public/images/404/looping-bird.gif index 4b7f1f2..341bd12 100644 Binary files a/Resources/public/images/404/looping-bird.gif and b/Resources/public/images/404/looping-bird.gif differ diff --git a/Resources/public/images/404/missing-stapler.gif b/Resources/public/images/404/missing-stapler.gif index 965247e..6c3dcfd 100644 Binary files a/Resources/public/images/404/missing-stapler.gif and b/Resources/public/images/404/missing-stapler.gif differ diff --git a/Resources/public/images/404/nothing-to-see-here.gif b/Resources/public/images/404/nothing-to-see-here.gif index 08653cb..4a35fc0 100644 Binary files a/Resources/public/images/404/nothing-to-see-here.gif and b/Resources/public/images/404/nothing-to-see-here.gif differ diff --git a/Resources/public/images/other/athletic.gif b/Resources/public/images/other/athletic.gif index 5bbe883..b9bffc3 100644 Binary files a/Resources/public/images/other/athletic.gif and b/Resources/public/images/other/athletic.gif differ diff --git a/Resources/public/images/other/bottle.gif b/Resources/public/images/other/bottle.gif index 6f42fb3..bdfac8b 100644 Binary files a/Resources/public/images/other/bottle.gif and b/Resources/public/images/other/bottle.gif differ diff --git a/Resources/public/images/other/captain-america.gif b/Resources/public/images/other/captain-america.gif index 577c798..096319a 100644 Binary files a/Resources/public/images/other/captain-america.gif and b/Resources/public/images/other/captain-america.gif differ diff --git a/Resources/public/images/other/car-accident.gif b/Resources/public/images/other/car-accident.gif index 15cb114..570b540 100644 Binary files a/Resources/public/images/other/car-accident.gif and b/Resources/public/images/other/car-accident.gif differ diff --git a/Resources/public/images/other/carousel-fail-o.gif b/Resources/public/images/other/carousel-fail-o.gif index 216768c..f44ed21 100644 Binary files a/Resources/public/images/other/carousel-fail-o.gif and b/Resources/public/images/other/carousel-fail-o.gif differ diff --git a/Resources/public/images/other/castle.gif b/Resources/public/images/other/castle.gif index e62aaa3..fafaf95 100644 Binary files a/Resources/public/images/other/castle.gif and b/Resources/public/images/other/castle.gif differ diff --git a/Resources/public/images/other/dunk.gif b/Resources/public/images/other/dunk.gif index 72d5ed1..0feb011 100644 Binary files a/Resources/public/images/other/dunk.gif and b/Resources/public/images/other/dunk.gif differ diff --git a/Resources/public/images/other/facepalm.gif b/Resources/public/images/other/facepalm.gif index f12ff0d..a329c7a 100644 Binary files a/Resources/public/images/other/facepalm.gif and b/Resources/public/images/other/facepalm.gif differ diff --git a/Resources/public/images/other/garbage.gif b/Resources/public/images/other/garbage.gif index a09c9f4..06eaabf 100644 Binary files a/Resources/public/images/other/garbage.gif and b/Resources/public/images/other/garbage.gif differ diff --git a/Resources/public/images/other/kangaroo.gif b/Resources/public/images/other/kangaroo.gif index 4d39789..6a09850 100644 Binary files a/Resources/public/images/other/kangaroo.gif and b/Resources/public/images/other/kangaroo.gif differ diff --git a/Resources/public/images/other/nope.gif b/Resources/public/images/other/nope.gif index 232f475..f4da365 100644 Binary files a/Resources/public/images/other/nope.gif and b/Resources/public/images/other/nope.gif differ diff --git a/Resources/public/images/other/panda.gif b/Resources/public/images/other/panda.gif index 69fb5f8..8f6205e 100644 Binary files a/Resources/public/images/other/panda.gif and b/Resources/public/images/other/panda.gif differ diff --git a/Resources/public/images/other/pingou.gif b/Resources/public/images/other/pingou.gif index 6e2ae0f..a6fac15 100644 Binary files a/Resources/public/images/other/pingou.gif and b/Resources/public/images/other/pingou.gif differ diff --git a/Resources/public/images/other/plane.gif b/Resources/public/images/other/plane.gif index 34e1484..94803a1 100644 Binary files a/Resources/public/images/other/plane.gif and b/Resources/public/images/other/plane.gif differ diff --git a/Resources/public/images/other/pool.gif b/Resources/public/images/other/pool.gif index 9913bce..c7c1163 100644 Binary files a/Resources/public/images/other/pool.gif and b/Resources/public/images/other/pool.gif differ diff --git a/Resources/public/images/other/tupper.gif b/Resources/public/images/other/tupper.gif index 6c6f9f5..a956746 100644 Binary files a/Resources/public/images/other/tupper.gif and b/Resources/public/images/other/tupper.gif differ diff --git a/bin/optimizer.php b/bin/optimizer.php index 07b96a6..1773bf6 100755 --- a/bin/optimizer.php +++ b/bin/optimizer.php @@ -22,7 +22,7 @@ } $application = new Application('gifexception'); -$application->add(new GifOptimizerCommand()); +$application->addCommand(new GifOptimizerCommand()); $application ->setDefaultCommand('gifexception:optimize', true) ->run() diff --git a/tests/app/config/routing.php b/tests/app/config/routing.php index a6ad786..c34bb89 100644 --- a/tests/app/config/routing.php +++ b/tests/app/config/routing.php @@ -11,7 +11,7 @@ use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; -return function (RoutingConfigurator $routes): void { +return static function (RoutingConfigurator $routes): void { $routes->add('test_routing_error', '/error-{status}') ->requirements(['status' => '\d+']) ->defaults(['_controller' => 'Joli\GifExceptionBundle\Tests\app\src\TestController::errorAction'])