diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php index 3b162c29..849cbe73 100644 --- a/tests/BaseTestCase.php +++ b/tests/BaseTestCase.php @@ -16,17 +16,17 @@ use PHPUnit\Framework\ExpectationFailedException; abstract class BaseTestCase extends MockeryTestCase { - public static function getTestResourcePath($filename = 'test.jpg'): string + public static function getTestResourcePath(string $filename = 'test.jpg'): string { return sprintf('%s/resources/%s', __DIR__, $filename); } - public static function getTestResourceData($filename = 'test.jpg'): string + public static function getTestResourceData(string $filename = 'test.jpg'): string { return file_get_contents(self::getTestResourcePath($filename)); } - public static function getTestResourcePointer($filename = 'test.jpg') + public static function getTestResourcePointer(string $filename = 'test.jpg'): mixed { $pointer = fopen('php://temp', 'rw'); fwrite($pointer, self::getTestResourceData($filename)); @@ -39,9 +39,8 @@ abstract class BaseTestCase extends MockeryTestCase * Assert that given color equals the given color channel values in the given optional tolerance * * @throws ExpectationFailedException - * @return void */ - protected function assertColor(int $r, int $g, int $b, int $a, ColorInterface $color, int $tolerance = 0) + protected function assertColor(int $r, int $g, int $b, int $a, ColorInterface $color, int $tolerance = 0): void { // build errorMessage $errorMessage = function (int $r, int $g, $b, int $a, ColorInterface $color): string { @@ -90,7 +89,7 @@ abstract class BaseTestCase extends MockeryTestCase ); } - protected function assertTransparency(ColorInterface $color) + protected function assertTransparency(ColorInterface $color): void { $this->assertInstanceOf(RgbColor::class, $color); $channel = $color->channel(Alpha::class); diff --git a/tests/GdTestCase.php b/tests/GdTestCase.php index ebe98a01..559d8067 100644 --- a/tests/GdTestCase.php +++ b/tests/GdTestCase.php @@ -12,7 +12,7 @@ use Intervention\Image\Image; abstract class GdTestCase extends BaseTestCase { - public static function readTestImage($filename = 'test.jpg'): Image + public static function readTestImage(string $filename = 'test.jpg'): Image { return (new Driver())->specialize(new FilePathImageDecoder())->decode( static::getTestResourcePath($filename) diff --git a/tests/ImagickTestCase.php b/tests/ImagickTestCase.php index 6c4f8ecc..3055c1ff 100644 --- a/tests/ImagickTestCase.php +++ b/tests/ImagickTestCase.php @@ -14,7 +14,7 @@ use Intervention\Image\Image; abstract class ImagickTestCase extends BaseTestCase { - public static function readTestImage($filename = 'test.jpg'): Image + public static function readTestImage(string $filename = 'test.jpg'): Image { return (new Driver())->specialize(new FilePathImageDecoder())->decode( static::getTestResourcePath($filename) diff --git a/tests/Unit/Colors/Hsl/Decoders/StringColorDecoderTest.php b/tests/Unit/Colors/Hsl/Decoders/StringColorDecoderTest.php index 447ebd64..7a087835 100644 --- a/tests/Unit/Colors/Hsl/Decoders/StringColorDecoderTest.php +++ b/tests/Unit/Colors/Hsl/Decoders/StringColorDecoderTest.php @@ -14,6 +14,9 @@ use PHPUnit\Framework\Attributes\DataProvider; #[CoversClass(StringColorDecoder::class)] final class StringColorDecoderTest extends BaseTestCase { + /** + * @param $channelValues array + */ #[DataProvider('decodeDataProvier')] public function testDecode(string $input, string $classname, array $channelValues): void { diff --git a/tests/Unit/Colors/Hsv/Decoders/StringColorDecoderTest.php b/tests/Unit/Colors/Hsv/Decoders/StringColorDecoderTest.php index 34da0874..2bd49791 100644 --- a/tests/Unit/Colors/Hsv/Decoders/StringColorDecoderTest.php +++ b/tests/Unit/Colors/Hsv/Decoders/StringColorDecoderTest.php @@ -14,6 +14,9 @@ use PHPUnit\Framework\Attributes\DataProvider; #[CoversClass(StringColorDecoder::class)] final class StringColorDecoderTest extends BaseTestCase { + /** + * @param $channelValues array + */ #[DataProvider('decodeDataProvier')] public function testDecodeHsv(string $input, string $classname, array $channelValues): void { diff --git a/tests/Unit/Colors/Rgb/Decoders/HexColorDecoderTest.php b/tests/Unit/Colors/Rgb/Decoders/HexColorDecoderTest.php index 3d510f4e..ee060001 100644 --- a/tests/Unit/Colors/Rgb/Decoders/HexColorDecoderTest.php +++ b/tests/Unit/Colors/Rgb/Decoders/HexColorDecoderTest.php @@ -14,6 +14,9 @@ use PHPUnit\Framework\Attributes\DataProvider; #[CoversClass(HexColorDecoder::class)] final class HexColorDecoderTest extends BaseTestCase { + /** + * @param $channelValues array + */ #[DataProvider('decodeDataProvier')] public function testDecode(string $input, string $classname, array $channelValues): void { diff --git a/tests/Unit/Colors/Rgb/Decoders/HtmlColornameDecoderTest.php b/tests/Unit/Colors/Rgb/Decoders/HtmlColornameDecoderTest.php index ddb88f9f..74f1f088 100644 --- a/tests/Unit/Colors/Rgb/Decoders/HtmlColornameDecoderTest.php +++ b/tests/Unit/Colors/Rgb/Decoders/HtmlColornameDecoderTest.php @@ -14,6 +14,9 @@ use PHPUnit\Framework\Attributes\DataProvider; #[CoversClass(HtmlColorNameDecoder::class)] final class HtmlColornameDecoderTest extends BaseTestCase { + /** + * @param $channelValues array + */ #[DataProvider('decodeDataProvier')] public function testDecode(string $input, string $classname, array $channelValues): void { diff --git a/tests/Unit/Colors/Rgb/Decoders/StringColorDecoderTest.php b/tests/Unit/Colors/Rgb/Decoders/StringColorDecoderTest.php index 951406c8..ddb4edb3 100644 --- a/tests/Unit/Colors/Rgb/Decoders/StringColorDecoderTest.php +++ b/tests/Unit/Colors/Rgb/Decoders/StringColorDecoderTest.php @@ -14,6 +14,9 @@ use PHPUnit\Framework\Attributes\DataProvider; #[CoversClass(StringColorDecoder::class)] final class StringColorDecoderTest extends BaseTestCase { + /** + * @param $channelValues array + */ #[DataProvider('decodeDataProvier')] public function testDecode(string $input, string $classname, array $channelValues): void { diff --git a/tests/Unit/Drivers/Gd/DriverTest.php b/tests/Unit/Drivers/Gd/DriverTest.php index 174a5293..366653c5 100644 --- a/tests/Unit/Drivers/Gd/DriverTest.php +++ b/tests/Unit/Drivers/Gd/DriverTest.php @@ -45,7 +45,7 @@ final class DriverTest extends BaseTestCase public function testCreateAnimation(): void { - $image = $this->driver->createAnimation(function ($animation) { + $image = $this->driver->createAnimation(function ($animation): void { $animation->add($this->getTestResourcePath('red.gif'), .25); $animation->add($this->getTestResourcePath('green.gif'), .25); })->setLoops(5); diff --git a/tests/Unit/Drivers/Gd/Modifiers/TextModifierTest.php b/tests/Unit/Drivers/Gd/Modifiers/TextModifierTest.php index 3bd1f503..7f657e68 100644 --- a/tests/Unit/Drivers/Gd/Modifiers/TextModifierTest.php +++ b/tests/Unit/Drivers/Gd/Modifiers/TextModifierTest.php @@ -24,7 +24,7 @@ final class TextModifierTest extends GdTestCase $modifier = new class ('test', new Point(), $font) extends TextModifier { - public function test() + public function test(): ColorInterface { return $this->textColor(); } diff --git a/tests/Unit/Drivers/Imagick/DriverTest.php b/tests/Unit/Drivers/Imagick/DriverTest.php index 494b002b..f69a5056 100644 --- a/tests/Unit/Drivers/Imagick/DriverTest.php +++ b/tests/Unit/Drivers/Imagick/DriverTest.php @@ -45,7 +45,7 @@ final class DriverTest extends BaseTestCase public function testCreateAnimation(): void { - $image = $this->driver->createAnimation(function ($animation) { + $image = $this->driver->createAnimation(function ($animation): void { $animation->add($this->getTestResourcePath('red.gif'), .25); $animation->add($this->getTestResourcePath('green.gif'), .25); })->setLoops(5); diff --git a/tests/Unit/Drivers/Imagick/Modifiers/TextModifierTest.php b/tests/Unit/Drivers/Imagick/Modifiers/TextModifierTest.php index 232b6c3e..8de39300 100644 --- a/tests/Unit/Drivers/Imagick/Modifiers/TextModifierTest.php +++ b/tests/Unit/Drivers/Imagick/Modifiers/TextModifierTest.php @@ -24,7 +24,7 @@ final class TextModifierTest extends ImagickTestCase $modifier = new class ('test', new Point(), $font) extends TextModifier { - public function test() + public function test(): ColorInterface { return $this->textColor(); } diff --git a/tests/Unit/Encoders/FileExtensionEncoderTest.php b/tests/Unit/Encoders/FileExtensionEncoderTest.php index d44597be..89dc814b 100644 --- a/tests/Unit/Encoders/FileExtensionEncoderTest.php +++ b/tests/Unit/Encoders/FileExtensionEncoderTest.php @@ -25,16 +25,19 @@ use PHPUnit\Framework\Attributes\DataProvider; #[CoversClass(FileExtensionEncoder::class)] final class FileExtensionEncoderTest extends BaseTestCase { + /** + * @param $options array + */ private function testEncoder(string|FileExtension $extension, array $options = []): EncoderInterface { $encoder = new class ($extension, ...$options) extends FileExtensionEncoder { - public function __construct($mediaType, ...$options) + public function __construct(string|FileExtension $extension, mixed ...$options) { - parent::__construct($mediaType, ...$options); + parent::__construct($extension, ...$options); } - public function test($extension) + public function test(string|FileExtension $extension): EncoderInterface { return $this->encoderByFileExtension($extension); } diff --git a/tests/Unit/Encoders/MediaTypeEncoderTest.php b/tests/Unit/Encoders/MediaTypeEncoderTest.php index d78c38e7..563c48f2 100644 --- a/tests/Unit/Encoders/MediaTypeEncoderTest.php +++ b/tests/Unit/Encoders/MediaTypeEncoderTest.php @@ -25,16 +25,19 @@ use PHPUnit\Framework\Attributes\DataProvider; #[CoversClass(MediaTypeEncoder::class)] final class MediaTypeEncoderTest extends BaseTestCase { + /** + * @param $options array + */ private function testEncoder(string|MediaType $mediaType, array $options = []): EncoderInterface { $encoder = new class ($mediaType, ...$options) extends MediaTypeEncoder { - public function __construct($mediaType, ...$options) + public function __construct(string|MediaType $mediaType, mixed ...$options) { parent::__construct($mediaType, ...$options); } - public function test($mediaType) + public function test(string|MediaType $mediaType): EncoderInterface { return $this->encoderByMediaType($mediaType); } diff --git a/tests/Unit/Geometry/Factories/BezierFactoryTest.php b/tests/Unit/Geometry/Factories/BezierFactoryTest.php index 483dbda1..a0c599e6 100644 --- a/tests/Unit/Geometry/Factories/BezierFactoryTest.php +++ b/tests/Unit/Geometry/Factories/BezierFactoryTest.php @@ -14,7 +14,7 @@ final class BezierFactoryTest extends BaseTestCase { public function testFactoryCallback(): void { - $factory = new BezierFactory(function ($bezier) { + $factory = new BezierFactory(function ($bezier): void { $bezier->background('f00'); $bezier->border('ff0', 10); $bezier->point(300, 260); diff --git a/tests/Unit/Geometry/Factories/CircleFactoryTest.php b/tests/Unit/Geometry/Factories/CircleFactoryTest.php index 1a830f64..94663c39 100644 --- a/tests/Unit/Geometry/Factories/CircleFactoryTest.php +++ b/tests/Unit/Geometry/Factories/CircleFactoryTest.php @@ -15,7 +15,7 @@ final class CircleFactoryTest extends BaseTestCase { public function testFactoryCallback(): void { - $factory = new CircleFactory(new Point(1, 2), function ($circle) { + $factory = new CircleFactory(new Point(1, 2), function ($circle): void { $circle->background('fff'); $circle->border('ccc', 10); $circle->radius(100); diff --git a/tests/Unit/Geometry/Factories/EllipseFactoryTest.php b/tests/Unit/Geometry/Factories/EllipseFactoryTest.php index 0b9bb970..481011d3 100644 --- a/tests/Unit/Geometry/Factories/EllipseFactoryTest.php +++ b/tests/Unit/Geometry/Factories/EllipseFactoryTest.php @@ -15,7 +15,7 @@ final class EllipseFactoryTest extends BaseTestCase { public function testFactoryCallback(): void { - $factory = new EllipseFactory(new Point(1, 2), function ($ellipse) { + $factory = new EllipseFactory(new Point(1, 2), function ($ellipse): void { $ellipse->background('fff'); $ellipse->border('ccc', 10); $ellipse->width(100); diff --git a/tests/Unit/Geometry/Factories/LineFactoryTest.php b/tests/Unit/Geometry/Factories/LineFactoryTest.php index f3c3483c..7e96a5c7 100644 --- a/tests/Unit/Geometry/Factories/LineFactoryTest.php +++ b/tests/Unit/Geometry/Factories/LineFactoryTest.php @@ -14,7 +14,7 @@ final class LineFactoryTest extends BaseTestCase { public function testFactoryCallback(): void { - $factory = new LineFactory(function ($line) { + $factory = new LineFactory(function ($line): void { $line->color('fff'); $line->background('fff'); $line->border('fff', 10); diff --git a/tests/Unit/Geometry/Factories/PolygonFactoryTest.php b/tests/Unit/Geometry/Factories/PolygonFactoryTest.php index 284dc04f..f652aba5 100644 --- a/tests/Unit/Geometry/Factories/PolygonFactoryTest.php +++ b/tests/Unit/Geometry/Factories/PolygonFactoryTest.php @@ -14,7 +14,7 @@ final class PolygonFactoryTest extends BaseTestCase { public function testFactoryCallback(): void { - $factory = new PolygonFactory(function ($polygon) { + $factory = new PolygonFactory(function ($polygon): void { $polygon->background('fff'); $polygon->border('ccc', 10); $polygon->point(1, 2); diff --git a/tests/Unit/Geometry/Factories/RectangleFactoryTest.php b/tests/Unit/Geometry/Factories/RectangleFactoryTest.php index b14b3bb1..1b183ef8 100644 --- a/tests/Unit/Geometry/Factories/RectangleFactoryTest.php +++ b/tests/Unit/Geometry/Factories/RectangleFactoryTest.php @@ -15,7 +15,7 @@ final class RectangleFactoryTest extends BaseTestCase { public function testFactoryCallback(): void { - $factory = new RectangleFactory(new Point(1, 2), function ($rectangle) { + $factory = new RectangleFactory(new Point(1, 2), function ($rectangle): void { $rectangle->background('fff'); $rectangle->border('ccc', 10); $rectangle->width(100); diff --git a/tests/Unit/Geometry/RectangleResizerTest.php b/tests/Unit/Geometry/RectangleResizerTest.php index 66cb3117..ace8d48e 100644 --- a/tests/Unit/Geometry/RectangleResizerTest.php +++ b/tests/Unit/Geometry/RectangleResizerTest.php @@ -51,6 +51,9 @@ final class RectangleResizerTest extends TestCase $this->assertInstanceOf(RectangleResizer::class, $resizer); } + /** + * @param $resizeParameters array + */ #[DataProvider('resizeDataProvider')] public function testResize(Rectangle $input, array $resizeParameters, Rectangle $result): void { @@ -68,6 +71,9 @@ final class RectangleResizerTest extends TestCase yield [new Rectangle(300, 200), [], new Rectangle(300, 200)]; } + /** + * @param $resizeParameters array + */ #[DataProvider('resizeDownDataProvider')] public function testResizeDown(Rectangle $input, array $resizeParameters, Rectangle $result): void { @@ -88,6 +94,9 @@ final class RectangleResizerTest extends TestCase yield [new Rectangle(800, 600), [], new Rectangle(800, 600)]; } + /** + * @param $resizeParameters array + */ #[DataProvider('scaleDataProvider')] public function testScale(Rectangle $input, array $resizeParameters, Rectangle $result): void { @@ -119,6 +128,9 @@ final class RectangleResizerTest extends TestCase yield [new Rectangle(800, 600), [], new Rectangle(800, 600)]; } + /** + * @param $resizeParameters array + */ #[DataProvider('scaleDownDataProvider')] public function testScaleDown(Rectangle $input, array $resizeParameters, Rectangle $result): void { diff --git a/tests/Unit/ImageManagerTestGd.php b/tests/Unit/ImageManagerTestGd.php index 78352096..3a246d4b 100644 --- a/tests/Unit/ImageManagerTestGd.php +++ b/tests/Unit/ImageManagerTestGd.php @@ -58,7 +58,7 @@ final class ImageManagerTestGd extends BaseTestCase public function testAnimate(): void { $manager = new ImageManager(Driver::class); - $image = $manager->animate(function ($animation) { + $image = $manager->animate(function ($animation): void { $animation->add($this->getTestResourcePath('red.gif'), .25); }); $this->assertInstanceOf(ImageInterface::class, $image); diff --git a/tests/Unit/ImageManagerTestImagick.php b/tests/Unit/ImageManagerTestImagick.php index 422229b1..a3e392f6 100644 --- a/tests/Unit/ImageManagerTestImagick.php +++ b/tests/Unit/ImageManagerTestImagick.php @@ -58,7 +58,7 @@ final class ImageManagerTestImagick extends BaseTestCase public function testAnimate(): void { $manager = new ImageManager(Driver::class); - $image = $manager->animate(function ($animation) { + $image = $manager->animate(function ($animation): void { $animation->add($this->getTestResourcePath('red.gif'), .25); }); $this->assertInstanceOf(ImageInterface::class, $image); diff --git a/tests/Unit/Modifiers/TextModifierTest.php b/tests/Unit/Modifiers/TextModifierTest.php index a8d98916..241855fe 100644 --- a/tests/Unit/Modifiers/TextModifierTest.php +++ b/tests/Unit/Modifiers/TextModifierTest.php @@ -18,7 +18,10 @@ final class TextModifierTest extends BaseTestCase { $modifier = new class ('test', new Point(), new Font()) extends TextModifier { - public function testStrokeOffsets(FontInterface $font) + /** + * @return array + */ + public function testStrokeOffsets(FontInterface $font): array { return $this->strokeOffsets($font); } diff --git a/tests/Unit/Typography/FontFactoryTest.php b/tests/Unit/Typography/FontFactoryTest.php index 277bf399..626ba36e 100644 --- a/tests/Unit/Typography/FontFactoryTest.php +++ b/tests/Unit/Typography/FontFactoryTest.php @@ -24,7 +24,7 @@ final class FontFactoryTest extends BaseTestCase public function testBuildWithCallback(): void { - $factory = new FontFactory(function (FontFactory $font) { + $factory = new FontFactory(function (FontFactory $font): void { $font->filename($this->getTestResourcePath('test.ttf')); $font->color('#b01735'); $font->size(70);