1 | <?php |
||
21 | trait TraversalTrait{ |
||
22 | |||
23 | /** |
||
24 | * @param $selector |
||
25 | * @param $index |
||
26 | * @param string $property |
||
27 | * @param int $nodeType https://secure.php.net/manual/dom.constants.php |
||
28 | * |
||
29 | * @return \chillerlan\PrototypeDOM\Node\PrototypeNode|null |
||
30 | */ |
||
31 | public function recursivelyFind($selector, int $index = null, string $property = null, int $nodeType = \XML_ELEMENT_NODE):?PrototypeNode{ |
||
39 | |||
40 | /** |
||
41 | * @link http://api.prototypejs.org/dom/Element/select/ |
||
42 | * |
||
43 | * @param array $selectors |
||
44 | * |
||
45 | * @return \chillerlan\PrototypeDOM\NodeList |
||
46 | */ |
||
47 | public function select(array $selectors = null):NodeList{ |
||
50 | |||
51 | /** |
||
52 | * @link http://api.prototypejs.org/dom/Element/match/ |
||
53 | * |
||
54 | * @param string $selector |
||
55 | * |
||
56 | * @return bool |
||
57 | */ |
||
58 | public function match(string $selector):bool{ |
||
61 | |||
62 | /** |
||
63 | * @link http://api.prototypejs.org/dom/Element/down/ |
||
64 | * |
||
65 | * @param null $expression |
||
66 | * @param int $index |
||
67 | * |
||
68 | * @return \chillerlan\PrototypeDOM\Node\PrototypeNode|null |
||
69 | */ |
||
70 | public function down($expression = null, int $index = null):?PrototypeNode{ |
||
88 | |||
89 | /** |
||
90 | * @link http://api.prototypejs.org/dom/Element/up/ |
||
91 | * |
||
92 | * @param string|null $expression |
||
93 | * @param int|null $index |
||
94 | * |
||
95 | * @return \chillerlan\PrototypeDOM\Node\PrototypeNode|null |
||
96 | */ |
||
97 | public function up($expression = null, int $index = null):?PrototypeNode{ |
||
100 | |||
101 | /** |
||
102 | * @link http://api.prototypejs.org/dom/Element/previous/ |
||
103 | * |
||
104 | * @param string|null $expression |
||
105 | * @param int|null $index |
||
106 | * |
||
107 | * @return \chillerlan\PrototypeDOM\Node\PrototypeNode|null |
||
108 | */ |
||
109 | public function previous($expression = null, int $index = null):?PrototypeNode{ |
||
112 | |||
113 | /** |
||
114 | * @link http://api.prototypejs.org/dom/Element/next/ |
||
115 | * |
||
116 | * @param string|null $expression |
||
117 | * @param int|null $index |
||
118 | * |
||
119 | * @return \chillerlan\PrototypeDOM\Node\PrototypeNode|null |
||
120 | */ |
||
121 | public function next($expression = null, int $index = null):?PrototypeNode{ |
||
124 | |||
125 | /** |
||
126 | * @link http://api.prototypejs.org/dom/Element/childElements/ |
||
127 | * |
||
128 | * @param int $nodeType https://secure.php.net/manual/dom.constants.php |
||
129 | * |
||
130 | * @return \chillerlan\PrototypeDOM\NodeList |
||
131 | */ |
||
132 | public function childElements(int $nodeType = \XML_ELEMENT_NODE):NodeList{ |
||
149 | |||
150 | /** |
||
151 | * @link http://api.prototypejs.org/dom/Element/descendantOf/ |
||
152 | * |
||
153 | * @param \DOMNode $ancestor |
||
154 | * |
||
155 | * @return bool |
||
156 | */ |
||
157 | public function descendantOf(DOMNode $ancestor):bool{ |
||
160 | |||
161 | /** |
||
162 | * @link http://api.prototypejs.org/dom/Element/ancestors/ |
||
163 | * |
||
164 | * @return \chillerlan\PrototypeDOM\NodeList |
||
165 | */ |
||
166 | public function ancestors():NodeList{ |
||
169 | |||
170 | /** |
||
171 | * @link http://api.prototypejs.org/dom/Element/siblings/ |
||
172 | * |
||
173 | * @return \chillerlan\PrototypeDOM\NodeList |
||
174 | */ |
||
175 | public function siblings():NodeList{ |
||
178 | |||
179 | /** |
||
180 | * @link http://api.prototypejs.org/dom/Element/descendants/ |
||
181 | * |
||
182 | * @return \chillerlan\PrototypeDOM\NodeList |
||
183 | */ |
||
184 | public function descendants():NodeList{ |
||
187 | |||
188 | /** |
||
189 | * @link http://api.prototypejs.org/dom/Element/firstDescendant/ |
||
190 | * |
||
191 | * @return \chillerlan\PrototypeDOM\Node\PrototypeNode|null |
||
192 | */ |
||
193 | public function firstDescendant():?PrototypeNode{ |
||
196 | |||
197 | /** |
||
198 | * @link http://api.prototypejs.org/dom/Element/previousSiblings/ |
||
199 | * |
||
200 | * @return \chillerlan\PrototypeDOM\NodeList |
||
201 | */ |
||
202 | public function previousSiblings():NodeList{ |
||
205 | |||
206 | /** |
||
207 | * @link http://api.prototypejs.org/dom/Element/nextSiblings/ |
||
208 | * |
||
209 | * @return \chillerlan\PrototypeDOM\NodeList |
||
210 | */ |
||
211 | public function nextSiblings():NodeList{ |
||
214 | |||
215 | } |
||
216 |
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.