Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,28 @@ 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/
retention-days: 1

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
Expand Down Expand Up @@ -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/
Expand Down
3 changes: 3 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* This document has been generated with
* https://mlocati.github.io/php-cs-fixer-configurator/#version:3.1.0|configurator
Expand Down Expand Up @@ -224,6 +225,8 @@
'whitespace_after_comma_in_array' => 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()
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/Advanced/Canvas.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/Basic/Rotate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Filter/Transformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Gd/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/Gd/Imagine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/Gmagick/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Gmagick/Imagine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/Image/Box.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/Image/BoxInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Image/ImagineInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/Image/ManipulatorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Imagick/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/Imagick/Imagine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/Constraint/IsImageEqual.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/Filter/Advanced/CanvasTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion tests/tests/Gmagick/LayersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ public function testCount()

public function testWebpFormatIsAllowedAsAnimatedFormat()
{
$palette = new RGB();
$this->checkGmagickMockable();
Copy link
Contributor Author

@alexander-schranz alexander-schranz Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks this was missed in another PR to be checked. Added to fix some CI issue.

$resource = $this->getMockBuilder('\Gmagick')->getMock();

$palette = new RGB();

$resource->expects($this->atLeastOnce())
->method('getNumberImages')
->will($this->returnValue(42));
Expand Down
1 change: 1 addition & 0 deletions tests/tests/Image/Fill/Gradient/HorizontalTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* This file is part of the Imagine package.
*
Expand Down
1 change: 1 addition & 0 deletions tests/tests/Image/Fill/Gradient/VerticalTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* This file is part of the Imagine package.
*
Expand Down
16 changes: 6 additions & 10 deletions tests/tests/Imagick/LayersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,12 @@ public function testCount()

public function testWebpFormatIsAllowedAsAnimatedFormat()
{
$palette = new RGB();
$resource = $this->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()
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/ImagineTestCaseBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading