| 1 | <?php |
||
| 5 | trait PaginatedListGenerator |
||
| 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 | * |
||
| 15 | * @return void |
||
| 16 | */ |
||
| 17 | public function rewind() |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Checks if current position is valid. |
||
| 24 | * |
||
| 25 | * @link http://php.net/manual/en/iterator.valid.php |
||
| 26 | * |
||
| 27 | * @return bool |
||
| 28 | */ |
||
| 29 | public function valid() |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Return the current element. |
||
| 40 | * |
||
| 41 | * @link http://php.net/manual/en/iterator.current.php |
||
| 42 | * |
||
| 43 | * @return mixed |
||
| 44 | */ |
||
| 45 | public function current() |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Move forward to next element. |
||
| 52 | * |
||
| 53 | * @link http://php.net/manual/en/iterator.next.php |
||
| 54 | * |
||
| 55 | * @return void |
||
| 56 | */ |
||
| 57 | public function next() |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Return the key of the current element. |
||
| 64 | * |
||
| 65 | * @link http://php.net/manual/en/iterator.key.php |
||
| 66 | * |
||
| 67 | * @return int|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: