|
9 | 9 | /** |
10 | 10 | * Represents a normalized slice definition with start, end, and step values. |
11 | 11 | * |
12 | | - * @property-read int $start The start index of the normalized slice. |
13 | | - * @property-read int $end The end index of the normalized slice. |
14 | | - * @property-read int $step The step size for selecting elements in the normalized slice. |
15 | | - * |
16 | 12 | * @implements \IteratorAggregate<int, int> |
17 | 13 | */ |
18 | 14 | class NormalizedSlice extends Slice implements \Countable, \IteratorAggregate |
19 | 15 | { |
20 | 16 | /** |
21 | | - * @var int|null The start index of the normalized slice. |
| 17 | + * Creates a new NormalizedSlice instance with optional start, end, and step values. |
| 18 | + * |
| 19 | + * @param int|null $start The start index of the slice range. |
| 20 | + * @param int|null $end The end index of the slice range. |
| 21 | + * @param int|null $step The step size for selecting elements in the slice range. |
22 | 22 | */ |
23 | | - public ?int $start; // TODO int, not int|null, but phpstan do not like it. |
| 23 | + public function __construct(int $start = null, int $end = null, int $step = null) |
| 24 | + { |
| 25 | + parent::__construct($start, $end, $step); |
| 26 | + } |
| 27 | + |
24 | 28 | /** |
25 | | - * @var int|null The end index of the normalized slice. |
| 29 | + * Getter for the start index of the normalized slice. |
| 30 | + * |
| 31 | + * @return int |
26 | 32 | */ |
27 | | - public ?int $end; |
| 33 | + public function getStart(): int |
| 34 | + { |
| 35 | + /** @var int */ |
| 36 | + return $this->start; |
| 37 | + } |
| 38 | + |
28 | 39 | /** |
29 | | - * @var int|null The step size for selecting elements in the normalized slice. |
| 40 | + * Getter for the stop index of the normalized slice. |
| 41 | + * |
| 42 | + * @return int |
30 | 43 | */ |
31 | | - public ?int $step; |
| 44 | + public function getEnd(): int |
| 45 | + { |
| 46 | + /** @var int */ |
| 47 | + return $this->end; |
| 48 | + } |
32 | 49 |
|
33 | 50 | /** |
34 | | - * Creates a new NormalizedSlice instance with optional start, end, and step values. |
| 51 | + * Getter for the step of the normalized slice. |
35 | 52 | * |
36 | | - * @param int|null $start The start index of the slice range. |
37 | | - * @param int|null $end The end index of the slice range. |
38 | | - * @param int|null $step The step size for selecting elements in the slice range. |
| 53 | + * @return int |
39 | 54 | */ |
40 | | - public function __construct(int $start = null, int $end = null, int $step = null) |
| 55 | + public function getStep(): int |
41 | 56 | { |
42 | | - parent::__construct($start, $end, $step); |
| 57 | + /** @var int */ |
| 58 | + return $this->step; |
43 | 59 | } |
44 | 60 |
|
45 | 61 | /** |
|
0 commit comments