1 | <?php |
||
11 | trait DelegatedArrayTrait |
||
12 | { |
||
13 | public function count() |
||
17 | |||
18 | public function offsetExists($name) |
||
22 | |||
23 | public function offsetSet($name, $field) |
||
27 | |||
28 | public function offsetUnset($name) |
||
32 | |||
33 | public function offsetGet($name) |
||
37 | |||
38 | /** |
||
39 | * (PHP 5 >= 5.0.0)<br/> |
||
40 | * Retrieve an external iterator. |
||
41 | * |
||
42 | * @link http://php.net/manual/en/iteratoraggregate.getiterator.php |
||
43 | * |
||
44 | * @return Traversable An instance of an object implementing <b>Iterator</b> or |
||
45 | * <b>Traversable</b> |
||
46 | */ |
||
47 | public function getIterator() |
||
51 | |||
52 | public function toArray() |
||
56 | |||
57 | public function exchangeArray($array) |
||
61 | } |
||
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.