1 | <?php |
||
5 | trait PaginatedList |
||
6 | { |
||
7 | /* @var integer */ |
||
8 | protected $position = 0; |
||
9 | |||
10 | /** |
||
11 | * Fetch all the data. |
||
12 | */ |
||
13 | protected function fetchData() |
||
17 | |||
18 | /** |
||
19 | * Rewind the Iterator to the first element. |
||
20 | * |
||
21 | * @link http://php.net/manual/en/iterator.rewind.php |
||
22 | * @return void |
||
23 | */ |
||
24 | public function rewind() |
||
28 | |||
29 | /** |
||
30 | * Checks if current position is valid. |
||
31 | * |
||
32 | * @link http://php.net/manual/en/iterator.valid.php |
||
33 | * @return boolean |
||
34 | */ |
||
35 | public function valid() |
||
43 | |||
44 | /** |
||
45 | * Return the current element |
||
46 | * @link http://php.net/manual/en/iterator.current.php |
||
47 | * @return mixed |
||
48 | */ |
||
49 | public function current() |
||
53 | |||
54 | /** |
||
55 | * Move forward to next element |
||
56 | * @link http://php.net/manual/en/iterator.next.php |
||
57 | * @return void |
||
58 | */ |
||
59 | public function next() |
||
63 | |||
64 | /** |
||
65 | * Return the key of the current element |
||
66 | * @link http://php.net/manual/en/iterator.key.php |
||
67 | * @return integer|null Scalar on success, or null on failure. |
||
68 | */ |
||
69 | public function key() |
||
73 | } |
||
74 |
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: