| 1 | <?php |
||
| 5 | trait ValuesTrait |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Returns all the elements, reindexes the keys (0,1,2,..,n). |
||
| 9 | * |
||
| 10 | * Use this to avoid key collisions. |
||
| 11 | * |
||
| 12 | * @return \Pipes\Pipe |
||
| 13 | */ |
||
| 14 | public function values() |
||
| 18 | |||
| 19 | /* |
||
| 20 | * Discards the keys, returns an indexed array. |
||
| 21 | * |
||
| 22 | * Shortcut for <code>p($iterator)->values->toArray();</code> |
||
| 23 | */ |
||
| 24 | public function toValues() |
||
| 28 | } |
||
| 29 |
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
Idableprovides a methodequalsIdthat 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.