diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 552b3ad8e..50100fb74 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -71,7 +71,7 @@ jobs: run: composer run test --ansi --no-interaction -- --exclude-group "${{ steps.inspect.outputs.excluded-groups }}" - name: Save tests temporary files if: always() && env.IMAGINE_TEST_KEEP_TEMPFILES == 'yes' - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: windows-${{ matrix.php-version }}-${{ matrix.extensions }} path: tests/tmp/ @@ -79,20 +79,20 @@ jobs: docker: name: PHP ${{ matrix.php-version }} - ${{ matrix.image-suffix }} (Docker) - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: php-version: - - "5.5" - - "5.6" - - "7.0" - "7.1" - "7.2" - "7.3" - "7.4" - "8.0" - "8.1" + - "8.2" + - "8.3" + - "8.4" image-suffix: - gd-gmagick - gd-imagick @@ -129,7 +129,7 @@ jobs: run: composer run test --ansi --no-interaction -- --exclude-group "${{ steps.inspect.outputs.excluded-groups }}" - name: Save tests temporary files if: always() && env.IMAGINE_TEST_KEEP_TEMPFILES == 'yes' - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: docker-${{ matrix.php-version }}-${{ matrix.image-suffix }} path: tests/tmp/ diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index ac6ed8e48..77f455b86 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -1,4 +1,5 @@ true, // Write conditions in Yoda style (`true`), non-Yoda style (`['equal' => false, 'identical' => false, 'less_and_greater' => false]`) or ignore those conditions (`null`) based on configuration. 'yoda_style' => array('always_move_variable' => false, 'equal' => false, 'identical' => false, 'less_and_greater' => false), + // Make type definition of default null also nullable to avoid PHP 8.4 deprecations + 'nullable_type_declaration_for_default_null_value' => true, )) ->setFinder( PhpCsFixer\Finder::create() diff --git a/README.md b/README.md index a824a5213..cfb85b181 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,12 @@ libraries. The Imagine library has the following requirements: - - PHP 5.5+ + - PHP 7.1+ + +Older version of the library support also older PHP Version: + + - PHP 5.5 - 7.0 use version ^1.3 + - PHP 5.3 - 5.4 use version ^1.2 Depending on the chosen Image implementation, you may need one of the following PHP extensions: diff --git a/composer.json b/composer.json index 37e02b3be..2e47c0639 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ } ], "require": { - "php": ">=5.5" + "php": ">=7.1" }, "require-dev": { "phpunit/phpunit": "^4.8 || ^5.7 || ^6.5 || ^7.5 || ^8.4 || ^9.3" diff --git a/src/Filter/Advanced/Canvas.php b/src/Filter/Advanced/Canvas.php index f8a98610f..ea04bf91e 100644 --- a/src/Filter/Advanced/Canvas.php +++ b/src/Filter/Advanced/Canvas.php @@ -52,7 +52,7 @@ class Canvas implements FilterInterface * @param \Imagine\Image\PointInterface $placement * @param \Imagine\Image\Palette\Color\ColorInterface $background */ - public function __construct(ImagineInterface $imagine, BoxInterface $size, PointInterface $placement = null, ColorInterface $background = null) + public function __construct(ImagineInterface $imagine, BoxInterface $size, ?PointInterface $placement = null, ?ColorInterface $background = null) { $this->imagine = $imagine; $this->size = $size; diff --git a/src/Filter/Basic/Rotate.php b/src/Filter/Basic/Rotate.php index 9992a8f00..96bbdff6b 100644 --- a/src/Filter/Basic/Rotate.php +++ b/src/Filter/Basic/Rotate.php @@ -36,7 +36,7 @@ class Rotate implements FilterInterface * @param int $angle * @param \Imagine\Image\Palette\Color\ColorInterface $background */ - public function __construct($angle, ColorInterface $background = null) + public function __construct($angle, ?ColorInterface $background = null) { $this->angle = $angle; $this->background = $background; diff --git a/src/Filter/Transformation.php b/src/Filter/Transformation.php index b7861d017..763651e0e 100644 --- a/src/Filter/Transformation.php +++ b/src/Filter/Transformation.php @@ -60,7 +60,7 @@ final class Transformation implements FilterInterface, ManipulatorInterface * * @param \Imagine\Image\ImageInterface|null $imagine An ImagineInterface instance */ - public function __construct(ImagineInterface $imagine = null) + public function __construct(?ImagineInterface $imagine = null) { $this->imagine = $imagine; } @@ -215,7 +215,7 @@ public function resize(BoxInterface $size, $filter = ImageInterface::FILTER_UNDE * * @see \Imagine\Image\ManipulatorInterface::rotate() */ - public function rotate($angle, ColorInterface $background = null) + public function rotate($angle, ?ColorInterface $background = null) { return $this->add(new Rotate($angle, $background)); } diff --git a/src/Gd/Image.php b/src/Gd/Image.php index 6c9d21d61..e418576e4 100644 --- a/src/Gd/Image.php +++ b/src/Gd/Image.php @@ -239,7 +239,7 @@ final public function resize(BoxInterface $size, $filter = ImageInterface::FILTE * * @see \Imagine\Image\ManipulatorInterface::rotate() */ - final public function rotate($angle, ColorInterface $background = null) + final public function rotate($angle, ?ColorInterface $background = null) { if ($background === null) { $background = $this->palette->color('fff'); diff --git a/src/Gd/Imagine.php b/src/Gd/Imagine.php index bcb9a2fd7..bae32743d 100644 --- a/src/Gd/Imagine.php +++ b/src/Gd/Imagine.php @@ -55,7 +55,7 @@ public static function getDriverInfo($required = true) * * @see \Imagine\Image\ImagineInterface::create() */ - public function create(BoxInterface $size, ColorInterface $color = null) + public function create(BoxInterface $size, ?ColorInterface $color = null) { $width = $size->getWidth(); $height = $size->getHeight(); diff --git a/src/Gmagick/Image.php b/src/Gmagick/Image.php index 0ef178302..e67d46f38 100644 --- a/src/Gmagick/Image.php +++ b/src/Gmagick/Image.php @@ -275,7 +275,7 @@ public function resize(BoxInterface $size, $filter = ImageInterface::FILTER_UNDE * * @see \Imagine\Image\ManipulatorInterface::rotate() */ - public function rotate($angle, ColorInterface $background = null) + public function rotate($angle, ?ColorInterface $background = null) { try { if ($background === null) { diff --git a/src/Gmagick/Imagine.php b/src/Gmagick/Imagine.php index d1159b13f..dfaae804b 100644 --- a/src/Gmagick/Imagine.php +++ b/src/Gmagick/Imagine.php @@ -81,7 +81,7 @@ public function open($path) * * @see \Imagine\Image\ImagineInterface::create() */ - public function create(BoxInterface $size, ColorInterface $color = null) + public function create(BoxInterface $size, ?ColorInterface $color = null) { $width = $size->getWidth(); $height = $size->getHeight(); diff --git a/src/Image/Box.php b/src/Image/Box.php index fee2fdef3..b8ba74652 100644 --- a/src/Image/Box.php +++ b/src/Image/Box.php @@ -99,7 +99,7 @@ public function increase($size) * * @see \Imagine\Image\BoxInterface::contains() */ - public function contains(BoxInterface $box, PointInterface $start = null) + public function contains(BoxInterface $box, ?PointInterface $start = null) { $start = $start ? $start : new Point(0, 0); diff --git a/src/Image/BoxInterface.php b/src/Image/BoxInterface.php index b963777a5..a882ab876 100644 --- a/src/Image/BoxInterface.php +++ b/src/Image/BoxInterface.php @@ -57,7 +57,7 @@ public function increase($size); * * @return bool */ - public function contains(BoxInterface $box, PointInterface $start = null); + public function contains(BoxInterface $box, ?PointInterface $start = null); /** * Gets current box square, useful for getting total number of pixels in a diff --git a/src/Image/ImagineInterface.php b/src/Image/ImagineInterface.php index 7a41cee4e..ab0b07cfd 100644 --- a/src/Image/ImagineInterface.php +++ b/src/Image/ImagineInterface.php @@ -33,7 +33,7 @@ interface ImagineInterface extends ClassFactoryAwareInterface * * @return \Imagine\Image\ImageInterface */ - public function create(BoxInterface $size, ColorInterface $color = null); + public function create(BoxInterface $size, ?ColorInterface $color = null); /** * Opens an existing image from $path. diff --git a/src/Image/ManipulatorInterface.php b/src/Image/ManipulatorInterface.php index 23f033fbb..f889a20c9 100644 --- a/src/Image/ManipulatorInterface.php +++ b/src/Image/ManipulatorInterface.php @@ -94,7 +94,7 @@ public function resize(BoxInterface $size, $filter = ImageInterface::FILTER_UNDE * * @return $this */ - public function rotate($angle, ColorInterface $background = null); + public function rotate($angle, ?ColorInterface $background = null); /** * Pastes an image into a parent image diff --git a/src/Imagick/Image.php b/src/Imagick/Image.php index 98435ceb0..bab72106d 100644 --- a/src/Imagick/Image.php +++ b/src/Imagick/Image.php @@ -305,7 +305,7 @@ public function resize(BoxInterface $size, $filter = ImageInterface::FILTER_UNDE * * @see \Imagine\Image\ManipulatorInterface::rotate() */ - public function rotate($angle, ColorInterface $background = null) + public function rotate($angle, ?ColorInterface $background = null) { if ($background === null) { $background = $this->palette->color('fff'); diff --git a/src/Imagick/Imagine.php b/src/Imagick/Imagine.php index 0bb36ba66..e63b67f21 100644 --- a/src/Imagick/Imagine.php +++ b/src/Imagick/Imagine.php @@ -88,7 +88,7 @@ public function open($path) * * @see \Imagine\Image\ImagineInterface::create() */ - public function create(BoxInterface $size, ColorInterface $color = null) + public function create(BoxInterface $size, ?ColorInterface $color = null) { $width = $size->getWidth(); $height = $size->getHeight(); diff --git a/tests/tests/Constraint/IsImageEqual.php b/tests/tests/Constraint/IsImageEqual.php index 5e5d7adac..224188256 100644 --- a/tests/tests/Constraint/IsImageEqual.php +++ b/tests/tests/Constraint/IsImageEqual.php @@ -59,7 +59,7 @@ class IsImageEqual extends Constraint * * @throws \InvalidArgumentException */ - public function __construct($expected, $delta = 0.1, ImagineInterface $imagine = null, $buckets = 4) + public function __construct($expected, $delta = 0.1, ?ImagineInterface $imagine = null, $buckets = 4) { parent::__construct(); $this->imagine = $imagine; diff --git a/tests/tests/Filter/Advanced/CanvasTest.php b/tests/tests/Filter/Advanced/CanvasTest.php index fdd7f4742..f3ac3a7b3 100644 --- a/tests/tests/Filter/Advanced/CanvasTest.php +++ b/tests/tests/Filter/Advanced/CanvasTest.php @@ -30,7 +30,7 @@ class CanvasTest extends FilterTestCase * @param PointInterface $placement * @param ColorInterface $background */ - public function testShouldCanvasImageAndReturnResult(BoxInterface $size, PointInterface $placement = null, ColorInterface $background = null) + public function testShouldCanvasImageAndReturnResult(BoxInterface $size, ?PointInterface $placement = null, ?ColorInterface $background = null) { $placement = $placement ?: new Point(0, 0); $image = $this->getImage(); diff --git a/tests/tests/Gmagick/LayersTest.php b/tests/tests/Gmagick/LayersTest.php index c9eab4ebe..189fdd306 100644 --- a/tests/tests/Gmagick/LayersTest.php +++ b/tests/tests/Gmagick/LayersTest.php @@ -86,9 +86,11 @@ public function testCount() public function testWebpFormatIsAllowedAsAnimatedFormat() { - $palette = new RGB(); + $this->checkGmagickMockable(); $resource = $this->getMockBuilder('\Gmagick')->getMock(); + $palette = new RGB(); + $resource->expects($this->atLeastOnce()) ->method('getNumberImages') ->will($this->returnValue(42)); diff --git a/tests/tests/Image/Fill/Gradient/HorizontalTest.php b/tests/tests/Image/Fill/Gradient/HorizontalTest.php index e6b02af95..53949f7e4 100644 --- a/tests/tests/Image/Fill/Gradient/HorizontalTest.php +++ b/tests/tests/Image/Fill/Gradient/HorizontalTest.php @@ -1,4 +1,5 @@ getMockBuilder('\Imagick')->getMock(); - - $resource->expects($this->atLeastOnce()) - ->method('getNumberImages') - ->will($this->returnValue(42)); - - $layers = new Layers(new Image($resource, $palette, new MetadataBag()), $palette, $resource); - - $layers->animate('webp', 200, 0); + $image = $this->getImagine()->open(IMAGINE_TEST_FIXTURESFOLDER . '/anima3.gif'); + $originalDelayInTicks = $image->layers()->get(0)->getImagick()->getImageDelay(); + $image->layers()->animate('webp', (int) (1000 + $originalDelayInTicks * 1000 / 20), 0); + $this->assertSame('webp', $image->getImagick()->getFormat()); + $newDelayInTicks = $image->layers()->get(0)->getImagick()->getImageDelay(); + $this->assertNotEquals($originalDelayInTicks, $newDelayInTicks); } public function testGetLayer() diff --git a/tests/tests/ImagineTestCaseBase.php b/tests/tests/ImagineTestCaseBase.php index afe26b04e..322ebdb13 100644 --- a/tests/tests/ImagineTestCaseBase.php +++ b/tests/tests/ImagineTestCaseBase.php @@ -37,7 +37,7 @@ abstract class ImagineTestCaseBase extends \PHPUnit\Framework\TestCase * @param \Imagine\Image\ImagineInterface|null $imagine * @param int $buckets */ - public static function assertImageEquals($expected, $actual, $message = '', $delta = 0.1, ImagineInterface $imagine = null, $buckets = 4) + public static function assertImageEquals($expected, $actual, $message = '', $delta = 0.1, ?ImagineInterface $imagine = null, $buckets = 4) { $constraint = new IsImageEqual($expected, $delta, $imagine, $buckets);