1 | <?php |
||
17 | trait EnumerableTrait{ |
||
18 | |||
19 | /** |
||
20 | * @link http://api.prototypejs.org/language/Enumerable/prototype/each/ |
||
21 | * |
||
22 | * @param callable $callback |
||
23 | * |
||
24 | * @return $this |
||
25 | */ |
||
26 | 1 | public function each($callback){ |
|
31 | |||
32 | /** |
||
33 | * @link http://api.prototypejs.org/language/Array/prototype/first/ |
||
34 | * |
||
35 | * @return \chillerlan\PrototypeDOM\Node\Element|null |
||
36 | */ |
||
37 | 3 | public function first(){ |
|
40 | |||
41 | /** |
||
42 | * @link http://api.prototypejs.org/language/Array/prototype/last/ |
||
43 | * |
||
44 | * @return \chillerlan\PrototypeDOM\Node\Element|null |
||
45 | */ |
||
46 | 1 | public function last(){ |
|
49 | |||
50 | /** |
||
51 | * @link http://api.prototypejs.org/language/Enumerable/prototype/collect/ |
||
52 | * @link http://api.prototypejs.org/language/Enumerable/prototype/map/ |
||
53 | * |
||
54 | * @param $callback |
||
55 | * |
||
56 | * @return array |
||
57 | * @throws \Exception |
||
58 | */ |
||
59 | 3 | public function map($callback):array { |
|
73 | |||
74 | /** |
||
75 | * @link http://api.prototypejs.org/language/Enumerable/prototype/pluck/ |
||
76 | * |
||
77 | * @param string $property |
||
78 | * |
||
79 | * @return array |
||
80 | */ |
||
81 | 3 | public function pluck(string $property):array { |
|
84 | |||
85 | /** |
||
86 | * @link http://api.prototypejs.org/language/Array/prototype/reverse/ |
||
87 | * |
||
88 | * @return $this |
||
89 | */ |
||
90 | 3 | public function reverse(){ |
|
96 | |||
97 | /** |
||
98 | * @link http://api.prototypejs.org/language/Enumerable/prototype/toArray/ |
||
99 | * |
||
100 | * @return array |
||
101 | */ |
||
102 | 1 | public function toArray():array { |
|
105 | |||
106 | } |
||
107 |
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.