Skip to content

Commit

Permalink
Fix PHP 8.4 deprecations nullable objects
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Dec 2, 2024
1 parent 8908a6c commit 8dfb1ba
Show file tree
Hide file tree
Showing 19 changed files with 22 additions and 17 deletions.
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
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
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
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

0 comments on commit 8dfb1ba

Please sign in to comment.