18
18
* @property int $page
19
19
* @property-read int $firstPage
20
20
* @property-read int|null $lastPage
21
- * @property-read int $firstItemOnPage
22
- * @property-read int $lastItemOnPage
21
+ * @property-read int<0,max> $firstItemOnPage
22
+ * @property-read int<0,max> $lastItemOnPage
23
23
* @property int $base
24
24
* @property-read bool $first
25
25
* @property-read bool $last
26
- * @property-read int|null $pageCount
27
- * @property int $itemsPerPage
28
- * @property int|null $itemCount
29
- * @property-read int $offset
30
- * @property-read int|null $countdownOffset
31
- * @property-read int $length
26
+ * @property-read int<0,max> |null $pageCount
27
+ * @property positive- int $itemsPerPage
28
+ * @property int<0,max> |null $itemCount
29
+ * @property-read int<0,max> $offset
30
+ * @property-read int<0,max> |null $countdownOffset
31
+ * @property-read int<0,max> $length
32
32
*/
33
33
class Paginator
34
34
{
35
35
use Nette \SmartObject;
36
36
37
37
private int $ base = 1 ;
38
+
39
+ /** @var positive-int */
38
40
private int $ itemsPerPage = 1 ;
41
+
39
42
private int $ page = 1 ;
43
+
44
+ /** @var int<0, max>|null */
40
45
private ?int $ itemCount = null ;
41
46
42
47
@@ -81,6 +86,7 @@ public function getLastPage(): ?int
81
86
82
87
/**
83
88
* Returns the sequence number of the first element on the page
89
+ * @return int<0, max>
84
90
*/
85
91
public function getFirstItemOnPage (): int
86
92
{
@@ -92,6 +98,7 @@ public function getFirstItemOnPage(): int
92
98
93
99
/**
94
100
* Returns the sequence number of the last element on the page
101
+ * @return int<0, max>
95
102
*/
96
103
public function getLastItemOnPage (): int
97
104
{
@@ -120,6 +127,7 @@ public function getBase(): int
120
127
121
128
/**
122
129
* Returns zero-based page number.
130
+ * @return int<0, max>
123
131
*/
124
132
protected function getPageIndex (): int
125
133
{
@@ -152,6 +160,7 @@ public function isLast(): bool
152
160
153
161
/**
154
162
* Returns the total number of pages.
163
+ * @return int<0, max>|null
155
164
*/
156
165
public function getPageCount (): ?int
157
166
{
@@ -173,6 +182,7 @@ public function setItemsPerPage(int $itemsPerPage): static
173
182
174
183
/**
175
184
* Returns the number of items to display on a single page.
185
+ * @return positive-int
176
186
*/
177
187
public function getItemsPerPage (): int
178
188
{
@@ -192,6 +202,7 @@ public function setItemCount(?int $itemCount = null): static
192
202
193
203
/**
194
204
* Returns the total number of items.
205
+ * @return int<0, max>|null
195
206
*/
196
207
public function getItemCount (): ?int
197
208
{
@@ -201,6 +212,7 @@ public function getItemCount(): ?int
201
212
202
213
/**
203
214
* Returns the absolute index of the first item on current page.
215
+ * @return int<0, max>
204
216
*/
205
217
public function getOffset (): int
206
218
{
@@ -210,6 +222,7 @@ public function getOffset(): int
210
222
211
223
/**
212
224
* Returns the absolute index of the first item on current page in countdown paging.
225
+ * @return int<0, max>|null
213
226
*/
214
227
public function getCountdownOffset (): ?int
215
228
{
@@ -221,6 +234,7 @@ public function getCountdownOffset(): ?int
221
234
222
235
/**
223
236
* Returns the number of items on current page.
237
+ * @return int<0, max>
224
238
*/
225
239
public function getLength (): int
226
240
{
0 commit comments