1 | <?php |
||
5 | trait IteratorTrait |
||
6 | { |
||
7 | /** |
||
8 | * Rewind the Iterator to the first element |
||
9 | * |
||
10 | * @return void |
||
11 | */ |
||
12 | public function rewind() |
||
16 | |||
17 | /** |
||
18 | * Return the current element. |
||
19 | * |
||
20 | * @return mixed |
||
21 | */ |
||
22 | public function current() |
||
26 | |||
27 | /** |
||
28 | * Return the key of the current element |
||
29 | * |
||
30 | * @return mixed |
||
31 | */ |
||
32 | public function key() |
||
36 | |||
37 | /** |
||
38 | * Move forward to next element. |
||
39 | * |
||
40 | * @return void |
||
41 | */ |
||
42 | public function next() |
||
46 | |||
47 | /** |
||
48 | * Checks if current position is valid. |
||
49 | * |
||
50 | * @return boolean |
||
51 | */ |
||
52 | public function valid() |
||
56 | } |
||
57 |
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: