Skip to content

Conversation

@alexander-schranz
Copy link
Contributor

This should avoid outpus like:

Deprecated: Imagine\Image\ImagineInterface::create(): Implicitly marking parameter $color as nullable is deprecated, the explicit nullable type must be used instead in /sulu-develop.localhost/vendor/imagine/imagine/src/Image/ImagineInterface.php on line 36
PHP Deprecated: Imagine\Image\ManipulatorInterface::rotate(): Implicitly marking parameter $background as nullable is deprecated, the explicit nullable type must be used instead in /sulu-develop.localhost/vendor/imagine/imagine/src/Image/ManipulatorInterface.php on line 97

Deprecated: Imagine\Image\ManipulatorInterface::rotate(): Implicitly marking parameter $background as nullable is deprecated, the explicit nullable type must be used instead in /sulu-develop.localhost/vendor/imagine/imagine/src/Image/ManipulatorInterface.php on line 97
PHP Deprecated: FOS\RestBundle\Serializer\Normalizer\FormErrorHandler::serializeFormToXml(): Implicitly marking parameter $context as nullable is deprecated, the explicit nullable type must be used instead in /sulu-develop.localhost/vendor/friendsofsymfony/rest-bundle/Serializer/Normalizer/FormErrorHandler.php on line 42

@ausi
Copy link
Collaborator

ausi commented Dec 2, 2024

Nullable types are only supported since PHP 7.1.0 so we would need to increase the version constraint in

"php": ">=5.5"
I think.

@alexander-schranz
Copy link
Contributor Author

@mlocati should we increase min version?

@mlocati
Copy link
Collaborator

mlocati commented Dec 2, 2024

I think so. PHP 5 is very very outdated (but I'd keep compatibility with PHP 7)

@alexander-schranz
Copy link
Contributor Author

@mlocati adopted. Think the rest of the errors are unrelated and in some cases connected to: php-imagine/docker-builder#5

@mlocati
Copy link
Collaborator

mlocati commented Dec 3, 2024

in some cases connected to: php-imagine/docker-builder#5

I've just published all the docker images required for tests

@alexander-schranz alexander-schranz force-pushed the enhancement/php-84-deprecations branch from 4a5ef21 to 3704e6b Compare December 3, 2024 10:49
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.

@alexander-schranz
Copy link
Contributor Author

alexander-schranz commented Dec 3, 2024

Can somebody help me with:

1) Imagine\Test\Imagick\LayersTest::testWebpFormatIsAllowedAsAnimatedFormat
TypeError: Argument 1 passed to Imagine\Imagick\Image::__construct() must be an instance of Imagick, null given, called in /__w/Imagine/Imagine/src/Factory/ClassFactory.php on line 126

/__w/Imagine/Imagine/src/Imagick/Image.php:70
/__w/Imagine/Imagine/src/Factory/ClassFactory.php:126
/__w/Imagine/Imagine/src/Imagick/Layers.php:180
/__w/Imagine/Imagine/src/Imagick/Layers.php:163
/__w/Imagine/Imagine/src/Imagick/Layers.php:108
/__w/Imagine/Imagine/tests/tests/Imagick/LayersTest.php:97
phpvfscomposer:///__w/Imagine/Imagine/vendor/phpunit/phpunit/phpunit:97

public function testWebpFormatIsAllowedAsAnimatedFormat()

@mlocati
Copy link
Collaborator

mlocati commented Dec 3, 2024

TypeError: Argument 1 passed to Imagine\Imagick\Image::__construct() must be an instance of Imagick, null given, called in /__w/Imagine/Imagine/src/Factory/ClassFactory.php on line 126

I think the simplest solution is to avoid mocks.

Something like this:

    public function testWebpFormatIsAllowedAsAnimatedFormat()
    {
        $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);
    }

@ausi
Copy link
Collaborator

ausi commented Dec 3, 2024

My guess would be that ->getImage() returns null here

$this->layers[$offset] = $this->getClassFactory()->createImage(ClassFactoryInterface::HANDLE_IMAGICK, $this->resource->getImage(), $this->palette, new MetadataBag());
because the mock object does not know about the correct return type?

Maybe adding the following lines to the test might solve it:

$resource->expects($this->atLeastOnce())
    ->method('getImage')
    ->will($this->returnValue($resource));

@alexander-schranz
Copy link
Contributor Author

alexander-schranz commented Dec 3, 2024

Thank you both. I did go with the mockless solution looks the CI is now green 🎉

@mlocati
Copy link
Collaborator

mlocati commented Dec 3, 2024

Thank you!

@mlocati mlocati merged commit 01ccac9 into php-imagine:develop Dec 3, 2024
21 checks passed
@alexander-schranz alexander-schranz deleted the enhancement/php-84-deprecations branch December 3, 2024 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants