Skip to content

Commit 826bf9f

Browse files
authored
Merge pull request #52 from Arkemlar/master
Add generics annotations for better IDE support
2 parents 7a8018a + 8be223d commit 826bf9f

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

src/Collections/FolderCollection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
namespace DirectoryTree\ImapEngine\Collections;
44

5+
use DirectoryTree\ImapEngine\FolderInterface;
56
use Illuminate\Support\Collection;
67

8+
/**
9+
* @template-extends Collection<array-key, FolderInterface>
10+
*/
711
class FolderCollection extends Collection {}

src/Collections/MessageCollection.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
use DirectoryTree\ImapEngine\Message;
66
use DirectoryTree\ImapEngine\MessageInterface;
77

8+
/**
9+
* @template-extends PaginatedCollection<array-key, MessageInterface>
10+
*/
811
class MessageCollection extends PaginatedCollection
912
{
1013
/**

src/Collections/PaginatedCollection.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
use DirectoryTree\ImapEngine\Pagination\LengthAwarePaginator;
66
use Illuminate\Support\Collection;
77

8+
/**
9+
* @template TKey of array-key
10+
* @template-covariant TValue
11+
*
12+
* @template-extends Collection<TKey, TValue>
13+
*/
814
class PaginatedCollection extends Collection
915
{
1016
/**
@@ -14,6 +20,8 @@ class PaginatedCollection extends Collection
1420

1521
/**
1622
* Paginate the current collection.
23+
*
24+
* @return LengthAwarePaginator<TKey, TValue>
1725
*/
1826
public function paginate(int $perPage = 15, ?int $page = null, string $pageName = 'page', bool $prepaginated = false): LengthAwarePaginator
1927
{
@@ -26,6 +34,8 @@ public function paginate(int $perPage = 15, ?int $page = null, string $pageName
2634

2735
/**
2836
* Create a new length-aware paginator instance.
37+
*
38+
* @return LengthAwarePaginator<TKey, TValue>
2939
*/
3040
protected function paginator(Collection $items, int $total, int $perPage, ?int $currentPage, string $pageName): LengthAwarePaginator
3141
{

src/Collections/ResponseCollection.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33
namespace DirectoryTree\ImapEngine\Collections;
44

55
use DirectoryTree\ImapEngine\Connection\Responses\ContinuationResponse;
6+
use DirectoryTree\ImapEngine\Connection\Responses\Response;
67
use DirectoryTree\ImapEngine\Connection\Responses\TaggedResponse;
78
use DirectoryTree\ImapEngine\Connection\Responses\UntaggedResponse;
89
use Illuminate\Support\Collection;
910

11+
/**
12+
* @template-extends Collection<array-key, Response>
13+
*/
1014
class ResponseCollection extends Collection
1115
{
1216
/**
1317
* Filter the collection to only tagged responses.
18+
*
19+
* @return self<array-key, TaggedResponse>
1420
*/
1521
public function tagged(): self
1622
{
@@ -19,6 +25,8 @@ public function tagged(): self
1925

2026
/**
2127
* Filter the collection to only untagged responses.
28+
*
29+
* @return self<array-key, UntaggedResponse>
2230
*/
2331
public function untagged(): self
2432
{
@@ -27,6 +35,8 @@ public function untagged(): self
2735

2836
/**
2937
* Filter the collection to only continuation responses.
38+
*
39+
* @return self<array-key, ContinuationResponse>
3040
*/
3141
public function continuation(): self
3242
{

src/Pagination/LengthAwarePaginator.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
use Illuminate\Support\Collection;
88
use JsonSerializable;
99

10+
/**
11+
* @template TKey of array-key
12+
* @template-covariant TValue
13+
*
14+
* @template-implements Arrayable<TKey, TValue>
15+
*/
1016
class LengthAwarePaginator implements Arrayable, JsonSerializable
1117
{
1218
use ForwardsCalls;
@@ -38,6 +44,8 @@ public function __call(string $method, array $parameters): mixed
3844

3945
/**
4046
* Get the items being paginated.
47+
*
48+
* @return Collection<TKey, TValue>
4149
*/
4250
public function items(): Collection
4351
{

0 commit comments

Comments
 (0)