1 | <?php |
||
24 | trait PrototypeHTMLElementTrait{ |
||
25 | use PrototypeElementTrait; |
||
26 | |||
27 | protected function magic_get_id():string{ |
||
30 | |||
31 | protected function magic_set_id(string $id){ |
||
34 | |||
35 | protected function magic_get_class():string{ |
||
38 | |||
39 | protected function magic_set_class(string $class){ |
||
42 | |||
43 | protected function magic_get_href():string{ |
||
46 | |||
47 | protected function magic_set_href(string $href){ |
||
50 | |||
51 | protected function magic_get_src():string{ |
||
54 | |||
55 | protected function magic_set_src(string $src){ |
||
58 | |||
59 | protected function magic_get_innerHTML():string{ |
||
62 | |||
63 | /** |
||
64 | * http://api.prototypejs.org/dom/Element/identify/ |
||
65 | * |
||
66 | * @param string|null $newID |
||
67 | * |
||
68 | * @return string |
||
69 | */ |
||
70 | public function identify(string $newID = null):string{ |
||
79 | |||
80 | /** |
||
81 | * @link http://api.prototypejs.org/dom/Element/classNames/ |
||
82 | * |
||
83 | * @return array |
||
84 | */ |
||
85 | public function classNames():array{ |
||
105 | |||
106 | /** |
||
107 | * @link http://api.prototypejs.org/dom/Element/hasClassName/ |
||
108 | * |
||
109 | * @param string $classname |
||
110 | * |
||
111 | * @return bool |
||
112 | */ |
||
113 | public function hasClassName(string $classname):bool{ |
||
116 | |||
117 | /** |
||
118 | * @link http://api.prototypejs.org/dom/Element/addClassName/ |
||
119 | * |
||
120 | * @param string $classname |
||
121 | * |
||
122 | * @return \chillerlan\PrototypeDOM\Node\PrototypeHTMLElement |
||
123 | */ |
||
124 | public function addClassName(string $classname):PrototypeHTMLElement{ |
||
127 | |||
128 | /** |
||
129 | * @link http://api.prototypejs.org/dom/Element/removeClassName/ |
||
130 | * |
||
131 | * @param string $classname |
||
132 | * |
||
133 | * @return \chillerlan\PrototypeDOM\Node\PrototypeHTMLElement |
||
134 | */ |
||
135 | public function removeClassName(string $classname):PrototypeHTMLElement{ |
||
138 | |||
139 | /** |
||
140 | * @link http://api.prototypejs.org/dom/Element/toggleClassName/ |
||
141 | * |
||
142 | * @param string $classname |
||
143 | * |
||
144 | * @return \chillerlan\PrototypeDOM\Node\PrototypeHTMLElement |
||
145 | */ |
||
146 | public function toggleClassName(string $classname):PrototypeHTMLElement{ |
||
154 | |||
155 | /** |
||
156 | * @link http://api.prototypejs.org/dom/Element/getStyle/ |
||
157 | * |
||
158 | * @param string $property |
||
159 | * |
||
160 | * @return null|string |
||
161 | */ |
||
162 | public function getStyle(string $property):?string{ |
||
171 | |||
172 | /** |
||
173 | * @link http://api.prototypejs.org/dom/Element/setStyle/ |
||
174 | * |
||
175 | * @param array $style |
||
176 | * @param bool $replace |
||
177 | * |
||
178 | * @return \chillerlan\PrototypeDOM\Node\PrototypeHTMLElement |
||
179 | */ |
||
180 | public function setStyle(array $style, bool $replace = null):PrototypeHTMLElement{ |
||
195 | |||
196 | } |
||
197 |
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.