1 | <?php |
||
19 | trait EnumerableTrait{ |
||
20 | use Enumerable{ |
||
21 | __map as map; |
||
22 | __each as each; |
||
23 | __toArray as toArray; |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @link http://api.prototypejs.org/language/Array/prototype/first/ |
||
28 | * |
||
29 | * @return \chillerlan\PrototypeDOM\Node\Element|null |
||
30 | */ |
||
31 | 3 | public function first(){ |
|
34 | |||
35 | /** |
||
36 | * @link http://api.prototypejs.org/language/Array/prototype/last/ |
||
37 | * |
||
38 | * @return \chillerlan\PrototypeDOM\Node\Element|null |
||
39 | */ |
||
40 | 1 | public function last(){ |
|
43 | |||
44 | /** |
||
45 | * @link http://api.prototypejs.org/language/Enumerable/prototype/pluck/ |
||
46 | * |
||
47 | * @param string $property |
||
48 | * |
||
49 | * @return array |
||
50 | */ |
||
51 | 3 | public function pluck(string $property):array { |
|
54 | |||
55 | /** |
||
56 | * @link http://api.prototypejs.org/language/Array/prototype/reverse/ |
||
57 | * |
||
58 | * @return $this |
||
59 | */ |
||
60 | 3 | public function reverse(){ |
|
66 | |||
67 | /** |
||
68 | * @link http://api.prototypejs.org/language/Enumerable/prototype/toArray/ |
||
69 | * |
||
70 | * @return array |
||
71 | */ |
||
72 | 1 | public function toArray():array { |
|
75 | |||
76 | } |
||
77 |
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.