1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-24 14:32:52 +02:00

Correct type hints

This commit is contained in:
Oliver Vogel
2025-05-31 17:27:52 +02:00
parent d3c3b6422a
commit 3838f28903
11 changed files with 18 additions and 54 deletions

View File

@@ -78,10 +78,9 @@ class Collection implements CollectionInterface, IteratorAggregate, Countable
/**
* Append new item to collection
*
* @param mixed $item
* @return CollectionInterface<int|string, mixed>
*/
public function push($item): CollectionInterface
public function push(mixed $item): CollectionInterface
{
$this->items[] = $item;
@@ -115,7 +114,7 @@ class Collection implements CollectionInterface, IteratorAggregate, Countable
/**
* Return item at given position starting at 0
*/
public function getAtPosition(int $key = 0, $default = null): mixed
public function getAtPosition(int $key = 0, mixed $default = null): mixed
{
if ($this->count() == 0) {
return $default;
@@ -134,7 +133,7 @@ class Collection implements CollectionInterface, IteratorAggregate, Countable
*
* @see CollectionInterface::get()
*/
public function get(int|string $query, $default = null): mixed
public function get(int|string $query, mixed $default = null): mixed
{
if ($this->count() == 0) {
return $default;

View File

@@ -144,42 +144,32 @@ class Bezier implements IteratorAggregate, Countable, ArrayAccess, DrawableInter
/**
* Determine if point exists at given offset
*
* @param mixed $offset
*/
public function offsetExists($offset): bool
public function offsetExists(mixed $offset): bool
{
return array_key_exists($offset, $this->points);
}
/**
* Return point at given offset
*
* @param mixed $offset
* @return PointInterface
*/
public function offsetGet($offset): mixed
public function offsetGet(mixed $offset): mixed
{
return $this->points[$offset];
}
/**
* Set point at given offset
*
* @param mixed $offset
* @param PointInterface $value
*/
public function offsetSet($offset, $value): void
public function offsetSet(mixed $offset, mixed $value): void
{
$this->points[$offset] = $value;
}
/**
* Unset offset at given offset
*
* @param mixed $offset
*/
public function offsetUnset($offset): void
public function offsetUnset(mixed $offset): void
{
unset($this->points[$offset]);
}

View File

@@ -120,42 +120,32 @@ class Polygon implements IteratorAggregate, Countable, ArrayAccess, DrawableInte
/**
* Determine if point exists at given offset
*
* @param mixed $offset
*/
public function offsetExists($offset): bool
public function offsetExists(mixed $offset): bool
{
return array_key_exists($offset, $this->points);
}
/**
* Return point at given offset
*
* @param mixed $offset
* @return PointInterface
*/
public function offsetGet($offset): mixed
public function offsetGet(mixed $offset): mixed
{
return $this->points[$offset];
}
/**
* Set point at given offset
*
* @param mixed $offset
* @param PointInterface $value
*/
public function offsetSet($offset, $value): void
public function offsetSet(mixed $offset, mixed $value): void
{
$this->points[$offset] = $value;
}
/**
* Unset offset at given offset
*
* @param mixed $offset
*/
public function offsetUnset($offset): void
public function offsetUnset(mixed $offset): void
{
unset($this->points[$offset]);
}

View File

@@ -66,7 +66,6 @@ class InputHandler implements InputHandlerInterface
* Create new input handler instance with given decoder classnames
*
* @param array<string|DecoderInterface> $decoders
* @param DriverInterface $driver
* @return void
*/
public function __construct(array $decoders = [], ?DriverInterface $driver = null)

View File

@@ -19,24 +19,19 @@ interface CollectionInterface extends Traversable
/**
* Add item to collection
*
* @param mixed $item
* @return CollectionInterface<int|string, mixed>
*/
public function push($item): self;
public function push(mixed $item): self;
/**
* Return item for given key or return default is key does not exist
*
* @param mixed $default
*/
public function get(int|string $key, $default = null): mixed;
public function get(int|string $key, mixed $default = null): mixed;
/**
* Return item at given numeric position starting at 0
*
* @param mixed $default
*/
public function getAtPosition(int $key = 0, $default = null): mixed;
public function getAtPosition(int $key = 0, mixed $default = null): mixed;
/**
* Return first item in collection

View File

@@ -12,9 +12,8 @@ interface ColorProcessorInterface
* Turn given color in the driver's color implementation
*
* @throws ColorException
* @return mixed
*/
public function colorToNative(ColorInterface $color);
public function colorToNative(ColorInterface $color): mixed;
/**
* Turn the given driver's definition of a color into a color object

View File

@@ -113,8 +113,6 @@ interface FontInterface
/**
* Set the wrap width with which the text is rendered
*
* @param int $width
*/
public function setWrapWidth(?int $width): self;

View File

@@ -15,10 +15,8 @@ interface FrameInterface
/**
* Set image data of drame in driver specific format
*
* @param mixed $native
*/
public function setNative($native): self;
public function setNative(mixed $native): self;
/**
* Transform frame into an image

View File

@@ -11,8 +11,7 @@ interface InputHandlerInterface
/**
* Try to decode the given input with each decoder of the the handler chain
*
* @param mixed $input
* @throws RuntimeException
*/
public function handle($input): ImageInterface|ColorInterface;
public function handle(mixed $input): ImageInterface|ColorInterface;
}

View File

@@ -27,7 +27,6 @@ class Line implements IteratorAggregate, Countable, Stringable
/**
* Create new text line object with given text & position
*
* @param string $text
* @return void
*/
public function __construct(

View File

@@ -44,10 +44,8 @@ class TextBlock extends Collection
/**
* Get line by given key
*
* @param mixed $key
*/
public function line($key): ?Line
public function line(mixed $key): ?Line
{
if (!array_key_exists($key, $this->lines())) {
return null;