1 | <?php |
||
24 | trait HTMLElementTrait{ |
||
25 | |||
26 | protected function magic_get_id():string{ |
||
29 | |||
30 | protected function magic_set_id($id){ |
||
33 | |||
34 | protected function magic_get_class():string{ |
||
37 | |||
38 | protected function magic_set_class($class){ |
||
41 | |||
42 | protected function magic_get_href():string{ |
||
45 | |||
46 | protected function magic_set_href($class){ |
||
49 | |||
50 | protected function magic_get_src():string{ |
||
53 | |||
54 | protected function magic_set_src($class){ |
||
57 | |||
58 | protected function magic_get_innerHTML():string{ |
||
61 | |||
62 | /** |
||
63 | * http://api.prototypejs.org/dom/Element/identify/ |
||
64 | * |
||
65 | * @param string|null $newID |
||
66 | * |
||
67 | * @return string |
||
68 | */ |
||
69 | public function identify(string $newID = null):string{ |
||
78 | |||
79 | /** |
||
80 | * @link http://api.prototypejs.org/dom/Element/classNames/ |
||
81 | * |
||
82 | * @return array |
||
83 | */ |
||
84 | public function classNames():array{ |
||
104 | |||
105 | /** |
||
106 | * @link http://api.prototypejs.org/dom/Element/hasClassName/ |
||
107 | * |
||
108 | * @param string $classname |
||
109 | * |
||
110 | * @return bool |
||
111 | */ |
||
112 | public function hasClassName(string $classname):bool{ |
||
115 | |||
116 | /** |
||
117 | * @link http://api.prototypejs.org/dom/Element/addClassName/ |
||
118 | * |
||
119 | * @param string $classname |
||
120 | * |
||
121 | * @return \chillerlan\PrototypeDOM\Node\PrototypeHTMLElement |
||
122 | */ |
||
123 | public function addClassName(string $classname):PrototypeHTMLElement{ |
||
126 | |||
127 | /** |
||
128 | * @link http://api.prototypejs.org/dom/Element/removeClassName/ |
||
129 | * |
||
130 | * @param string $classname |
||
131 | * |
||
132 | * @return \chillerlan\PrototypeDOM\Node\PrototypeHTMLElement |
||
133 | */ |
||
134 | public function removeClassName(string $classname):PrototypeHTMLElement{ |
||
137 | |||
138 | /** |
||
139 | * @link http://api.prototypejs.org/dom/Element/toggleClassName/ |
||
140 | * |
||
141 | * @param string $classname |
||
142 | * |
||
143 | * @return \chillerlan\PrototypeDOM\Node\PrototypeHTMLElement |
||
144 | */ |
||
145 | public function toggleClassName(string $classname):PrototypeHTMLElement{ |
||
153 | |||
154 | /** |
||
155 | * @link http://api.prototypejs.org/dom/Element/getStyle/ |
||
156 | * |
||
157 | * @param string $property |
||
158 | * |
||
159 | * @return null|string |
||
160 | */ |
||
161 | public function getStyle(string $property):?string{ |
||
170 | |||
171 | /** |
||
172 | * @link http://api.prototypejs.org/dom/Element/setStyle/ |
||
173 | * |
||
174 | * @param array $style |
||
175 | * @param bool $replace |
||
176 | * |
||
177 | * @return \chillerlan\PrototypeDOM\Node\PrototypeHTMLElement |
||
178 | */ |
||
179 | public function setStyle(array $style, bool $replace = null):PrototypeHTMLElement{ |
||
194 | |||
195 | } |
||
196 |
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.