| 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() |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Checks if current position is valid. |
||
| 26 | * |
||
| 27 | * @link http://php.net/manual/en/iterator.valid.php |
||
| 28 | * |
||
| 29 | * @return bool |
||
| 30 | */ |
||
| 31 | public function valid() |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Return the current element. |
||
| 42 | * |
||
| 43 | * @link http://php.net/manual/en/iterator.current.php |
||
| 44 | * |
||
| 45 | * @return mixed |
||
| 46 | */ |
||
| 47 | public function current() |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Move forward to next element. |
||
| 54 | * |
||
| 55 | * @link http://php.net/manual/en/iterator.next.php |
||
| 56 | * |
||
| 57 | * @return void |
||
| 58 | */ |
||
| 59 | public function next() |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Return the key of the current element. |
||
| 66 | * |
||
| 67 | * @link http://php.net/manual/en/iterator.key.php |
||
| 68 | * |
||
| 69 | * @return int|null Scalar on success, or null on failure. |
||
| 70 | */ |
||
| 71 | public function key() |
||
| 75 | } |
||
| 76 |
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: