1 | <?php |
||
18 | class Node |
||
19 | { |
||
20 | /** |
||
21 | * Node document. |
||
22 | * |
||
23 | * @var DOMDocument |
||
24 | */ |
||
25 | protected $document; |
||
26 | |||
27 | /** |
||
28 | * Node element. |
||
29 | * |
||
30 | * @var DOMElement |
||
31 | */ |
||
32 | protected $element; |
||
33 | |||
34 | /** |
||
35 | * Define the parent node name. |
||
36 | * |
||
37 | * @var string|null |
||
38 | */ |
||
39 | protected $parentNodeName = null; |
||
40 | |||
41 | /** |
||
42 | * Define the node name. |
||
43 | * |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $nodeName; |
||
47 | |||
48 | /** |
||
49 | * Node attributes. |
||
50 | * |
||
51 | * @var array |
||
52 | */ |
||
53 | protected $attr = []; |
||
54 | |||
55 | protected $outstandingReferences; |
||
56 | |||
57 | /** |
||
58 | * Create a new node instance. |
||
59 | * |
||
60 | * @param array $attr |
||
61 | */ |
||
62 | public function __construct(array ...$attr) |
||
75 | |||
76 | /** |
||
77 | * Add a new node. |
||
78 | * |
||
79 | * @param \Kinedu\CfdiXML\Common\Node $node |
||
80 | * |
||
81 | * @return void |
||
82 | */ |
||
83 | public function add(Node $node) |
||
146 | |||
147 | /** |
||
148 | * Search the direct child of an element. |
||
149 | * |
||
150 | * @param DOMNodeList $children |
||
151 | * @param string $find |
||
152 | * |
||
153 | * @return DOMElement|null |
||
154 | */ |
||
155 | protected function getDirectChildElementByName(DOMNodeList $children, string $find) |
||
165 | |||
166 | /** |
||
167 | * @param \Kinedu\CfdiXML\Common\Node $node |
||
168 | * @return void |
||
169 | */ |
||
170 | public function setNamespace(Node $node) |
||
200 | |||
201 | /** |
||
202 | * @param string $schemaDefinition |
||
203 | * @return void |
||
204 | */ |
||
205 | public function setSchemaDefinition(string $schemaDefinition) |
||
220 | |||
221 | private function hasOutstandingReferences(): bool |
||
225 | |||
226 | /** |
||
227 | * Get node attributes. |
||
228 | * |
||
229 | * @param string $index |
||
230 | * |
||
231 | * @return array|null |
||
232 | */ |
||
233 | public function getAttr(string $index = 'node') |
||
243 | |||
244 | /** |
||
245 | * Adds attributes to an element. |
||
246 | * |
||
247 | * @param DOMElement $element |
||
248 | * @param array $attr |
||
249 | * |
||
250 | * @return void |
||
251 | */ |
||
252 | public function setAttr(DOMElement $element, array $attr = null) |
||
260 | |||
261 | /** |
||
262 | * Get element. |
||
263 | * |
||
264 | * @return DOMElement |
||
265 | */ |
||
266 | public function getElement(): DOMElement |
||
270 | |||
271 | /** |
||
272 | * Get document. |
||
273 | * |
||
274 | * @return DOMDocument |
||
275 | */ |
||
276 | public function getDocument(): DOMDocument |
||
280 | |||
281 | /** |
||
282 | * Get wrapper node name. |
||
283 | * |
||
284 | * @return string|null |
||
285 | */ |
||
286 | public function getWrapperNodeName() |
||
290 | |||
291 | /** |
||
292 | * Get parent node name. |
||
293 | * |
||
294 | * @return string|null |
||
295 | */ |
||
296 | public function getParentNodeName() |
||
300 | |||
301 | /** |
||
302 | * Get node name. |
||
303 | * |
||
304 | * @return string |
||
305 | */ |
||
306 | public function getNodeName() |
||
310 | } |
||
311 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.