1 | <?php |
||
8 | trait IteratorTrait |
||
9 | { |
||
10 | private $container; |
||
11 | |||
12 | protected function getData() |
||
21 | |||
22 | protected $position = 0; |
||
23 | |||
24 | public function key() |
||
28 | |||
29 | public function current() |
||
33 | |||
34 | public function next() |
||
38 | |||
39 | public function prev() |
||
43 | |||
44 | public function rewind() |
||
48 | |||
49 | public function valid() |
||
53 | |||
54 | public function seek($position) |
||
62 | } |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.