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