diff --git a/src/AbstractPaginator.php b/src/AbstractPaginator.php index 5010766..901e907 100644 --- a/src/AbstractPaginator.php +++ b/src/AbstractPaginator.php @@ -11,6 +11,7 @@ */ namespace Hyperf\Paginator; +use ArrayAccess; use ArrayIterator; use Closure; use Hyperf\Contract\PaginatorInterface; @@ -19,7 +20,7 @@ use Hyperf\Utils\Str; use Hyperf\Utils\Traits\ForwardsCalls; -abstract class AbstractPaginator implements PaginatorInterface +abstract class AbstractPaginator implements PaginatorInterface, ArrayAccess { use ForwardsCalls; @@ -370,41 +371,27 @@ public function setCollection(Collection $collection): self return $this; } - /** - * Determine if the given item exists. - * @param mixed $key - */ - public function offsetExists($key): bool + public function offsetExists(mixed $offset): bool { - return $this->items->has($key); + return $this->items->has($offset); } - /** - * Get the item at the given offset. - * @param mixed $key - */ - public function offsetGet($key) + public function offsetGet(mixed $offset): mixed { - return $this->items->get($key); + return $this->items->get($offset); } - /** - * Set the item at the given offset. - * @param mixed $key - * @param mixed $value - */ - public function offsetSet($key, $value): void + public function offsetSet(mixed $offset, mixed $value): void { - $this->items->put($key, $value); + $this->items->put($offset, $value); } /** * Unset the item at the given key. - * @param mixed $key */ - public function offsetUnset($key): void + public function offsetUnset(mixed $offset): void { - $this->items->forget($key); + $this->items->forget($offset); } /** diff --git a/src/LengthAwarePaginator.php b/src/LengthAwarePaginator.php index 749c543..735a796 100644 --- a/src/LengthAwarePaginator.php +++ b/src/LengthAwarePaginator.php @@ -11,7 +11,6 @@ */ namespace Hyperf\Paginator; -use ArrayAccess; use Countable; use Hyperf\Contract\Arrayable; use Hyperf\Contract\LengthAwarePaginatorInterface; @@ -20,7 +19,7 @@ use IteratorAggregate; use JsonSerializable; -class LengthAwarePaginator extends AbstractPaginator implements Arrayable, ArrayAccess, Countable, IteratorAggregate, JsonSerializable, Jsonable, LengthAwarePaginatorInterface +class LengthAwarePaginator extends AbstractPaginator implements Arrayable, Countable, IteratorAggregate, JsonSerializable, Jsonable, LengthAwarePaginatorInterface { /** * The total number of items before slicing. diff --git a/src/Paginator.php b/src/Paginator.php index 7f6ee6e..4c4aeb9 100644 --- a/src/Paginator.php +++ b/src/Paginator.php @@ -11,7 +11,6 @@ */ namespace Hyperf\Paginator; -use ArrayAccess; use Countable; use Hyperf\Contract\Arrayable; use Hyperf\Utils\Collection; @@ -19,7 +18,7 @@ use IteratorAggregate; use JsonSerializable; -class Paginator extends AbstractPaginator implements Arrayable, ArrayAccess, Countable, IteratorAggregate, JsonSerializable, Jsonable +class Paginator extends AbstractPaginator implements Arrayable, Countable, IteratorAggregate, JsonSerializable, Jsonable { /** * Determine if there are more items in the data source.