mirror of
https://github.com/Intervention/image.git
synced 2025-08-28 08:09:54 +02:00
Fix missing phpdoc and configure phpstan
This commit is contained in:
2
.github/workflows/run-tests.yml
vendored
2
.github/workflows/run-tests.yml
vendored
@@ -99,7 +99,7 @@ jobs:
|
||||
run: vendor/bin/phpunit --no-coverage
|
||||
|
||||
- name: Run analyzer
|
||||
run: vendor/bin/phpstan analyze --level=4 ./src
|
||||
run: vendor/bin/phpstan
|
||||
|
||||
- name: Validate coding standards
|
||||
run: vendor/bin/phpcs
|
||||
|
20
phpstan.dist.neon
Normal file
20
phpstan.dist.neon
Normal file
@@ -0,0 +1,20 @@
|
||||
parameters:
|
||||
level: 4
|
||||
paths:
|
||||
- src
|
||||
exceptions:
|
||||
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
|
||||
- Error
|
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image;
|
||||
|
||||
use Intervention\Image\Exceptions\RuntimeException;
|
||||
use Intervention\Image\Interfaces\CollectionInterface;
|
||||
use ArrayIterator;
|
||||
use Countable;
|
||||
@@ -198,10 +197,6 @@ class Collection implements CollectionInterface, IteratorAggregate, Countable
|
||||
*/
|
||||
public function slice(int $offset, ?int $length = null): CollectionInterface
|
||||
{
|
||||
if ($offset >= count($this->items)) {
|
||||
throw new RuntimeException('Offset exceeds the maximum value.');
|
||||
}
|
||||
|
||||
$this->items = array_slice($this->items, $offset, $length);
|
||||
|
||||
return $this;
|
||||
|
@@ -20,6 +20,9 @@ abstract class AbstractDrawModifier extends DriverSpecialized implements Modifie
|
||||
return $this->drawable->position();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws DecoderException
|
||||
*/
|
||||
public function backgroundColor(): ColorInterface
|
||||
{
|
||||
try {
|
||||
@@ -31,6 +34,9 @@ abstract class AbstractDrawModifier extends DriverSpecialized implements Modifie
|
||||
return $color;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws DecoderException
|
||||
*/
|
||||
public function borderColor(): ColorInterface
|
||||
{
|
||||
try {
|
||||
|
@@ -6,7 +6,7 @@ namespace Intervention\Image\Drivers\Gd;
|
||||
|
||||
use Intervention\Image\Drivers\AbstractDriver;
|
||||
use Intervention\Image\Exceptions\DecoderException;
|
||||
use Intervention\Image\Exceptions\RuntimeException;
|
||||
use Intervention\Image\Exceptions\DriverException;
|
||||
use Intervention\Image\Image;
|
||||
use Intervention\Image\Interfaces\ColorInterface;
|
||||
use Intervention\Image\Interfaces\ColorProcessorInterface;
|
||||
@@ -36,7 +36,7 @@ class Driver extends AbstractDriver
|
||||
public function checkHealth(): void
|
||||
{
|
||||
if (!extension_loaded('gd') || !function_exists('gd_info')) {
|
||||
throw new RuntimeException(
|
||||
throw new DriverException(
|
||||
'GD PHP extension must be installed to use this driver.'
|
||||
);
|
||||
}
|
||||
|
@@ -43,7 +43,11 @@ class GifEncoder extends DriverSpecializedEncoder
|
||||
);
|
||||
}
|
||||
|
||||
$builder->setLoops($image->loops());
|
||||
try {
|
||||
$builder->setLoops($image->loops());
|
||||
} catch (\Exception $e) {
|
||||
throw new EncoderException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
|
||||
return new EncodedImage($builder->encode(), 'image/gif');
|
||||
}
|
||||
|
@@ -9,7 +9,6 @@ use ImagickException;
|
||||
use Iterator;
|
||||
use Intervention\Image\Interfaces\CoreInterface;
|
||||
use Intervention\Image\Exceptions\AnimationException;
|
||||
use Intervention\Image\Exceptions\RuntimeException;
|
||||
use Intervention\Image\Interfaces\CollectionInterface;
|
||||
use Intervention\Image\Interfaces\FrameInterface;
|
||||
|
||||
@@ -98,10 +97,6 @@ class Core implements CoreInterface, Iterator
|
||||
*/
|
||||
public function slice(int $offset, ?int $length = null): CollectionInterface
|
||||
{
|
||||
if ($offset >= $this->count()) {
|
||||
throw new RuntimeException('Offset exceeds the maximum value.');
|
||||
}
|
||||
|
||||
$allowed_indexes = [];
|
||||
$length = is_null($length) ? $this->count() : $length;
|
||||
for ($i = $offset; $i < $offset + $length; $i++) {
|
||||
|
@@ -8,7 +8,7 @@ use Imagick;
|
||||
use ImagickPixel;
|
||||
use Intervention\Image\Drivers\AbstractDriver;
|
||||
use Intervention\Image\Exceptions\DecoderException;
|
||||
use Intervention\Image\Exceptions\RuntimeException;
|
||||
use Intervention\Image\Exceptions\DriverException;
|
||||
use Intervention\Image\Image;
|
||||
use Intervention\Image\Interfaces\ColorInterface;
|
||||
use Intervention\Image\Interfaces\ColorProcessorInterface;
|
||||
@@ -38,7 +38,7 @@ class Driver extends AbstractDriver
|
||||
public function checkHealth(): void
|
||||
{
|
||||
if (!extension_loaded('imagick') || !class_exists('Imagick')) {
|
||||
throw new RuntimeException(
|
||||
throw new DriverException(
|
||||
'Imagick PHP extension must be installed to use this driver.'
|
||||
);
|
||||
}
|
||||
|
9
src/Exceptions/DriverException.php
Normal file
9
src/Exceptions/DriverException.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Exceptions;
|
||||
|
||||
class DriverException extends RuntimeException
|
||||
{
|
||||
}
|
@@ -5,6 +5,7 @@ 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
|
||||
@@ -78,7 +79,7 @@ interface DriverInterface
|
||||
* Check whether all requirements for operating the driver are met and
|
||||
* throw exception if the check fails.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws DriverException
|
||||
* @return void
|
||||
*/
|
||||
public function checkHealth(): void;
|
||||
|
Reference in New Issue
Block a user