Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7b6bc14

Browse files
author
janvt
authoredDec 19, 2023
Merge pull request #23 from Bl00D4NGEL/implement-array-access-generics
Feat: Genericly implement ArrayAccess for Collection and Paginator
2 parents df3f12b + d654dbe commit 7b6bc14

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed
 

‎src/Domain/Collection.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88

99
/**
1010
* @template T of object
11-
* @extends \IteratorAggregate<T>
11+
* @implements \IteratorAggregate<T>
12+
* @implements \ArrayAccess<mixed, T>
1213
*/
1314
class Collection implements \ArrayAccess, \Countable, \IteratorAggregate
1415
{
1516
/**
1617
* @param T[] $items
1718
* @param class-string<T>|null $itemType
18-
*
19-
* @throws Assert\AssertionFailedException
2019
*/
2120
final public function __construct(
2221
private readonly array $items = [],
@@ -31,10 +30,8 @@ final public function __construct(
3130
* Add one or more items to the collection. It **does not** modify the
3231
* current collection, but returns a new one.
3332
*
34-
* @param mixed $item One or more items to add to the collection.
33+
* @param mixed $item One or more items to add to the collection.
3534
* @return static
36-
*
37-
* @throws Assert\AssertionFailedException
3835
*/
3936
public function add(mixed $item): static
4037
{

‎src/Infrastructure/InMemory/Paginator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
/**
1515
* @template T of object
16-
* @extends PaginatorInterface<T>
16+
* @implements PaginatorInterface<T>
17+
* @implements ArrayAccess<mixed, T>
1718
*/
1819
class Paginator implements PaginatorInterface, ArrayAccess
1920
{

0 commit comments

Comments
 (0)
Please sign in to comment.