1 | <?php |
||
5 | trait IterableImplementation |
||
6 | { |
||
7 | protected $position = 0; |
||
8 | |||
9 | public function offsetGet($offset) |
||
13 | |||
14 | public function offsetSet($offset, $value) |
||
24 | |||
25 | public function offsetExists($offset) |
||
29 | |||
30 | public function offsetUnset($offset) |
||
34 | |||
35 | public function next() |
||
39 | |||
40 | public function key() |
||
44 | |||
45 | public function valid() |
||
49 | |||
50 | public function rewind() |
||
54 | |||
55 | public function count(): int |
||
59 | } |
||
60 |
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: