1 | <?php |
||
17 | trait ChildTrait |
||
18 | { |
||
19 | /** |
||
20 | * @var ElementStorage |
||
21 | */ |
||
22 | protected $child; |
||
23 | |||
24 | /** |
||
25 | * @param string $name |
||
26 | * |
||
27 | * @return ContainerInterface[] |
||
28 | */ |
||
29 | 8 | public function getChild($name) |
|
44 | |||
45 | /** |
||
46 | * @param $id |
||
47 | * |
||
48 | * @return ContainerInterface |
||
49 | */ |
||
50 | 4 | public function getChildById($id) |
|
69 | |||
70 | /** |
||
71 | * @return ContainerInterface|null |
||
72 | */ |
||
73 | 66 | public function getFirstChild() |
|
81 | |||
82 | /** |
||
83 | * @return bool |
||
84 | */ |
||
85 | 66 | public function hasChild() |
|
89 | |||
90 | /** |
||
91 | * @return ContainerInterface[]|ElementStorage |
||
92 | */ |
||
93 | 2 | public function getChildren() |
|
97 | |||
98 | /** |
||
99 | * @param $index |
||
100 | * |
||
101 | * @return ContainerInterface|SVGElement|null |
||
102 | */ |
||
103 | 9 | public function getChildAtIndex($index) |
|
107 | |||
108 | /** |
||
109 | * @param ElementInterface $child |
||
110 | */ |
||
111 | 11 | public function removeChild(ElementInterface $child) |
|
122 | } |
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.