1 | <?php |
||
5 | trait PaginatedList |
||
6 | { |
||
7 | /* @var integer */ |
||
8 | protected $position = 0; |
||
9 | |||
10 | /** |
||
11 | * Rewind the Iterator to the first element. |
||
12 | * |
||
13 | * @link http://php.net/manual/en/iterator.rewind.php |
||
14 | * @return void |
||
15 | */ |
||
16 | public function rewind() |
||
20 | |||
21 | /** |
||
22 | * Checks if current position is valid. |
||
23 | * |
||
24 | * @link http://php.net/manual/en/iterator.valid.php |
||
25 | * @return boolean |
||
26 | */ |
||
27 | public function valid() |
||
35 | |||
36 | /** |
||
37 | * Return the current element |
||
38 | * @link http://php.net/manual/en/iterator.current.php |
||
39 | * @return mixed |
||
40 | */ |
||
41 | public function current() |
||
45 | |||
46 | /** |
||
47 | * Move forward to next element |
||
48 | * @link http://php.net/manual/en/iterator.next.php |
||
49 | * @return void |
||
50 | */ |
||
51 | public function next() |
||
55 | |||
56 | /** |
||
57 | * Return the key of the current element |
||
58 | * @link http://php.net/manual/en/iterator.key.php |
||
59 | * @return integer|null Scalar on success, or null on failure. |
||
60 | */ |
||
61 | public function key() |
||
65 | } |
||
66 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: