Skip to content

Commit

Permalink
Merge pull request #23 from Bl00D4NGEL/implement-array-access-generics
Browse files Browse the repository at this point in the history
Feat: Genericly implement ArrayAccess for Collection and Paginator
  • Loading branch information
janvt authored Dec 19, 2023
2 parents df3f12b + d654dbe commit 7b6bc14
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
9 changes: 3 additions & 6 deletions src/Domain/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@

/**
* @template T of object
* @extends \IteratorAggregate<T>
* @implements \IteratorAggregate<T>
* @implements \ArrayAccess<mixed, T>
*/
class Collection implements \ArrayAccess, \Countable, \IteratorAggregate
{
/**
* @param T[] $items
* @param class-string<T>|null $itemType
*
* @throws Assert\AssertionFailedException
*/
final public function __construct(
private readonly array $items = [],
Expand All @@ -31,10 +30,8 @@ final public function __construct(
* Add one or more items to the collection. It **does not** modify the
* current collection, but returns a new one.
*
* @param mixed $item One or more items to add to the collection.
* @param mixed $item One or more items to add to the collection.
* @return static
*
* @throws Assert\AssertionFailedException
*/
public function add(mixed $item): static
{
Expand Down
3 changes: 2 additions & 1 deletion src/Infrastructure/InMemory/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

/**
* @template T of object
* @extends PaginatorInterface<T>
* @implements PaginatorInterface<T>
* @implements ArrayAccess<mixed, T>
*/
class Paginator implements PaginatorInterface, ArrayAccess
{
Expand Down

0 comments on commit 7b6bc14

Please sign in to comment.