diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0ce56d4..8e2fa80 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,6 +24,10 @@ jobs: run: | composer install --no-progress + - name: Run PHPStan + run: | + make phpstan + - name: Run tests run: | make test diff --git a/Makefile b/Makefile index a360d44..a47b562 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ phpstan: - vendor/bin/phpstan analyse --level max src tests + vendor/bin/phpstan analyse -c phpstan.neon test: phpstan vendor/bin/phpunit --verbose diff --git a/composer.json b/composer.json index 5cf42d3..2da465d 100644 --- a/composer.json +++ b/composer.json @@ -8,8 +8,8 @@ "php": "^8.0" }, "require-dev": { - "phpunit/phpunit": "^8.5.8|^9.3.3", - "phpstan/phpstan": "^0.12" + "phpunit/phpunit": "^9.6", + "phpstan/phpstan": "^1.8" }, "autoload": { "psr-4": { diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..1494f51 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + level: max + paths: + - src + - tests diff --git a/src/Options/AbstractOption.php b/src/Options/AbstractOption.php index 5870c11..81d9a6c 100644 --- a/src/Options/AbstractOption.php +++ b/src/Options/AbstractOption.php @@ -44,9 +44,7 @@ abstract public function data(): array; */ public function value(): string { - $data = $this->data(); - - array_unshift($data, $this->name()); + $data = [$this->name(), ...$this->data()]; // Remove empty options from end. return rtrim(implode(':', $data), ':'); diff --git a/src/Options/AutoRotate.php b/src/Options/AutoRotate.php index 657af2d..65826a5 100644 --- a/src/Options/AutoRotate.php +++ b/src/Options/AutoRotate.php @@ -6,12 +6,9 @@ final class AutoRotate extends AbstractOption { - private bool $rotate; - - public function __construct(bool $rotate = true) - { - $this->rotate = $rotate; - } + public function __construct( + private bool $rotate = true, + ) {} /** * @inheritDoc diff --git a/src/Options/Blur.php b/src/Options/Blur.php index f56a3bf..73d444b 100644 --- a/src/Options/Blur.php +++ b/src/Options/Blur.php @@ -8,15 +8,13 @@ final class Blur extends AbstractOption { - private float $sigma; - - public function __construct(float $sigma) + public function __construct( + private float $sigma, + ) { if ($sigma < 0) { throw new InvalidArgumentException(sprintf('Invalid blur: %s', $sigma)); } - - $this->sigma = $sigma; } /** diff --git a/src/Options/CacheBuster.php b/src/Options/CacheBuster.php index 15c572b..6a3d320 100644 --- a/src/Options/CacheBuster.php +++ b/src/Options/CacheBuster.php @@ -8,15 +8,12 @@ final class CacheBuster extends AbstractOption { - private string $value; - - public function __construct(string $value) - { + public function __construct( + private string $value, + ) { if (empty($value)) { throw new InvalidArgumentException('Cache buster cannot be empty'); } - - $this->value = $value; } /** diff --git a/src/Options/Crop.php b/src/Options/Crop.php index 2b9eb0e..82c2c8d 100644 --- a/src/Options/Crop.php +++ b/src/Options/Crop.php @@ -8,7 +8,7 @@ final class Crop extends AbstractOption { private Width $width; private Height $height; - private ?Gravity $gravity = null; + private ?Gravity $gravity; public function __construct(int $width, int $height, Gravity|string|null $gravity = null) { diff --git a/src/Options/Dpr.php b/src/Options/Dpr.php index 80ced91..a601d69 100644 --- a/src/Options/Dpr.php +++ b/src/Options/Dpr.php @@ -8,15 +8,12 @@ final class Dpr extends AbstractOption { - private int $dpr; - - public function __construct(int $dpr) - { + public function __construct( + private int $dpr, + ) { if ($dpr <= 0) { throw new InvalidArgumentException(sprintf('Invalid dpr: %s', $dpr)); } - - $this->dpr = $dpr; } /** diff --git a/src/Options/EnforceThumbnail.php b/src/Options/EnforceThumbnail.php index 01567b2..fe76abe 100644 --- a/src/Options/EnforceThumbnail.php +++ b/src/Options/EnforceThumbnail.php @@ -6,12 +6,9 @@ final class EnforceThumbnail extends AbstractOption { - private ?string $format; - - public function __construct(?string $format = null) - { - $this->format = $format; - } + public function __construct( + private ?string $format = null, + ) {} /** * @inheritDoc diff --git a/src/Options/Enlarge.php b/src/Options/Enlarge.php index cfc1c41..baacdfd 100644 --- a/src/Options/Enlarge.php +++ b/src/Options/Enlarge.php @@ -6,12 +6,9 @@ final class Enlarge extends AbstractOption { - private bool $enlarge; - - public function __construct(bool $enlarge = true) - { - $this->enlarge = $enlarge; - } + public function __construct( + private bool $enlarge = true, + ) {} /** * @inheritDoc diff --git a/src/Options/Expires.php b/src/Options/Expires.php index 6f3691b..038b2f2 100644 --- a/src/Options/Expires.php +++ b/src/Options/Expires.php @@ -6,12 +6,9 @@ final class Expires extends AbstractOption { - private int $timestamp; - - public function __construct(int $timestamp) - { - $this->timestamp = $timestamp; - } + public function __construct( + private int $timestamp, + ) {} /** * @inheritDoc diff --git a/src/Options/Extend.php b/src/Options/Extend.php index bd530de..3868cb4 100644 --- a/src/Options/Extend.php +++ b/src/Options/Extend.php @@ -6,12 +6,13 @@ final class Extend extends AbstractOption { - private bool $extend; - private ?Gravity $gravity = null; + private ?Gravity $gravity; - public function __construct(bool $extend = true, Gravity|string|null $gravity = null) + public function __construct( + private bool $extend = true, + Gravity|string|null $gravity = null + ) { - $this->extend = $extend; $this->gravity = is_string($gravity) ? Gravity::fromString($gravity) : $gravity; } diff --git a/src/Options/Filename.php b/src/Options/Filename.php index efa1be6..9cf0fc3 100644 --- a/src/Options/Filename.php +++ b/src/Options/Filename.php @@ -8,15 +8,12 @@ final class Filename extends AbstractOption { - private string $name; - - public function __construct(string $name) - { + public function __construct( + private string $name, + ) { if (empty($name)) { throw new InvalidArgumentException('Filename cannot be empty'); } - - $this->name = $name; } /** diff --git a/src/Options/Flip.php b/src/Options/Flip.php new file mode 100644 index 0000000..72f4a37 --- /dev/null +++ b/src/Options/Flip.php @@ -0,0 +1,26 @@ +horizontal, + (int) $this->vertical, + ]; + } +} diff --git a/src/Options/Format.php b/src/Options/Format.php index 17213dd..b9db0f0 100644 --- a/src/Options/Format.php +++ b/src/Options/Format.php @@ -8,15 +8,12 @@ final class Format extends AbstractOption { - private string $extension; - - public function __construct(string $extension) - { + public function __construct( + private string $extension, + ) { if (empty($extension)) { throw new InvalidArgumentException('Format cannot be empty'); } - - $this->extension = $extension; } /** diff --git a/src/Options/FormatQuality.php b/src/Options/FormatQuality.php index 4e5f7f2..1f07a67 100644 --- a/src/Options/FormatQuality.php +++ b/src/Options/FormatQuality.php @@ -9,7 +9,7 @@ final class FormatQuality extends AbstractOption { /** - * @var array[] + * @var list */ private array $options = []; @@ -18,9 +18,8 @@ final class FormatQuality extends AbstractOption */ public function __construct(array $options) { - foreach ($options as $format => $quality) { - $data = (new Quality($quality))->data(); - $this->options[] = [$format, ...$data]; + foreach ($options as $format => $value) { + $this->options[] = [$format, (new Quality($value))->quality()]; } if (empty($this->options)) { diff --git a/src/Options/Gravity.php b/src/Options/Gravity.php index 2b16b63..257a222 100644 --- a/src/Options/Gravity.php +++ b/src/Options/Gravity.php @@ -10,15 +10,17 @@ final class Gravity extends AbstractOption { private GravityType $type; - private ?float $x; - private ?float $y; /** * @param string $type * @param float|null $x * @param float|null $y */ - public function __construct(string $type, ?float $x = null, ?float $y = null) + public function __construct( + string $type, + private ?float $x = null, + private ?float $y = null, + ) { $this->type = new GravityType($type); @@ -29,9 +31,6 @@ public function __construct(string $type, ?float $x = null, ?float $y = null) if ($y < 0) { throw new InvalidArgumentException(sprintf('Invalid gravity Y: %s', $y)); } - - $this->x = $x; - $this->y = $y; } /** diff --git a/src/Options/Height.php b/src/Options/Height.php index 172e45a..faff413 100644 --- a/src/Options/Height.php +++ b/src/Options/Height.php @@ -8,15 +8,12 @@ final class Height extends AbstractOption { - private int $height; - - public function __construct(int $height) - { + public function __construct( + private int $height, + ) { if ($height < 0) { throw new InvalidArgumentException(sprintf('Invalid height: %s', $height)); } - - $this->height = $height; } /** diff --git a/src/Options/KeepCopyright.php b/src/Options/KeepCopyright.php index 7830bf4..8d83068 100644 --- a/src/Options/KeepCopyright.php +++ b/src/Options/KeepCopyright.php @@ -6,12 +6,9 @@ final class KeepCopyright extends AbstractOption { - private bool $keep; - - public function __construct(bool $keep = true) - { - $this->keep = $keep; - } + public function __construct( + private bool $keep = true, + ) {} /** * @inheritDoc diff --git a/src/Options/MaxBytes.php b/src/Options/MaxBytes.php index 41bb2c8..bdb6ecb 100644 --- a/src/Options/MaxBytes.php +++ b/src/Options/MaxBytes.php @@ -8,15 +8,12 @@ final class MaxBytes extends AbstractOption { - private int $bytes; - - public function __construct(int $bytes) - { + public function __construct( + private int $bytes, + ) { if ($bytes < 0) { throw new InvalidArgumentException(sprintf('Invalid max bytes: %s', $bytes)); } - - $this->bytes = $bytes; } /** diff --git a/src/Options/Option.php b/src/Options/Option.php index 45ba4dd..7dfc2f0 100644 --- a/src/Options/Option.php +++ b/src/Options/Option.php @@ -6,21 +6,14 @@ final class Option extends AbstractOption { - private string $name; - /** - * @var array - */ - private array $data; - /** * @param string $name * @param array $data */ - public function __construct(string $name, array $data = []) - { - $this->name = $name; - $this->data = $data; - } + public function __construct( + private string $name, + private array $data = [], + ) {} /** * @inheritDoc diff --git a/src/Options/Padding.php b/src/Options/Padding.php index f423720..af919f6 100644 --- a/src/Options/Padding.php +++ b/src/Options/Padding.php @@ -8,21 +8,15 @@ final class Padding extends AbstractOption { - private ?int $top; - private ?int $right; - private ?int $bottom; - private ?int $left; - - public function __construct(?int $top = null, ?int $right = null, ?int $bottom = null, ?int $left = null) - { + public function __construct( + private ?int $top = null, + private ?int $right = null, + private ?int $bottom = null, + private ?int $left = null, + ) { if (is_null($top ?? $right ?? $bottom ?? $left)) { throw new InvalidArgumentException('At least one dimension must be set'); } - - $this->top = $top; - $this->right = $right; - $this->bottom = $bottom; - $this->left = $left; } /** diff --git a/src/Options/Pixelate.php b/src/Options/Pixelate.php new file mode 100644 index 0000000..e5fc719 --- /dev/null +++ b/src/Options/Pixelate.php @@ -0,0 +1,30 @@ +size, + ]; + } +} diff --git a/src/Options/Quality.php b/src/Options/Quality.php index aafc7bf..b63b952 100644 --- a/src/Options/Quality.php +++ b/src/Options/Quality.php @@ -8,15 +8,17 @@ final class Quality extends AbstractOption { - private int $quality; - - public function __construct(int $quality) - { + public function __construct( + public int $quality, + ) { if ($quality < 0 || $quality > 100) { throw new InvalidArgumentException(sprintf('Invalid quality: %s', $quality)); } + } - $this->quality = $quality; + public function quality(): int + { + return $this->quality; } /** diff --git a/src/Options/Raw.php b/src/Options/Raw.php index 88955d1..1271104 100644 --- a/src/Options/Raw.php +++ b/src/Options/Raw.php @@ -6,12 +6,9 @@ final class Raw extends AbstractOption { - private bool $raw; - - public function __construct(bool $raw = true) - { - $this->raw = $raw; - } + public function __construct( + private bool $raw = true, + ) {} /** * @inheritDoc diff --git a/src/Options/ResizingType.php b/src/Options/ResizingType.php index 1374c59..65be31b 100644 --- a/src/Options/ResizingType.php +++ b/src/Options/ResizingType.php @@ -24,15 +24,12 @@ final class ResizingType extends AbstractOption self::AUTO, ]; - private string $type; - - public function __construct(string $type) - { + public function __construct( + private string $type, + ) { if (!in_array($type, self::TYPES)) { throw new InvalidArgumentException(sprintf('Invalid resizing type: %s', $type)); } - - $this->type = $type; } /** diff --git a/src/Options/ReturnAttachment.php b/src/Options/ReturnAttachment.php index c2c79f6..b290799 100644 --- a/src/Options/ReturnAttachment.php +++ b/src/Options/ReturnAttachment.php @@ -6,12 +6,9 @@ final class ReturnAttachment extends AbstractOption { - private bool $value; - - public function __construct(bool $value = true) - { - $this->value = $value; - } + public function __construct( + private bool $value = true, + ) {} /** * @inheritDoc diff --git a/src/Options/Rotate.php b/src/Options/Rotate.php index 2b2194e..c23e16f 100644 --- a/src/Options/Rotate.php +++ b/src/Options/Rotate.php @@ -8,15 +8,12 @@ final class Rotate extends AbstractOption { - private int $angle; - - public function __construct(int $angle) - { + public function __construct( + private int $angle, + ) { if ($angle < 0 || $angle % 90 !== 0) { throw new InvalidArgumentException(sprintf('Invalid angle: %s', $angle)); } - - $this->angle = $angle; } /** diff --git a/src/Options/Sharpen.php b/src/Options/Sharpen.php index 57c7fe3..6e61dd0 100644 --- a/src/Options/Sharpen.php +++ b/src/Options/Sharpen.php @@ -8,15 +8,12 @@ final class Sharpen extends AbstractOption { - private float $sigma; - - public function __construct(float $sigma) - { + public function __construct( + private float $sigma, + ) { if ($sigma < 0) { throw new InvalidArgumentException(sprintf('Invalid sharpen: %s', $sigma)); } - - $this->sigma = $sigma; } /** diff --git a/src/Options/StripColorProfile.php b/src/Options/StripColorProfile.php index b5d2996..5551aa5 100644 --- a/src/Options/StripColorProfile.php +++ b/src/Options/StripColorProfile.php @@ -6,12 +6,9 @@ final class StripColorProfile extends AbstractOption { - private bool $strip; - - public function __construct(bool $strip = true) - { - $this->strip = $strip; - } + public function __construct( + private bool $strip = true, + ) {} /** * @inheritDoc diff --git a/src/Options/StripMetadata.php b/src/Options/StripMetadata.php index 7d6fab0..ee1b72b 100644 --- a/src/Options/StripMetadata.php +++ b/src/Options/StripMetadata.php @@ -6,12 +6,9 @@ final class StripMetadata extends AbstractOption { - private bool $strip; - - public function __construct(bool $strip = true) - { - $this->strip = $strip; - } + public function __construct( + private bool $strip = true, + ) {} /** * @inheritDoc diff --git a/src/Options/Width.php b/src/Options/Width.php index 09905e8..dd0e5fa 100644 --- a/src/Options/Width.php +++ b/src/Options/Width.php @@ -8,15 +8,12 @@ final class Width extends AbstractOption { - private int $width; - - public function __construct(int $width) - { + public function __construct( + private int $width, + ) { if ($width < 0) { throw new InvalidArgumentException(sprintf('Invalid width: %s', $width)); } - - $this->width = $width; } /** diff --git a/src/Options/Zoom.php b/src/Options/Zoom.php index 1a9860c..2cb8039 100644 --- a/src/Options/Zoom.php +++ b/src/Options/Zoom.php @@ -8,11 +8,10 @@ final class Zoom extends AbstractOption { - private float $x; - private ?float $y; - - public function __construct(float $x, ?float $y = null) - { + public function __construct( + private float $x, + private ?float $y = null, + ) { if ($x <= 0) { throw new InvalidArgumentException(sprintf('Invalid zoom X value: %s', $x)); } @@ -20,9 +19,6 @@ public function __construct(float $x, ?float $y = null) if ($y !== null && $y <= 0) { throw new InvalidArgumentException(sprintf('Invalid zoom Y value: %s', $y)); } - - $this->x = $x; - $this->y = $y; } /** diff --git a/src/Support/Color.php b/src/Support/Color.php index 818cba0..0f1f3c5 100644 --- a/src/Support/Color.php +++ b/src/Support/Color.php @@ -34,7 +34,7 @@ public static function fromHex(string $color): self } /** - * @param array $data + * @param array $data * * @return self */ diff --git a/src/Support/GravityType.php b/src/Support/GravityType.php index e1aaffc..355580e 100644 --- a/src/Support/GravityType.php +++ b/src/Support/GravityType.php @@ -36,22 +36,19 @@ class GravityType self::FOCUS_POINT, ]; - private string $type; - /** * @param string $type */ - public function __construct(string $type) - { + public function __construct( + private string $type, + ) { if (!in_array($type, self::TYPES)) { throw new InvalidArgumentException(sprintf('Invalid gravity: %s', $type)); } - - $this->type = $type; } /** - * @param array $data + * @param array $data * * @return self */ diff --git a/src/Support/ImageFormat.php b/src/Support/ImageFormat.php index e6a9f83..a5ab467 100644 --- a/src/Support/ImageFormat.php +++ b/src/Support/ImageFormat.php @@ -28,7 +28,7 @@ public function __construct(string $extension) } /** - * @param array $data + * @param array $data * * @return self */ diff --git a/src/UrlBuilder.php b/src/UrlBuilder.php index f2681e6..c1149eb 100644 --- a/src/UrlBuilder.php +++ b/src/UrlBuilder.php @@ -12,7 +12,6 @@ class UrlBuilder { private const INSECURE_SIGN = 'insecure'; - private ?UrlSigner $signer; private bool $encoded = true; private int $splitSize = 16; /** @@ -23,10 +22,9 @@ class UrlBuilder /** * @param UrlSigner|null $signer */ - public function __construct(?UrlSigner $signer = null) - { - $this->signer = $signer; - } + public function __construct( + private ?UrlSigner $signer = null, + ) {} /** * @param string $key @@ -50,7 +48,7 @@ public function options(): array /** * @param AbstractOption ...$options * - * @return $this + * @return self */ public function with(AbstractOption ...$options): self { @@ -63,7 +61,7 @@ public function with(AbstractOption ...$options): self /** * @param bool $encoded * - * @return $this + * @return self */ public function encoded(bool $encoded): self { diff --git a/tests/Options/AutoRotateTest.php b/tests/Options/AutoRotateTest.php index 208dd28..40b3f26 100644 --- a/tests/Options/AutoRotateTest.php +++ b/tests/Options/AutoRotateTest.php @@ -24,7 +24,7 @@ public function testCreateDefault(): void } /** - * @return array[] + * @return list */ public function exampleData(): array { diff --git a/tests/Options/BackgroundTest.php b/tests/Options/BackgroundTest.php index 77401c8..bdb67eb 100644 --- a/tests/Options/BackgroundTest.php +++ b/tests/Options/BackgroundTest.php @@ -31,7 +31,7 @@ public function testCreateFail(string $color): void } /** - * @return array[] + * @return list */ public function validData(): array { @@ -43,7 +43,7 @@ public function validData(): array } /** - * @return array[] + * @return list */ public function invalidData(): array { diff --git a/tests/Options/BlurTest.php b/tests/Options/BlurTest.php index 366c343..3ebbdcc 100644 --- a/tests/Options/BlurTest.php +++ b/tests/Options/BlurTest.php @@ -29,7 +29,7 @@ public function testCreateFail(float $sigma): void } /** - * @return array[] + * @return list */ public function validData(): array { @@ -42,7 +42,7 @@ public function validData(): array } /** - * @return array[] + * @return list */ public function invalidData(): array { diff --git a/tests/Options/CropTest.php b/tests/Options/CropTest.php index c6474f0..ae1b542 100644 --- a/tests/Options/CropTest.php +++ b/tests/Options/CropTest.php @@ -52,7 +52,7 @@ public function testCreateFailInvalidGravity(string $gravity, string $message): } /** - * @return array[] + * @return list */ public function validData(): array { @@ -70,7 +70,7 @@ public function validData(): array } /** - * @return array[] + * @return list */ public function invalidData(): array { @@ -81,7 +81,7 @@ public function invalidData(): array } /** - * @return array[] + * @return list */ public function invalidGravityData(): array { diff --git a/tests/Options/DprTest.php b/tests/Options/DprTest.php index d46b53d..9701c8b 100644 --- a/tests/Options/DprTest.php +++ b/tests/Options/DprTest.php @@ -29,7 +29,7 @@ public function testCreateFail(int $dpr): void } /** - * @return array[] + * @return list */ public function validData(): array { @@ -40,7 +40,7 @@ public function validData(): array } /** - * @return array[] + * @return list */ public function invalidData(): array { diff --git a/tests/Options/EnforceThumbnailTest.php b/tests/Options/EnforceThumbnailTest.php index 4d17e83..ab54f89 100644 --- a/tests/Options/EnforceThumbnailTest.php +++ b/tests/Options/EnforceThumbnailTest.php @@ -24,7 +24,7 @@ public function testCreateDefault(): void } /** - * @return array[] + * @return list */ public function exampleData(): array { diff --git a/tests/Options/EnlargeTest.php b/tests/Options/EnlargeTest.php index 43a262a..d14ed77 100644 --- a/tests/Options/EnlargeTest.php +++ b/tests/Options/EnlargeTest.php @@ -24,7 +24,7 @@ public function testCreateDefault(): void } /** - * @return array[] + * @return list */ public function exampleData(): array { diff --git a/tests/Options/ExpiresTest.php b/tests/Options/ExpiresTest.php index 69baf76..a496b5d 100644 --- a/tests/Options/ExpiresTest.php +++ b/tests/Options/ExpiresTest.php @@ -18,7 +18,7 @@ public function testCreate(int $timestamp, string $expected): void } /** - * @return array[] + * @return list */ public function exampleData(): array { diff --git a/tests/Options/ExtendAspectRatioTest.php b/tests/Options/ExtendAspectRatioTest.php index 016f2b3..8826ce1 100644 --- a/tests/Options/ExtendAspectRatioTest.php +++ b/tests/Options/ExtendAspectRatioTest.php @@ -35,7 +35,7 @@ public function testCreateFail(string $gravity, string $message): void } /** - * @return array[] + * @return list */ public function exampleData(): array { @@ -49,7 +49,7 @@ public function exampleData(): array } /** - * @return array[] + * @return list */ public function invalidGravityData(): array { diff --git a/tests/Options/ExtendTest.php b/tests/Options/ExtendTest.php index ef7803b..2d9b907 100644 --- a/tests/Options/ExtendTest.php +++ b/tests/Options/ExtendTest.php @@ -38,7 +38,7 @@ public function testCreateFail(string $gravity, string $message): void } /** - * @return array[] + * @return list */ public function exampleData(): array { @@ -54,7 +54,7 @@ public function exampleData(): array } /** - * @return array[] + * @return list */ public function invalidGravityData(): array { diff --git a/tests/Options/FlipTest.php b/tests/Options/FlipTest.php new file mode 100644 index 0000000..e474dd2 --- /dev/null +++ b/tests/Options/FlipTest.php @@ -0,0 +1,38 @@ +assertSame($expected, (string) $opt); + } + + public function testCreateDefault(): void + { + $opt = new Flip(); + $this->assertSame('fl:0:0', (string) $opt); + } + + /** + * @return list + */ + public function exampleData(): array + { + return [ + [true, true, 'fl:1:1'], + [true, false, 'fl:1:0'], + [false, true, 'fl:0:1'], + [false, false, 'fl:0:0'], + ]; + } +} diff --git a/tests/Options/FormatQualityTest.php b/tests/Options/FormatQualityTest.php index 791f7e1..959bfe6 100644 --- a/tests/Options/FormatQualityTest.php +++ b/tests/Options/FormatQualityTest.php @@ -39,7 +39,7 @@ public function testCreateFailEmptyOptions(): void } /** - * @return array[] + * @return list, string}> */ public function validData(): array { @@ -52,7 +52,7 @@ public function validData(): array } /** - * @return array[] + * @return list */ public function invalidData(): array { diff --git a/tests/Options/GravityTest.php b/tests/Options/GravityTest.php index d5ee149..6fc8dc6 100644 --- a/tests/Options/GravityTest.php +++ b/tests/Options/GravityTest.php @@ -76,7 +76,7 @@ public function testCreateFailInvalidOffsetY(float $y): void } /** - * @return array[] + * @return list */ public function validData(): array { @@ -91,7 +91,7 @@ public function validData(): array } /** - * @return array[] + * @return list */ public function validDataFromString(): array { @@ -105,7 +105,7 @@ public function validDataFromString(): array } /** - * @return array[] + * @return list */ public function invalidDataFromString(): array { @@ -117,7 +117,7 @@ public function invalidDataFromString(): array } /** - * @return array[] + * @return list */ public function invalidGravityType(): array { @@ -128,7 +128,7 @@ public function invalidGravityType(): array } /** - * @return array[] + * @return list */ public function invalidGravityOffset(): array { diff --git a/tests/Options/HeightTest.php b/tests/Options/HeightTest.php index c436ed8..2285fd6 100644 --- a/tests/Options/HeightTest.php +++ b/tests/Options/HeightTest.php @@ -31,7 +31,7 @@ public function testCreateFail(int $height): void } /** - * @return array[] + * @return list */ public function validData(): array { @@ -42,7 +42,7 @@ public function validData(): array } /** - * @return array[] + * @return list */ public function invalidData(): array { diff --git a/tests/Options/KeepCopyrightTest.php b/tests/Options/KeepCopyrightTest.php index 0310ec9..2dc332e 100644 --- a/tests/Options/KeepCopyrightTest.php +++ b/tests/Options/KeepCopyrightTest.php @@ -24,7 +24,7 @@ public function testCreateDefault(): void } /** - * @return array[] + * @return list */ public function exampleData(): array { diff --git a/tests/Options/MaxBytesTest.php b/tests/Options/MaxBytesTest.php index bf61bc9..d5a351e 100644 --- a/tests/Options/MaxBytesTest.php +++ b/tests/Options/MaxBytesTest.php @@ -29,7 +29,7 @@ public function testCreateFail(int $bytes): void } /** - * @return array[] + * @return list */ public function validData(): array { @@ -40,7 +40,7 @@ public function validData(): array } /** - * @return array[] + * @return list */ public function invalidData(): array { diff --git a/tests/Options/MinHeightTest.php b/tests/Options/MinHeightTest.php index e29df7a..f10fcc7 100644 --- a/tests/Options/MinHeightTest.php +++ b/tests/Options/MinHeightTest.php @@ -29,7 +29,7 @@ public function testCreateFail(int $height): void } /** - * @return array[] + * @return list */ public function validData(): array { @@ -40,7 +40,7 @@ public function validData(): array } /** - * @return array[] + * @return list */ public function invalidData(): array { diff --git a/tests/Options/MinWidthTest.php b/tests/Options/MinWidthTest.php index 2c0adf0..9232ae6 100644 --- a/tests/Options/MinWidthTest.php +++ b/tests/Options/MinWidthTest.php @@ -29,7 +29,7 @@ public function testCreateFail(int $width): void } /** - * @return array[] + * @return list */ public function validData(): array { @@ -40,7 +40,7 @@ public function validData(): array } /** - * @return array[] + * @return list */ public function invalidData(): array { diff --git a/tests/Options/OptionTest.php b/tests/Options/OptionTest.php index cfe4f89..6596e6e 100644 --- a/tests/Options/OptionTest.php +++ b/tests/Options/OptionTest.php @@ -22,7 +22,7 @@ public function testCreate(string $value, array $data, string $expected): void } /** - * @return array[] + * @return list, string}> */ public function exampleData(): array { diff --git a/tests/Options/PaddingTest.php b/tests/Options/PaddingTest.php index 6f7da20..53f1a14 100644 --- a/tests/Options/PaddingTest.php +++ b/tests/Options/PaddingTest.php @@ -26,7 +26,7 @@ public function testCreateFail(): void } /** - * @return array[] + * @return list */ public function validData(): array { diff --git a/tests/Options/PixelateTest.php b/tests/Options/PixelateTest.php new file mode 100644 index 0000000..5a2d0b7 --- /dev/null +++ b/tests/Options/PixelateTest.php @@ -0,0 +1,52 @@ +assertSame($expected, (string) $opt); + } + + /** + * @dataProvider invalidData + */ + public function testCreateFail(int $size): void + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage("Invalid size: $size"); + + new Pixelate($size); + } + + /** + * @return list + */ + public function validData(): array + { + return [ + [0, 'pix:0'], + [10, 'pix:10'], + ]; + } + + /** + * @return list + */ + public function invalidData(): array + { + return [ + [-1], + [-10], + ]; + } +} diff --git a/tests/Options/PresetTest.php b/tests/Options/PresetTest.php index 9d43f20..e715d1c 100644 --- a/tests/Options/PresetTest.php +++ b/tests/Options/PresetTest.php @@ -29,7 +29,7 @@ public function testCreateFail(): void } /** - * @return array[] + * @return list, string}> */ public function validData(): array { diff --git a/tests/Options/QualityTest.php b/tests/Options/QualityTest.php index 9ff840e..750d9d6 100644 --- a/tests/Options/QualityTest.php +++ b/tests/Options/QualityTest.php @@ -29,7 +29,7 @@ public function testCreateFail(int $quality): void } /** - * @return array[] + * @return list */ public function validData(): array { @@ -41,7 +41,7 @@ public function validData(): array } /** - * @return array[] + * @return list */ public function invalidData(): array { diff --git a/tests/Options/RawTest.php b/tests/Options/RawTest.php index 65154e5..9f19fb7 100644 --- a/tests/Options/RawTest.php +++ b/tests/Options/RawTest.php @@ -24,7 +24,7 @@ public function testCreateDefault(): void } /** - * @return array[] + * @return list */ public function exampleData(): array { diff --git a/tests/Options/ResizeTest.php b/tests/Options/ResizeTest.php index 72aa196..e38a64c 100644 --- a/tests/Options/ResizeTest.php +++ b/tests/Options/ResizeTest.php @@ -45,7 +45,14 @@ public function testCreateFailInvalidHeight(): void } /** - * @return array[] + * @return list */ public function validData(): array { @@ -66,7 +73,7 @@ public function validData(): array } /** - * @return array[] + * @return list */ public function invalidResizingType(): array { diff --git a/tests/Options/ResizingTypeTest.php b/tests/Options/ResizingTypeTest.php index 9a4fe10..675787f 100644 --- a/tests/Options/ResizingTypeTest.php +++ b/tests/Options/ResizingTypeTest.php @@ -29,7 +29,7 @@ public function testCreateFail(string $type): void } /** - * @return array[] + * @return list */ public function validData(): array { @@ -43,7 +43,7 @@ public function validData(): array } /** - * @return array[] + * @return list */ public function invalidData(): array { diff --git a/tests/Options/ReturnAttachmentTest.php b/tests/Options/ReturnAttachmentTest.php index 636582f..0aff0d3 100644 --- a/tests/Options/ReturnAttachmentTest.php +++ b/tests/Options/ReturnAttachmentTest.php @@ -24,7 +24,7 @@ public function testCreateDefault(): void } /** - * @return array[] + * @return list */ public function exampleData(): array { diff --git a/tests/Options/RotateTest.php b/tests/Options/RotateTest.php index a82a9d8..40a12f6 100644 --- a/tests/Options/RotateTest.php +++ b/tests/Options/RotateTest.php @@ -29,7 +29,7 @@ public function testCreateFail(int $angle): void } /** - * @return array[] + * @return list */ public function validData(): array { @@ -43,7 +43,7 @@ public function validData(): array } /** - * @return array[] + * @return list */ public function invalidData(): array { diff --git a/tests/Options/SharpenTest.php b/tests/Options/SharpenTest.php index eb35e31..3e7b2bd 100644 --- a/tests/Options/SharpenTest.php +++ b/tests/Options/SharpenTest.php @@ -29,7 +29,7 @@ public function testCreateFail(int $sigma): void } /** - * @return array[] + * @return list */ public function validData(): array { @@ -40,7 +40,7 @@ public function validData(): array } /** - * @return array[] + * @return list */ public function invalidData(): array { diff --git a/tests/Options/SizeTest.php b/tests/Options/SizeTest.php index af149a8..c03afdb 100644 --- a/tests/Options/SizeTest.php +++ b/tests/Options/SizeTest.php @@ -37,7 +37,13 @@ public function testCreateFailInvalidData(?int $width, ?int $height, string $mes } /** - * @return array[] + * @return list */ public function validData(): array { @@ -54,7 +60,7 @@ public function validData(): array } /** - * @return array[] + * @return list */ public function invalidData(): array { diff --git a/tests/Options/SkipProcessingTest.php b/tests/Options/SkipProcessingTest.php index 6bb927c..d8b7352 100644 --- a/tests/Options/SkipProcessingTest.php +++ b/tests/Options/SkipProcessingTest.php @@ -29,7 +29,7 @@ public function testCreateFail(): void } /** - * @return array[] + * @return list, string}> */ public function exampleData(): array { diff --git a/tests/Options/StripColorProfileTest.php b/tests/Options/StripColorProfileTest.php index 32bd256..7624209 100644 --- a/tests/Options/StripColorProfileTest.php +++ b/tests/Options/StripColorProfileTest.php @@ -24,7 +24,7 @@ public function testCreateDefault(): void } /** - * @return array[] + * @return list */ public function exampleData(): array { diff --git a/tests/Options/StripMetadataTest.php b/tests/Options/StripMetadataTest.php index 444ee6e..4246e1d 100644 --- a/tests/Options/StripMetadataTest.php +++ b/tests/Options/StripMetadataTest.php @@ -24,7 +24,7 @@ public function testCreateDefault(): void } /** - * @return array[] + * @return list */ public function exampleData(): array { diff --git a/tests/Options/TrimTest.php b/tests/Options/TrimTest.php index f1db295..a14f6b8 100644 --- a/tests/Options/TrimTest.php +++ b/tests/Options/TrimTest.php @@ -40,7 +40,7 @@ public function testCreateFailInvalidThreshold(float $threshold): void } /** - * @return array[] + * @return list */ public function validData(): array { @@ -53,7 +53,7 @@ public function validData(): array } /** - * @return array[] + * @return list */ public function invalidColorData(): array { @@ -65,7 +65,7 @@ public function invalidColorData(): array } /** - * @return array[] + * @return list */ public function invalidThresholdData(): array { diff --git a/tests/Options/WatermarkTest.php b/tests/Options/WatermarkTest.php index 4886d07..0bc019e 100644 --- a/tests/Options/WatermarkTest.php +++ b/tests/Options/WatermarkTest.php @@ -56,7 +56,7 @@ public function testCreateFailInvalidScale(): void } /** - * @return array[] + * @return list */ public function validData(): array { @@ -69,7 +69,7 @@ public function validData(): array } /** - * @return array[] + * @return list */ public function validPositions(): array { @@ -88,7 +88,7 @@ public function validPositions(): array } /** - * @return array[] + * @return list */ public function invalidOpacityData(): array { diff --git a/tests/Options/WidthTest.php b/tests/Options/WidthTest.php index 4c3ddc1..c15e910 100644 --- a/tests/Options/WidthTest.php +++ b/tests/Options/WidthTest.php @@ -31,7 +31,7 @@ public function testCreateFail(int $width): void } /** - * @return array[] + * @return list */ public function validData(): array { @@ -42,7 +42,7 @@ public function validData(): array } /** - * @return array[] + * @return list */ public function invalidData(): array { diff --git a/tests/Options/ZoomTest.php b/tests/Options/ZoomTest.php index 81e283b..a74d112 100644 --- a/tests/Options/ZoomTest.php +++ b/tests/Options/ZoomTest.php @@ -44,7 +44,7 @@ public function testCreateFailInvalidYZoom(float $x): void } /** - * @return array[] + * @return list */ public function validData(): array { @@ -57,7 +57,7 @@ public function validData(): array } /** - * @return array[] + * @return list */ public function invalidData(): array { diff --git a/tests/UrlBuilderTest.php b/tests/UrlBuilderTest.php index 0eb9da9..83d7630 100644 --- a/tests/UrlBuilderTest.php +++ b/tests/UrlBuilderTest.php @@ -71,7 +71,7 @@ public function testSplitSize(): void } /** - * @return array[] + * @return list> */ public function signedData(): array { @@ -125,7 +125,7 @@ public function signedData(): array } /** - * @return array[] + * @return list> */ public function unsignedData(): array {