| 1 | <?php namespace Comodojo\Extender\Components; |
||
| 25 | trait Iterator { |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Reset the iterator |
||
| 29 | */ |
||
| 30 | public function rewind() { |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Get the current element |
||
| 38 | * |
||
| 39 | * @return mixed |
||
| 40 | */ |
||
| 41 | public function current() { |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Return the current key |
||
| 49 | * |
||
| 50 | * @return string|int |
||
| 51 | */ |
||
| 52 | public function key() { |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Move to next element |
||
| 60 | */ |
||
| 61 | public function next() { |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Check if element is valid (isset) |
||
| 69 | * |
||
| 70 | * @return boolean |
||
| 71 | */ |
||
| 72 | public function valid() { |
||
| 77 | |||
| 78 | } |
||
| 79 |
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: