1 | <?php |
||
5 | trait EachTrait |
||
6 | { |
||
7 | /** |
||
8 | * Applies a callback to each element. |
||
9 | * (internally uses \CallbackFilterIterator). |
||
10 | * |
||
11 | * The passed callback will be invoked with the following argument: |
||
12 | * |
||
13 | * - $value (iterator's current()) |
||
14 | * |
||
15 | * If the second parameter is true the following arguments will be added |
||
16 | * to the call: |
||
17 | * |
||
18 | * - $key (iterator's key()) |
||
19 | * - $iterator (the iterator itself) |
||
20 | * |
||
21 | * @param callable $______callback a PHP callable (closure, string or array) |
||
22 | * @param bool $______allArgs if true key and iterator will be passed to the callback |
||
23 | * |
||
24 | * @return \Pipes\Pipe |
||
25 | */ |
||
26 | public function each(callable $______callback, $______allArgs = false) |
||
37 | } |
||
38 |
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.