1 | <?php |
||
22 | trait HTMLElementTrait{ |
||
23 | use Magic, ElementTrait; |
||
24 | |||
25 | 12 | protected function magic_get_id():string { |
|
28 | |||
29 | 1 | protected function magic_set_id($id) { |
|
32 | |||
33 | 6 | protected function magic_get_class():string { |
|
36 | |||
37 | 3 | protected function magic_set_class($class) { |
|
40 | |||
41 | 3 | protected function magic_get_innerHTML():string { |
|
44 | |||
45 | /** |
||
46 | * http://api.prototypejs.org/dom/Element/identify/ |
||
47 | * |
||
48 | * @param string|null $newID |
||
49 | * |
||
50 | * @return string |
||
51 | */ |
||
52 | 1 | public function identify(string $newID = null):string { |
|
61 | |||
62 | /** |
||
63 | * @link http://api.prototypejs.org/dom/Element/classNames/ |
||
64 | * |
||
65 | * @return array |
||
66 | */ |
||
67 | 6 | public function classNames():array{ |
|
90 | |||
91 | /** |
||
92 | * @link http://api.prototypejs.org/dom/Element/hasClassName/ |
||
93 | * |
||
94 | * @param string $classname |
||
95 | * |
||
96 | * @return bool |
||
97 | */ |
||
98 | 5 | public function hasClassName(string $classname):bool{ |
|
101 | |||
102 | /** |
||
103 | * @link http://api.prototypejs.org/dom/Element/addClassName/ |
||
104 | * |
||
105 | * @param string $classname |
||
106 | * |
||
107 | * @return \chillerlan\PrototypeDOM\Node\PrototypeHTMLElement |
||
108 | */ |
||
109 | 2 | public function addClassName(string $classname):PrototypeHTMLElement{ |
|
112 | |||
113 | /** |
||
114 | * @link http://api.prototypejs.org/dom/Element/removeClassName/ |
||
115 | * |
||
116 | * @param string $classname |
||
117 | * |
||
118 | * @return \chillerlan\PrototypeDOM\Node\PrototypeHTMLElement |
||
119 | */ |
||
120 | 2 | public function removeClassName(string $classname):PrototypeHTMLElement{ |
|
123 | |||
124 | /** |
||
125 | * @link http://api.prototypejs.org/dom/Element/toggleClassName/ |
||
126 | * |
||
127 | * @param string $classname |
||
128 | * |
||
129 | * @return \chillerlan\PrototypeDOM\Node\PrototypeHTMLElement |
||
130 | */ |
||
131 | 1 | public function toggleClassName(string $classname):PrototypeHTMLElement{ |
|
137 | |||
138 | /** |
||
139 | * @link http://api.prototypejs.org/dom/Element/getStyle/ |
||
140 | * |
||
141 | * @param string $property |
||
142 | * |
||
143 | * @return null|string |
||
144 | */ |
||
145 | 2 | public function getStyle(string $property){ |
|
154 | |||
155 | /** |
||
156 | * @link http://api.prototypejs.org/dom/Element/setStyle/ |
||
157 | * |
||
158 | * @param array $style |
||
159 | * @param bool $replace |
||
160 | * |
||
161 | * @return \chillerlan\PrototypeDOM\Node\PrototypeHTMLElement |
||
162 | */ |
||
163 | 2 | public function setStyle(array $style, bool $replace = false):PrototypeHTMLElement{ |
|
178 | |||
179 | |||
180 | } |
||
181 |
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.