diff --git a/phpstan.dist.neon b/phpstan.dist.neon index 61893095..9a6d4ace 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -6,14 +6,8 @@ parameters: check: missingCheckedExceptionInThrows: true uncheckedExceptionClasses: - - Intervention\Image\Exceptions\AnimationException - Intervention\Image\Exceptions\ColorException - - Intervention\Image\Exceptions\DriverException - - Intervention\Image\Exceptions\GeometryException - - Intervention\Image\Exceptions\FontException - - Intervention\Image\Exceptions\InputException - Intervention\Image\Exceptions\NotSupportedException - - Intervention\Image\Exceptions\NotWritableException - ImagickException - ImagickDrawException - ImagickPixelException diff --git a/src/Drivers/AbstractDecoder.php b/src/Drivers/AbstractDecoder.php index 70ef7dfe..b376849f 100644 --- a/src/Drivers/AbstractDecoder.php +++ b/src/Drivers/AbstractDecoder.php @@ -7,6 +7,7 @@ namespace Intervention\Image\Drivers; use Exception; use Intervention\Image\Collection; use Intervention\Image\Exceptions\DecoderException; +use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Interfaces\CollectionInterface; use Intervention\Image\Interfaces\ColorInterface; use Intervention\Image\Interfaces\DecoderInterface; @@ -25,7 +26,7 @@ abstract class AbstractDecoder extends DriverSpecialized implements DecoderInter * Try to decode given input to image or color object * * @param mixed $input - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface|ColorInterface */ final public function handle(mixed $input): ImageInterface|ColorInterface diff --git a/src/Drivers/AbstractDrawModifier.php b/src/Drivers/AbstractDrawModifier.php index 411113b1..3a9f0c64 100644 --- a/src/Drivers/AbstractDrawModifier.php +++ b/src/Drivers/AbstractDrawModifier.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Intervention\Image\Drivers; use Intervention\Image\Exceptions\DecoderException; +use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Interfaces\ColorInterface; use Intervention\Image\Interfaces\DrawableInterface; use Intervention\Image\Interfaces\ModifierInterface; @@ -21,7 +22,7 @@ abstract class AbstractDrawModifier extends DriverSpecialized implements Modifie } /** - * @throws DecoderException + * @throws RuntimeException */ public function backgroundColor(): ColorInterface { @@ -35,7 +36,7 @@ abstract class AbstractDrawModifier extends DriverSpecialized implements Modifie } /** - * @throws DecoderException + * @throws RuntimeException */ public function borderColor(): ColorInterface { diff --git a/src/Drivers/AbstractDriver.php b/src/Drivers/AbstractDriver.php index 9428c63f..f2b07211 100644 --- a/src/Drivers/AbstractDriver.php +++ b/src/Drivers/AbstractDriver.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Drivers; +use Intervention\Image\Exceptions\DriverException; use Intervention\Image\Exceptions\NotSupportedException; use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Interfaces\AnalyzerInterface; @@ -16,6 +17,9 @@ use ReflectionClass; abstract class AbstractDriver implements DriverInterface { + /** + * @throws DriverException + */ public function __construct() { $this->checkHealth(); diff --git a/src/Drivers/AbstractFontProcessor.php b/src/Drivers/AbstractFontProcessor.php index 2ab7c35b..33a04524 100644 --- a/src/Drivers/AbstractFontProcessor.php +++ b/src/Drivers/AbstractFontProcessor.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Drivers; +use Intervention\Image\Exceptions\FontException; use Intervention\Image\Geometry\Point; use Intervention\Image\Geometry\Rectangle; use Intervention\Image\Interfaces\FontInterface; @@ -90,6 +91,7 @@ abstract class AbstractFontProcessor implements FontProcessorInterface * * @param TextBlock $block * @param FontInterface $font + * @throws FontException * @return TextBlock */ protected function wrapTextBlock(TextBlock $block, FontInterface $font): TextBlock @@ -111,6 +113,7 @@ abstract class AbstractFontProcessor implements FontProcessorInterface * * @param Line $line * @param FontInterface $font + * @throws FontException * @return array */ protected function wrapLine(Line $line, FontInterface $font): array @@ -152,6 +155,7 @@ abstract class AbstractFontProcessor implements FontProcessorInterface * @param TextBlock $block * @param FontInterface $font * @param PointInterface $position + * @throws FontException * @return PointInterface */ protected function buildPivot(TextBlock $block, FontInterface $font, PointInterface $position): PointInterface diff --git a/src/Drivers/Gd/Analyzers/PixelColorAnalyzer.php b/src/Drivers/Gd/Analyzers/PixelColorAnalyzer.php index be565ba1..fe1d8cd2 100644 --- a/src/Drivers/Gd/Analyzers/PixelColorAnalyzer.php +++ b/src/Drivers/Gd/Analyzers/PixelColorAnalyzer.php @@ -27,6 +27,9 @@ class PixelColorAnalyzer extends DriverSpecialized implements AnalyzerInterface ); } + /** + * @throws GeometryException + */ protected function colorAt(ColorspaceInterface $colorspace, GdImage $gd): ColorInterface { $index = @imagecolorat($gd, $this->x, $this->y); diff --git a/src/Drivers/Gd/Decoders/BinaryImageDecoder.php b/src/Drivers/Gd/Decoders/BinaryImageDecoder.php index 2b2231a5..67d31d06 100644 --- a/src/Drivers/Gd/Decoders/BinaryImageDecoder.php +++ b/src/Drivers/Gd/Decoders/BinaryImageDecoder.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Drivers\Gd\Decoders; +use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Interfaces\ColorInterface; use Intervention\Image\Interfaces\DecoderInterface; use Intervention\Image\Interfaces\ImageInterface; @@ -36,7 +37,7 @@ class BinaryImageDecoder extends GdImageDecoder implements DecoderInterface * Decode image from given binary data * * @param string $input - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ private function decodeBinary(string $input): ImageInterface diff --git a/src/Drivers/Gd/Decoders/Traits/CanDecodeGif.php b/src/Drivers/Gd/Decoders/Traits/CanDecodeGif.php index 07479c5d..9b1452b9 100644 --- a/src/Drivers/Gd/Decoders/Traits/CanDecodeGif.php +++ b/src/Drivers/Gd/Decoders/Traits/CanDecodeGif.php @@ -9,6 +9,7 @@ use Intervention\Gif\Splitter as GifSplitter; use Intervention\Image\Drivers\Gd\Core; use Intervention\Image\Drivers\Gd\Driver; use Intervention\Image\Drivers\Gd\Frame; +use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Image; use Intervention\Image\Interfaces\ImageInterface; @@ -18,6 +19,7 @@ trait CanDecodeGif * Decode image from given GIF source which can be either a file path or binary data * * @param mixed $input + * @throws RuntimeException * @return ImageInterface */ protected function decodeGif(mixed $input): ImageInterface diff --git a/src/Drivers/Gd/Driver.php b/src/Drivers/Gd/Driver.php index ae62d992..b1e34cc3 100644 --- a/src/Drivers/Gd/Driver.php +++ b/src/Drivers/Gd/Driver.php @@ -5,8 +5,8 @@ declare(strict_types=1); namespace Intervention\Image\Drivers\Gd; use Intervention\Image\Drivers\AbstractDriver; -use Intervention\Image\Exceptions\DecoderException; use Intervention\Image\Exceptions\DriverException; +use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Image; use Intervention\Image\Interfaces\ColorInterface; use Intervention\Image\Interfaces\ColorProcessorInterface; @@ -81,7 +81,7 @@ class Driver extends AbstractDriver } /** - * @throws DecoderException + * @throws RuntimeException */ public function add($source, float $delay = 1): self { @@ -92,6 +92,9 @@ class Driver extends AbstractDriver return $this; } + /** + * @throws RuntimeException + */ public function __invoke(): ImageInterface { return new Image( diff --git a/src/Drivers/Gd/Encoders/GifEncoder.php b/src/Drivers/Gd/Encoders/GifEncoder.php index 10dd03ad..f11721e8 100644 --- a/src/Drivers/Gd/Encoders/GifEncoder.php +++ b/src/Drivers/Gd/Encoders/GifEncoder.php @@ -9,6 +9,7 @@ use Intervention\Gif\Builder as GifBuilder; use Intervention\Image\Drivers\DriverSpecializedEncoder; use Intervention\Image\EncodedImage; use Intervention\Image\Exceptions\EncoderException; +use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Interfaces\ImageInterface; class GifEncoder extends DriverSpecializedEncoder @@ -28,7 +29,7 @@ class GifEncoder extends DriverSpecializedEncoder } /** - * @throws EncoderException + * @throws RuntimeException */ protected function encodeAnimated(ImageInterface $image): EncodedImage { diff --git a/src/Drivers/Gd/Modifiers/CoverDownModifier.php b/src/Drivers/Gd/Modifiers/CoverDownModifier.php index 5fb71f08..8fab3d4b 100644 --- a/src/Drivers/Gd/Modifiers/CoverDownModifier.php +++ b/src/Drivers/Gd/Modifiers/CoverDownModifier.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Drivers\Gd\Modifiers; +use Intervention\Image\Exceptions\GeometryException; use Intervention\Image\Interfaces\SizeInterface; /** @@ -12,6 +13,9 @@ use Intervention\Image\Interfaces\SizeInterface; */ class CoverDownModifier extends CoverModifier { + /** + * @throws GeometryException + */ public function getResizeSize(SizeInterface $size): SizeInterface { return $size->scaleDown($this->width, $this->height); diff --git a/src/Drivers/Gd/Modifiers/FillModifier.php b/src/Drivers/Gd/Modifiers/FillModifier.php index 976ab75e..5c45b280 100644 --- a/src/Drivers/Gd/Modifiers/FillModifier.php +++ b/src/Drivers/Gd/Modifiers/FillModifier.php @@ -6,7 +6,7 @@ namespace Intervention\Image\Drivers\Gd\Modifiers; use Intervention\Image\Drivers\DriverSpecialized; use Intervention\Image\Drivers\Gd\Frame; -use Intervention\Image\Exceptions\DecoderException; +use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Geometry\Point; use Intervention\Image\Interfaces\ModifierInterface; @@ -34,7 +34,7 @@ class FillModifier extends DriverSpecialized implements ModifierInterface } /** - * @throws DecoderException + * @throws RuntimeException */ private function color(ImageInterface $image): int { diff --git a/src/Drivers/Gd/Modifiers/PlaceModifier.php b/src/Drivers/Gd/Modifiers/PlaceModifier.php index 7d01d532..282c5ffe 100644 --- a/src/Drivers/Gd/Modifiers/PlaceModifier.php +++ b/src/Drivers/Gd/Modifiers/PlaceModifier.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Intervention\Image\Drivers\Gd\Modifiers; use Intervention\Image\Drivers\DriverSpecialized; +use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Interfaces\FrameInterface; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ModifierInterface; @@ -44,6 +45,7 @@ class PlaceModifier extends DriverSpecialized implements ModifierInterface * @param FrameInterface $frame * @param ImageInterface $watermark * @param PointInterface $position + * @throws RuntimeException * @return void */ private function placeOpaque(FrameInterface $frame, ImageInterface $watermark, PointInterface $position): void @@ -76,6 +78,7 @@ class PlaceModifier extends DriverSpecialized implements ModifierInterface * @param FrameInterface $frame * @param ImageInterface $watermark * @param PointInterface $position + * @throws RuntimeException * @return void */ private function placeTransparent(FrameInterface $frame, ImageInterface $watermark, PointInterface $position): void diff --git a/src/Drivers/Gd/Modifiers/ResizeModifier.php b/src/Drivers/Gd/Modifiers/ResizeModifier.php index 48599dce..2f33767b 100644 --- a/src/Drivers/Gd/Modifiers/ResizeModifier.php +++ b/src/Drivers/Gd/Modifiers/ResizeModifier.php @@ -6,6 +6,7 @@ namespace Intervention\Image\Drivers\Gd\Modifiers; use Intervention\Image\Drivers\DriverSpecialized; use Intervention\Image\Drivers\Gd\Cloner; +use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Interfaces\FrameInterface; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ModifierInterface; @@ -50,6 +51,9 @@ class ResizeModifier extends DriverSpecialized implements ModifierInterface $frame->setNative($modified); } + /** + * @throws RuntimeException + */ protected function getAdjustedSize(ImageInterface $image): SizeInterface { return $image->size()->resize($this->width, $this->height); diff --git a/src/Drivers/Imagick/Driver.php b/src/Drivers/Imagick/Driver.php index 9887e426..3dd9ea7c 100644 --- a/src/Drivers/Imagick/Driver.php +++ b/src/Drivers/Imagick/Driver.php @@ -7,8 +7,8 @@ namespace Intervention\Image\Drivers\Imagick; use Imagick; use ImagickPixel; use Intervention\Image\Drivers\AbstractDriver; -use Intervention\Image\Exceptions\DecoderException; use Intervention\Image\Exceptions\DriverException; +use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Image; use Intervention\Image\Interfaces\ColorInterface; use Intervention\Image\Interfaces\ColorProcessorInterface; @@ -83,7 +83,7 @@ class Driver extends AbstractDriver } /** - * @throws DecoderException + * @throws RuntimeException */ public function add($source, float $delay = 1): self { @@ -95,6 +95,9 @@ class Driver extends AbstractDriver return $this; } + /** + * @throws RuntimeException + */ public function __invoke(): ImageInterface { return new Image( diff --git a/src/Drivers/Imagick/Modifiers/CoverDownModifier.php b/src/Drivers/Imagick/Modifiers/CoverDownModifier.php index 1312647f..c16bf4be 100644 --- a/src/Drivers/Imagick/Modifiers/CoverDownModifier.php +++ b/src/Drivers/Imagick/Modifiers/CoverDownModifier.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Drivers\Imagick\Modifiers; +use Intervention\Image\Exceptions\GeometryException; use Intervention\Image\Interfaces\SizeInterface; /** @@ -12,6 +13,9 @@ use Intervention\Image\Interfaces\SizeInterface; */ class CoverDownModifier extends CoverModifier { + /** + * @throws GeometryException + */ public function getResizeSize(SizeInterface $size): SizeInterface { return $size->scaleDown($this->width, $this->height); diff --git a/src/Drivers/Imagick/Modifiers/ResizeModifier.php b/src/Drivers/Imagick/Modifiers/ResizeModifier.php index 457012f6..becfdc9a 100644 --- a/src/Drivers/Imagick/Modifiers/ResizeModifier.php +++ b/src/Drivers/Imagick/Modifiers/ResizeModifier.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Intervention\Image\Drivers\Imagick\Modifiers; use Intervention\Image\Drivers\DriverSpecialized; +use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ModifierInterface; use Intervention\Image\Interfaces\SizeInterface; @@ -29,6 +30,9 @@ class ResizeModifier extends DriverSpecialized implements ModifierInterface return $image; } + /** + * @throws RuntimeException + */ protected function getAdjustedSize(ImageInterface $image): SizeInterface { return $image->size()->resize($this->width, $this->height); diff --git a/src/Drivers/Imagick/Modifiers/TextModifier.php b/src/Drivers/Imagick/Modifiers/TextModifier.php index 3f14813c..88abe535 100644 --- a/src/Drivers/Imagick/Modifiers/TextModifier.php +++ b/src/Drivers/Imagick/Modifiers/TextModifier.php @@ -52,6 +52,7 @@ class TextModifier extends DriverSpecialized implements ModifierInterface /** * Return imagick font processor * + * @throws FontException * @return FontProcessor */ private function processor(): FontProcessor diff --git a/src/Geometry/Rectangle.php b/src/Geometry/Rectangle.php index e31f894f..a95d2355 100644 --- a/src/Geometry/Rectangle.php +++ b/src/Geometry/Rectangle.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Geometry; +use Intervention\Image\Exceptions\GeometryException; use Intervention\Image\Geometry\Tools\RectangleResizer; use Intervention\Image\Interfaces\PointInterface; use Intervention\Image\Interfaces\SizeInterface; @@ -281,6 +282,9 @@ class Rectangle extends Polygon implements SizeInterface return $this->points[2]; } + /** + * @throws GeometryException + */ protected function resizer(?int $width = null, ?int $height = null): RectangleResizer { return new RectangleResizer($width, $height); diff --git a/src/Geometry/Tools/RectangleResizer.php b/src/Geometry/Tools/RectangleResizer.php index eaa2d3b4..86be04d4 100644 --- a/src/Geometry/Tools/RectangleResizer.php +++ b/src/Geometry/Tools/RectangleResizer.php @@ -10,6 +10,9 @@ use Intervention\Image\Interfaces\SizeInterface; class RectangleResizer { + /** + * @throws GeometryException + */ public function __construct( protected ?int $width = null, protected ?int $height = null, @@ -27,6 +30,9 @@ class RectangleResizer } } + /** + * @throws GeometryException + */ public static function to(...$arguments): self { return new self(...$arguments); @@ -52,6 +58,9 @@ class RectangleResizer return $this->hasTargetHeight() ? $this->height : null; } + /** + * @throws GeometryException + */ protected function getTargetSize(): SizeInterface { if (!$this->hasTargetWidth() || !$this->hasTargetHeight()) { @@ -201,6 +210,7 @@ class RectangleResizer * Scale given size to cover target size * * @param SizeInterface $size Size to be resized + * @throws GeometryException * @return SizeInterface */ public function cover(SizeInterface $size): SizeInterface @@ -224,6 +234,7 @@ class RectangleResizer * Scale given size to contain target size * * @param SizeInterface $size Size to be resized + * @throws GeometryException * @return SizeInterface */ public function contain(SizeInterface $size): SizeInterface @@ -247,6 +258,7 @@ class RectangleResizer * Scale given size to contain target size but prevent upsizing * * @param SizeInterface $size Size to be resized + * @throws GeometryException * @return SizeInterface */ public function containDown(SizeInterface $size): SizeInterface diff --git a/src/Image.php b/src/Image.php index 4d12ff89..995babd6 100644 --- a/src/Image.php +++ b/src/Image.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Intervention\Image; +use Intervention\Image\Exceptions\RuntimeException; use Traversable; use Intervention\Image\Analyzers\ColorspaceAnalyzer; use Intervention\Image\Analyzers\HeightAnalyzer; @@ -112,6 +113,7 @@ final class Image implements ImageInterface * @param DriverInterface $driver * @param CoreInterface $core * @param CollectionInterface $exif + * @throws RuntimeException * @return void */ public function __construct( @@ -891,7 +893,7 @@ final class Image implements ImageInterface * Alias of self::toJpeg() * * @param mixed $options - * @throws EncoderException + * @throws RuntimeException * @return EncodedImageInterface */ public function toJpg(mixed ...$options): EncodedImageInterface @@ -913,7 +915,7 @@ final class Image implements ImageInterface * ALias of self::toJpeg2000() * * @param mixed $options - * @throws EncoderException + * @throws RuntimeException * @return EncodedImageInterface */ public function toJp2(mixed ...$options): EncodedImageInterface @@ -964,7 +966,7 @@ final class Image implements ImageInterface /** * Alias if self::toBitmap() * - * @throws EncoderException + * @throws RuntimeException * @return EncodedImageInterface */ public function toBmp(mixed ...$options): EncodedImageInterface @@ -996,7 +998,7 @@ final class Image implements ImageInterface * Alias of self::toTiff() * * @param mixed $options - * @throws EncoderException + * @throws RuntimeException * @return EncodedImageInterface */ public function toTif(mixed ...$options): EncodedImageInterface diff --git a/src/ImageManager.php b/src/ImageManager.php index c79fc73f..613a8998 100644 --- a/src/ImageManager.php +++ b/src/ImageManager.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Intervention\Image; -use Intervention\Image\Exceptions\DecoderException; +use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Interfaces\DriverInterface; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Drivers\Gd\Driver as GdDriver; @@ -56,6 +56,7 @@ final class ImageManager * * @param int $width * @param int $height + * @throws RuntimeException * @return ImageInterface */ public function create(int $width, int $height): ImageInterface @@ -88,7 +89,7 @@ final class ImageManager * * @param mixed $input * @param string|array|DecoderInterface $decoders - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function read(mixed $input, string|array|DecoderInterface $decoders = []): ImageInterface diff --git a/src/Interfaces/AnalyzerInterface.php b/src/Interfaces/AnalyzerInterface.php index 88c96d9b..9a44690e 100644 --- a/src/Interfaces/AnalyzerInterface.php +++ b/src/Interfaces/AnalyzerInterface.php @@ -4,12 +4,15 @@ declare(strict_types=1); namespace Intervention\Image\Interfaces; +use Intervention\Image\Exceptions\RuntimeException; + interface AnalyzerInterface { /** * Analyze given image and return the retrieved data * * @param ImageInterface $image + * @throws RuntimeException * @return mixed */ public function analyze(ImageInterface $image): mixed; diff --git a/src/Interfaces/ColorInterface.php b/src/Interfaces/ColorInterface.php index 932716e7..1ece89f3 100644 --- a/src/Interfaces/ColorInterface.php +++ b/src/Interfaces/ColorInterface.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Interfaces; -use Intervention\Image\Exceptions\DecoderException; +use Intervention\Image\Exceptions\RuntimeException; interface ColorInterface { @@ -13,7 +13,7 @@ interface ColorInterface * and returns a corresponding color object * * @param mixed $input - * @throws DecoderException + * @throws RuntimeException * @return ColorInterface */ public static function create(mixed $input): self; diff --git a/src/Interfaces/CoreInterface.php b/src/Interfaces/CoreInterface.php index 55d78a46..f8ac19f6 100644 --- a/src/Interfaces/CoreInterface.php +++ b/src/Interfaces/CoreInterface.php @@ -4,11 +4,14 @@ declare(strict_types=1); namespace Intervention\Image\Interfaces; +use Intervention\Image\Exceptions\AnimationException; + interface CoreInterface extends CollectionInterface { /** * return driver's representation of the image core. * + * @throws AnimationException * @return mixed */ public function native(): mixed; @@ -32,6 +35,7 @@ interface CoreInterface extends CollectionInterface * Return frame of given position in an animated image * * @param int $position + * @throws AnimationException * @return FrameInterface */ public function frame(int $position): FrameInterface; @@ -63,7 +67,16 @@ interface CoreInterface extends CollectionInterface /** * Get first frame in core * + * @throws AnimationException * @return FrameInterface */ public function first(): FrameInterface; + + /** + * Get last frame in core + * + * @throws AnimationException + * @return FrameInterface + */ + public function last(): FrameInterface; } diff --git a/src/Interfaces/DecoderInterface.php b/src/Interfaces/DecoderInterface.php index bf9139c2..6d67cc4c 100644 --- a/src/Interfaces/DecoderInterface.php +++ b/src/Interfaces/DecoderInterface.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Interfaces; -use Intervention\Image\Exceptions\DecoderException; +use Intervention\Image\Exceptions\RuntimeException; interface DecoderInterface { @@ -12,7 +12,7 @@ interface DecoderInterface * Decode given input either to color or image * * @param mixed $input - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface|ColorInterface */ public function decode(mixed $input): ImageInterface|ColorInterface; diff --git a/src/Interfaces/DriverInterface.php b/src/Interfaces/DriverInterface.php index 35fc5cc3..ba827381 100644 --- a/src/Interfaces/DriverInterface.php +++ b/src/Interfaces/DriverInterface.php @@ -4,8 +4,8 @@ declare(strict_types=1); namespace Intervention\Image\Interfaces; -use Intervention\Image\Exceptions\DecoderException; use Intervention\Image\Exceptions\DriverException; +use Intervention\Image\Exceptions\RuntimeException; interface DriverInterface { @@ -37,6 +37,7 @@ interface DriverInterface * * @param int $width * @param int $height + * @throws RuntimeException * @return ImageInterface */ public function createImage(int $width, int $height): ImageInterface; @@ -54,7 +55,7 @@ interface DriverInterface * * @param mixed $input * @param array $decoders - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface|ColorInterface */ public function handleInput(mixed $input, array $decoders = []): ImageInterface|ColorInterface; diff --git a/src/Interfaces/EncoderInterface.php b/src/Interfaces/EncoderInterface.php index 9c5402e1..53e9bcc6 100644 --- a/src/Interfaces/EncoderInterface.php +++ b/src/Interfaces/EncoderInterface.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Interfaces; -use Intervention\Image\Exceptions\EncoderException; +use Intervention\Image\Exceptions\RuntimeException; interface EncoderInterface { @@ -12,7 +12,7 @@ interface EncoderInterface * Encode given image * * @param ImageInterface $image - * @throws EncoderException + * @throws RuntimeException * @return EncodedImageInterface */ public function encode(ImageInterface $image): EncodedImageInterface; diff --git a/src/Interfaces/FileInterface.php b/src/Interfaces/FileInterface.php index 3b096fb3..6aa7e421 100644 --- a/src/Interfaces/FileInterface.php +++ b/src/Interfaces/FileInterface.php @@ -4,12 +4,15 @@ declare(strict_types=1); namespace Intervention\Image\Interfaces; +use Intervention\Image\Exceptions\RuntimeException; + interface FileInterface { /** * Save data in given path in file system * * @param string $filepath + * @throws RuntimeException * @return void */ public function save(string $filepath): void; diff --git a/src/Interfaces/FontProcessorInterface.php b/src/Interfaces/FontProcessorInterface.php index 58927eef..3a999b38 100644 --- a/src/Interfaces/FontProcessorInterface.php +++ b/src/Interfaces/FontProcessorInterface.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Interfaces; +use Intervention\Image\Exceptions\FontException; use Intervention\Image\Typography\TextBlock; interface FontProcessorInterface @@ -11,6 +12,7 @@ interface FontProcessorInterface /** * Calculate size of bounding box of given text in conjuction with the given font * + * @throws FontException * @return SizeInterface */ public function boxSize(string $text, FontInterface $font): SizeInterface; @@ -22,6 +24,7 @@ interface FontProcessorInterface * @param string $text * @param FontInterface $font * @param PointInterface $position + * @throws FontException * @return TextBlock */ public function textBlock(string $text, FontInterface $font, PointInterface $position): TextBlock; @@ -36,6 +39,7 @@ interface FontProcessorInterface /** * Calculate the typographical font size in pixels * + * @throws FontException * @return int */ public function typographicalSize(FontInterface $font): int; @@ -44,6 +48,7 @@ interface FontProcessorInterface * Calculates typographical cap height * * @param FontInterface $font + * @throws FontException * @return int */ public function capHeight(FontInterface $font): int; @@ -52,6 +57,7 @@ interface FontProcessorInterface * Calculates typographical leading size * * @param FontInterface $font + * @throws FontException * @return int */ public function leading(FontInterface $font): int; diff --git a/src/Interfaces/FrameInterface.php b/src/Interfaces/FrameInterface.php index 7ff8316a..d28ee38c 100644 --- a/src/Interfaces/FrameInterface.php +++ b/src/Interfaces/FrameInterface.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace Intervention\Image\Interfaces; +use Intervention\Image\Exceptions\RuntimeException; + interface FrameInterface { /** @@ -25,6 +27,7 @@ interface FrameInterface * Transform frame into an image * * @param DriverInterface $driver + * @throws RuntimeException * @return ImageInterface */ public function toImage(DriverInterface $driver): ImageInterface; diff --git a/src/Interfaces/ImageInterface.php b/src/Interfaces/ImageInterface.php index a36583c4..581060c4 100644 --- a/src/Interfaces/ImageInterface.php +++ b/src/Interfaces/ImageInterface.php @@ -6,8 +6,7 @@ namespace Intervention\Image\Interfaces; use Countable; use Intervention\Image\Encoders\AutoEncoder; -use Intervention\Image\Exceptions\DecoderException; -use Intervention\Image\Exceptions\EncoderException; +use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Origin; use IteratorAggregate; @@ -45,6 +44,7 @@ interface ImageInterface extends IteratorAggregate, Countable /** * Return width of current image * + * @throws RuntimeException * @return int */ public function width(): int; @@ -52,6 +52,7 @@ interface ImageInterface extends IteratorAggregate, Countable /** * Return height of current image * + * @throws RuntimeException * @return int */ public function height(): int; @@ -59,6 +60,7 @@ interface ImageInterface extends IteratorAggregate, Countable /** * Return size of current image * + * @throws RuntimeException * @return SizeInterface */ public function size(): SizeInterface; @@ -67,7 +69,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Encode image with given encoder * * @param EncoderInterface $encoder - * @throws EncoderException + * @throws RuntimeException * @return EncodedImageInterface */ public function encode(EncoderInterface $encoder = new AutoEncoder()): EncodedImageInterface; @@ -77,7 +79,7 @@ interface ImageInterface extends IteratorAggregate, Countable * given, the image will be saved at its original location. * * @param null|string $path - * @throws EncoderException + * @throws RuntimeException * @return ImageInterface */ public function save(?string $path = null, ...$options): self; @@ -86,7 +88,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Apply given modifier to current image * * @param ModifierInterface $modifier - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function modify(ModifierInterface $modifier): self; @@ -95,6 +97,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Analyzer current image with given analyzer * * @param AnalyzerInterface $analyzer + * @throws RuntimeException * @return mixed */ public function analyze(AnalyzerInterface $analyzer): mixed; @@ -115,7 +118,7 @@ interface ImageInterface extends IteratorAggregate, Countable * and the respective frame position is only determined approximately. * * @param int|string $position - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function removeAnimation(int|string $position = 0): self; @@ -125,7 +128,7 @@ interface ImageInterface extends IteratorAggregate, Countable * * @param int $offset * @param null|int $length - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function sliceAnimation(int $offset = 0, ?int $length = null): self; @@ -163,6 +166,7 @@ interface ImageInterface extends IteratorAggregate, Countable /** * Return image resolution/density * + * @throws RuntimeException * @return ResolutionInterface */ public function resolution(): ResolutionInterface; @@ -172,7 +176,7 @@ interface ImageInterface extends IteratorAggregate, Countable * * @param float $x * @param float $y - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function setResolution(float $x, float $y): self; @@ -180,6 +184,7 @@ interface ImageInterface extends IteratorAggregate, Countable /** * Get the colorspace of the image * + * @throws RuntimeException * @return ColorspaceInterface */ public function colorspace(): ColorspaceInterface; @@ -188,7 +193,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Transform image to given colorspace * * @param string|ColorspaceInterface $colorspace - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function setColorspace(string|ColorspaceInterface $colorspace): self; @@ -199,6 +204,7 @@ interface ImageInterface extends IteratorAggregate, Countable * @param int $x * @param int $y * @param int $frame_key + * @throws RuntimeException * @return ColorInterface */ public function pickColor(int $x, int $y, int $frame_key = 0): ColorInterface; @@ -208,6 +214,7 @@ interface ImageInterface extends IteratorAggregate, Countable * * @param int $x * @param int $y + * @throws RuntimeException * @return CollectionInterface */ public function pickColors(int $x, int $y): CollectionInterface; @@ -225,7 +232,7 @@ interface ImageInterface extends IteratorAggregate, Countable * which does not support transparency. * * @param mixed $color - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function setBlendingColor(mixed $color): self; @@ -234,7 +241,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Replace transparent areas of the image with given color * * @param mixed $color - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function blendTransparency(mixed $color = null): self; @@ -242,6 +249,7 @@ interface ImageInterface extends IteratorAggregate, Countable /** * Retrieve ICC color profile of image * + * @throws RuntimeException * @return ProfileInterface */ public function profile(): ProfileInterface; @@ -250,7 +258,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Set given icc color profile to image * * @param ProfileInterface $profile - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function setProfile(ProfileInterface $profile): self; @@ -258,7 +266,7 @@ interface ImageInterface extends IteratorAggregate, Countable /** * Remove ICC color profile from the current image * - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function removeProfile(): self; @@ -268,7 +276,7 @@ interface ImageInterface extends IteratorAggregate, Countable * * @param int $limit * @param mixed $background - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function reduceColors(int $limit, mixed $background = 'transparent'): self; @@ -277,7 +285,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Sharpen the current image with given strength * * @param int $amount - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function sharpen(int $amount = 10): self; @@ -285,7 +293,7 @@ interface ImageInterface extends IteratorAggregate, Countable /** * Turn image into a greyscale version * - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function greyscale(): self; @@ -294,7 +302,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Adjust brightness of the current image * * @param int $level - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function brightness(int $level): self; @@ -303,7 +311,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Adjust color contrast of the current image * * @param int $level - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function contrast(int $level): self; @@ -312,7 +320,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Apply gamma correction on the current image * * @param float $gamma - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function gamma(float $gamma): self; @@ -323,7 +331,7 @@ interface ImageInterface extends IteratorAggregate, Countable * @param int $red * @param int $green * @param int $blue - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function colorize(int $red = 0, int $green = 0, int $blue = 0): self; @@ -331,7 +339,7 @@ interface ImageInterface extends IteratorAggregate, Countable /** * Mirror the current image horizontally * - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function flip(): self; @@ -339,7 +347,7 @@ interface ImageInterface extends IteratorAggregate, Countable /** * Mirror the current image vertically * - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function flop(): self; @@ -348,7 +356,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Blur current image by given strength * * @param int $amount - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function blur(int $amount = 5): self; @@ -356,7 +364,7 @@ interface ImageInterface extends IteratorAggregate, Countable /** * Invert the colors of the current image * - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function invert(): self; @@ -365,7 +373,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Apply pixelation filter effect on current image * * @param int $size - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function pixelate(int $size): self; @@ -375,7 +383,7 @@ interface ImageInterface extends IteratorAggregate, Countable * * @param float $angle * @param string $background - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function rotate(float $angle, mixed $background = 'ffffff'): self; @@ -387,7 +395,7 @@ interface ImageInterface extends IteratorAggregate, Countable * @param int $x * @param int $y * @param callable|FontInterface $font - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function text(string $text, int $x, int $y, callable|FontInterface $font): self; @@ -397,7 +405,7 @@ interface ImageInterface extends IteratorAggregate, Countable * * @param null|int $width * @param null|int $height - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function resize(?int $width = null, ?int $height = null): self; @@ -407,7 +415,7 @@ interface ImageInterface extends IteratorAggregate, Countable * * @param null|int $width * @param null|int $height - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function resizeDown(?int $width = null, ?int $height = null): self; @@ -417,7 +425,7 @@ interface ImageInterface extends IteratorAggregate, Countable * * @param null|int $width * @param null|int $height - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function scale(?int $width = null, ?int $height = null): self; @@ -428,7 +436,7 @@ interface ImageInterface extends IteratorAggregate, Countable * * @param null|int $width * @param null|int $height - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function scaleDown(?int $width = null, ?int $height = null): self; @@ -441,7 +449,7 @@ interface ImageInterface extends IteratorAggregate, Countable * @param int $width * @param int $height * @param string $position - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function cover(int $width, int $height, string $position = 'center'): self; @@ -452,7 +460,7 @@ interface ImageInterface extends IteratorAggregate, Countable * @param int $width * @param int $height * @param string $position - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function coverDown(int $width, int $height, string $position = 'center'): self; @@ -467,7 +475,7 @@ interface ImageInterface extends IteratorAggregate, Countable * @param null|int $height * @param string $position * @param mixed $background - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function resizeCanvas( @@ -486,7 +494,7 @@ interface ImageInterface extends IteratorAggregate, Countable * @param null|int $height * @param string $position * @param mixed $background - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function resizeCanvasRelative( @@ -509,7 +517,7 @@ interface ImageInterface extends IteratorAggregate, Countable * @param int $height * @param string $background * @param string $position - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function pad( @@ -527,7 +535,7 @@ interface ImageInterface extends IteratorAggregate, Countable * @param int $height * @param string $background * @param string $position - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function contain( @@ -548,7 +556,7 @@ interface ImageInterface extends IteratorAggregate, Countable * @param int $offset_y * @param mixed $background * @param string $position - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function crop( @@ -568,7 +576,7 @@ interface ImageInterface extends IteratorAggregate, Countable * @param int $offset_x * @param int $offset_y * @param int $opacity - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function place( @@ -592,7 +600,7 @@ interface ImageInterface extends IteratorAggregate, Countable * @param mixed $color * @param null|int $x * @param null|int $y - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function fill(mixed $color, ?int $x = null, ?int $y = null): self; @@ -603,7 +611,7 @@ interface ImageInterface extends IteratorAggregate, Countable * @param int $x * @param int $y * @param mixed $color - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function drawPixel(int $x, int $y, mixed $color): self; @@ -614,7 +622,7 @@ interface ImageInterface extends IteratorAggregate, Countable * @param int $x * @param int $y * @param callable $init - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function drawRectangle(int $x, int $y, callable $init): self; @@ -625,7 +633,7 @@ interface ImageInterface extends IteratorAggregate, Countable * @param int $x * @param int $y * @param callable $init - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function drawEllipse(int $x, int $y, callable $init): self; @@ -636,7 +644,7 @@ interface ImageInterface extends IteratorAggregate, Countable * @param int $x * @param int $y * @param callable $init - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function drawCircle(int $x, int $y, callable $init): self; @@ -645,7 +653,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Draw a polygon on the current image * * @param callable $init - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function drawPolygon(callable $init): self; @@ -654,7 +662,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Draw a line on the current image * * @param callable $init - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function drawLine(callable $init): self; @@ -664,7 +672,7 @@ interface ImageInterface extends IteratorAggregate, Countable * will be encoded to the format of the originally read image. * * @param null|string $type - * @throws EncoderException + * @throws RuntimeException * @return EncodedImageInterface */ public function encodeByMediaType(?string $type = null, ...$options): EncodedImageInterface; @@ -675,7 +683,7 @@ interface ImageInterface extends IteratorAggregate, Countable * originally read image. * * @param null|string $extension - * @throws EncoderException + * @throws RuntimeException * @return EncodedImageInterface */ public function encodeByExtension(?string $extension = null, mixed ...$options): EncodedImageInterface; @@ -686,7 +694,7 @@ interface ImageInterface extends IteratorAggregate, Countable * the format of the originally read image. * * @param null|string $path - * @throws EncoderException + * @throws RuntimeException * @return EncodedImageInterface */ public function encodeByPath(?string $path = null, mixed ...$options): EncodedImageInterface; @@ -695,7 +703,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Encode image to JPEG format * * @param mixed $options - * @throws EncoderException + * @throws RuntimeException * @return EncodedImageInterface */ @@ -705,7 +713,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Encode image to Jpeg2000 format * * @param mixed $options - * @throws EncoderException + * @throws RuntimeException * @return EncodedImageInterface */ public function toJpeg2000(mixed ...$options): EncodedImageInterface; @@ -714,7 +722,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Encode image to Webp format * * @param mixed $options - * @throws EncoderException + * @throws RuntimeException * @return EncodedImageInterface */ public function toWebp(mixed ...$options): EncodedImageInterface; @@ -723,7 +731,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Encode image to PNG format * * @param mixed $options - * @throws EncoderException + * @throws RuntimeException * @return EncodedImageInterface */ public function toPng(mixed ...$options): EncodedImageInterface; @@ -732,7 +740,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Encode image to GIF format * * @param mixed $options - * @throws EncoderException + * @throws RuntimeException * @return EncodedImageInterface */ public function toGif(mixed ...$options): EncodedImageInterface; @@ -741,7 +749,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Encode image to Bitmap format * * @param mixed $options - * @throws EncoderException + * @throws RuntimeException * @return EncodedImageInterface */ public function toBitmap(mixed ...$options): EncodedImageInterface; @@ -750,7 +758,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Encode image to AVIF format * * @param mixed $options - * @throws EncoderException + * @throws RuntimeException * @return EncodedImageInterface */ public function toAvif(mixed ...$options): EncodedImageInterface; @@ -759,7 +767,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Encode image to TIFF format * * @param mixed $options - * @throws EncoderException + * @throws RuntimeException * @return EncodedImageInterface */ public function toTiff(mixed ...$options): EncodedImageInterface; @@ -768,7 +776,7 @@ interface ImageInterface extends IteratorAggregate, Countable * Encode image to HEIC format * * @param mixed $options - * @throws EncoderException + * @throws RuntimeException * @return EncodedImageInterface */ public function toHeic(mixed ...$options): EncodedImageInterface; diff --git a/src/Interfaces/InputHandlerInterface.php b/src/Interfaces/InputHandlerInterface.php index b10259e6..6d89f07e 100644 --- a/src/Interfaces/InputHandlerInterface.php +++ b/src/Interfaces/InputHandlerInterface.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Interfaces; -use Intervention\Image\Exceptions\DecoderException; +use Intervention\Image\Exceptions\RuntimeException; interface InputHandlerInterface { @@ -12,7 +12,7 @@ interface InputHandlerInterface * Try to decode the given input with each decoder of the the handler chain * * @param mixed $input - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface|ColorInterface */ public function handle($input): ImageInterface|ColorInterface; diff --git a/src/Interfaces/ModifierInterface.php b/src/Interfaces/ModifierInterface.php index a224be0c..a68def25 100644 --- a/src/Interfaces/ModifierInterface.php +++ b/src/Interfaces/ModifierInterface.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Interfaces; -use Intervention\Image\Exceptions\DecoderException; +use Intervention\Image\Exceptions\RuntimeException; interface ModifierInterface { @@ -12,7 +12,7 @@ interface ModifierInterface * Apply modifications of the current modifier to the given image * * @param ImageInterface $image - * @throws DecoderException + * @throws RuntimeException * @return ImageInterface */ public function apply(ImageInterface $image): ImageInterface; diff --git a/src/Interfaces/SizeInterface.php b/src/Interfaces/SizeInterface.php index 70bcbb7e..d62fa6ed 100644 --- a/src/Interfaces/SizeInterface.php +++ b/src/Interfaces/SizeInterface.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace Intervention\Image\Interfaces; +use Intervention\Image\Exceptions\GeometryException; + interface SizeInterface { /** @@ -110,33 +112,48 @@ interface SizeInterface /** * @see ImageInterface::resize() + * + * @throws GeometryException */ public function resize(?int $width = null, ?int $height = null): self; /** * @see ImageInterface::resizeDown() + * + * @throws GeometryException */ public function resizeDown(?int $width = null, ?int $height = null): self; /** * @see ImageInterface::scale() + * + * @throws GeometryException */ public function scale(?int $width = null, ?int $height = null): self; /** * @see ImageInterface::scaleDown() + * + * @throws GeometryException */ public function scaleDown(?int $width = null, ?int $height = null): self; /** * @see ImageInterface::cover() + * + * @throws GeometryException */ public function cover(int $width, int $height): self; /** * @see ImageInterface::contain() + * + * @throws GeometryException */ public function contain(int $width, int $height): self; + /** + * @throws GeometryException + */ public function containMax(int $width, int $height): self; } diff --git a/src/Modifiers/ContainModifier.php b/src/Modifiers/ContainModifier.php index 03826887..05d2e1a8 100644 --- a/src/Modifiers/ContainModifier.php +++ b/src/Modifiers/ContainModifier.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Modifiers; +use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Geometry\Rectangle; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\SizeInterface; @@ -18,6 +19,9 @@ class ContainModifier extends SpecializableModifier ) { } + /** + * @throws RuntimeException + */ public function getCropSize(ImageInterface $image): SizeInterface { return $image->size() diff --git a/src/Modifiers/CoverModifier.php b/src/Modifiers/CoverModifier.php index 7b78c757..06bb6793 100644 --- a/src/Modifiers/CoverModifier.php +++ b/src/Modifiers/CoverModifier.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Modifiers; +use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Geometry\Rectangle; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\SizeInterface; @@ -17,6 +18,9 @@ class CoverModifier extends SpecializableModifier ) { } + /** + * @throws RuntimeException + */ public function getCropSize(ImageInterface $image): SizeInterface { $imagesize = $image->size(); @@ -30,6 +34,9 @@ class CoverModifier extends SpecializableModifier return $crop; } + /** + * @throws RuntimeException + */ public function getResizeSize(SizeInterface $size): SizeInterface { return $size->scale($this->width, $this->height); diff --git a/src/Modifiers/CropModifier.php b/src/Modifiers/CropModifier.php index 3979f25a..1eff42a6 100644 --- a/src/Modifiers/CropModifier.php +++ b/src/Modifiers/CropModifier.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Modifiers; +use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Geometry\Rectangle; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\SizeInterface; @@ -20,6 +21,9 @@ class CropModifier extends SpecializableModifier ) { } + /** + * @throws RuntimeException + */ public function crop(ImageInterface $image): SizeInterface { $crop = new Rectangle($this->width, $this->height); diff --git a/src/Modifiers/PlaceModifier.php b/src/Modifiers/PlaceModifier.php index 3d75a9a0..4289fdf2 100644 --- a/src/Modifiers/PlaceModifier.php +++ b/src/Modifiers/PlaceModifier.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Modifiers; +use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\PointInterface; @@ -18,6 +19,9 @@ class PlaceModifier extends SpecializableModifier ) { } + /** + * @throws RuntimeException + */ public function getPosition(ImageInterface $image, ImageInterface $watermark): PointInterface { $image_size = $image->size()->movePivot( diff --git a/src/Modifiers/RemoveAnimationModifier.php b/src/Modifiers/RemoveAnimationModifier.php index c950d825..cabba2b1 100644 --- a/src/Modifiers/RemoveAnimationModifier.php +++ b/src/Modifiers/RemoveAnimationModifier.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Intervention\Image\Modifiers; use Intervention\Image\Exceptions\InputException; +use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Interfaces\FrameInterface; use Intervention\Image\Interfaces\ImageInterface; @@ -15,6 +16,9 @@ class RemoveAnimationModifier extends SpecializableModifier // } + /** + * @throws RuntimeException + */ public function chosenFrame(ImageInterface $image, int|string $position): FrameInterface { if (is_int($position)) { diff --git a/src/Modifiers/ResizeCanvasModifier.php b/src/Modifiers/ResizeCanvasModifier.php index 37fec17d..d4e5ed43 100644 --- a/src/Modifiers/ResizeCanvasModifier.php +++ b/src/Modifiers/ResizeCanvasModifier.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Modifiers; +use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Geometry\Rectangle; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\SizeInterface; @@ -18,6 +19,9 @@ class ResizeCanvasModifier extends SpecializableModifier ) { } + /** + * @throws RuntimeException + */ public function cropSize(ImageInterface $image): SizeInterface { $width = is_null($this->width) ? $image->width() : $this->width;