xref: /PHP-8.2/ext/dom/php_dom.stub.php (revision 90785dd8)
1<?php
2
3/** @generate-class-entries */
4
5namespace
6{
7    /**
8     * @var int
9     * @cvalue XML_ELEMENT_NODE
10     */
11    const XML_ELEMENT_NODE = UNKNOWN;
12    /**
13     * @var int
14     * @cvalue XML_ATTRIBUTE_NODE
15     */
16    const XML_ATTRIBUTE_NODE = UNKNOWN;
17    /**
18     * @var int
19     * @cvalue XML_TEXT_NODE
20     */
21    const XML_TEXT_NODE = UNKNOWN;
22    /**
23     * @var int
24     * @cvalue XML_CDATA_SECTION_NODE
25     */
26    const XML_CDATA_SECTION_NODE = UNKNOWN;
27    /**
28     * @var int
29     * @cvalue XML_ENTITY_REF_NODE
30     */
31    const XML_ENTITY_REF_NODE = UNKNOWN;
32    /**
33     * @var int
34     * @cvalue XML_ENTITY_NODE
35     */
36    const XML_ENTITY_NODE = UNKNOWN;
37    /**
38     * @var int
39     * @cvalue XML_PI_NODE
40     */
41    const XML_PI_NODE = UNKNOWN;
42    /**
43     * @var int
44     * @cvalue XML_COMMENT_NODE
45     */
46    const XML_COMMENT_NODE = UNKNOWN;
47    /**
48     * @var int
49     * @cvalue XML_DOCUMENT_NODE
50     */
51    const XML_DOCUMENT_NODE = UNKNOWN;
52    /**
53     * @var int
54     * @cvalue XML_DOCUMENT_TYPE_NODE
55     */
56    const XML_DOCUMENT_TYPE_NODE = UNKNOWN;
57    /**
58     * @var int
59     * @cvalue XML_DOCUMENT_FRAG_NODE
60     */
61    const XML_DOCUMENT_FRAG_NODE = UNKNOWN;
62    /**
63     * @var int
64     * @cvalue XML_NOTATION_NODE
65     */
66    const XML_NOTATION_NODE = UNKNOWN;
67    /**
68     * @var int
69     * @cvalue XML_HTML_DOCUMENT_NODE
70     */
71    const XML_HTML_DOCUMENT_NODE = UNKNOWN;
72    /**
73     * @var int
74     * @cvalue XML_DTD_NODE
75     */
76    const XML_DTD_NODE = UNKNOWN;
77    /**
78     * @var int
79     * @cvalue XML_ELEMENT_DECL
80     */
81    const XML_ELEMENT_DECL_NODE = UNKNOWN;
82    /**
83     * @var int
84     * @cvalue XML_ATTRIBUTE_DECL
85     */
86    const XML_ATTRIBUTE_DECL_NODE = UNKNOWN;
87    /**
88     * @var int
89     * @cvalue XML_ENTITY_DECL
90     */
91    const XML_ENTITY_DECL_NODE = UNKNOWN;
92    /**
93     * @var int
94     * @cvalue XML_NAMESPACE_DECL
95     */
96    const XML_NAMESPACE_DECL_NODE = UNKNOWN;
97#ifdef XML_GLOBAL_NAMESPACE
98    /**
99     * @var int
100     * @cvalue XML_GLOBAL_NAMESPACE
101     */
102    const XML_GLOBAL_NAMESPACE = UNKNOWN;
103#endif
104
105    /**
106     * @var int
107     * @cvalue XML_LOCAL_NAMESPACE
108     */
109    const XML_LOCAL_NAMESPACE = UNKNOWN;
110    /**
111     * @var int
112     * @cvalue XML_ATTRIBUTE_CDATA
113     */
114    const XML_ATTRIBUTE_CDATA = UNKNOWN;
115    /**
116     * @var int
117     * @cvalue XML_ATTRIBUTE_ID
118     */
119    const XML_ATTRIBUTE_ID = UNKNOWN;
120    /**
121     * @var int
122     * @cvalue XML_ATTRIBUTE_IDREF
123     */
124    const XML_ATTRIBUTE_IDREF = UNKNOWN;
125    /**
126     * @var int
127     * @cvalue XML_ATTRIBUTE_IDREFS
128     */
129    const XML_ATTRIBUTE_IDREFS = UNKNOWN;
130    /**
131     * @var int
132     * @cvalue XML_ATTRIBUTE_ENTITIES
133     */
134    const XML_ATTRIBUTE_ENTITY = UNKNOWN;
135    /**
136     * @var int
137     * @cvalue XML_ATTRIBUTE_NMTOKEN
138     */
139    const XML_ATTRIBUTE_NMTOKEN = UNKNOWN;
140    /**
141     * @var int
142     * @cvalue XML_ATTRIBUTE_NMTOKENS
143     */
144    const XML_ATTRIBUTE_NMTOKENS = UNKNOWN;
145    /**
146     * @var int
147     * @cvalue XML_ATTRIBUTE_ENUMERATION
148     */
149    const XML_ATTRIBUTE_ENUMERATION = UNKNOWN;
150    /**
151     * @var int
152     * @cvalue XML_ATTRIBUTE_NOTATION
153     */
154    const XML_ATTRIBUTE_NOTATION = UNKNOWN;
155
156    /**
157     * @var int
158     * @cvalue PHP_ERR
159     */
160    const DOM_PHP_ERR = UNKNOWN;
161    /**
162     * @var int
163     * @cvalue INDEX_SIZE_ERR
164     */
165    const DOM_INDEX_SIZE_ERR = UNKNOWN;
166    /**
167     * @var int
168     * @cvalue DOMSTRING_SIZE_ERR
169     */
170    const DOMSTRING_SIZE_ERR = UNKNOWN;
171    /**
172     * @var int
173     * @cvalue HIERARCHY_REQUEST_ERR
174     */
175    const DOM_HIERARCHY_REQUEST_ERR = UNKNOWN;
176    /**
177     * @var int
178     * @cvalue WRONG_DOCUMENT_ERR
179     */
180    const DOM_WRONG_DOCUMENT_ERR = UNKNOWN;
181    /**
182     * @var int
183     * @cvalue INVALID_CHARACTER_ERR
184     */
185    const DOM_INVALID_CHARACTER_ERR = UNKNOWN;
186    /**
187     * @var int
188     * @cvalue NO_DATA_ALLOWED_ERR
189     */
190    const DOM_NO_DATA_ALLOWED_ERR = UNKNOWN;
191    /**
192     * @var int
193     * @cvalue NO_MODIFICATION_ALLOWED_ERR
194     */
195    const DOM_NO_MODIFICATION_ALLOWED_ERR = UNKNOWN;
196    /**
197     * @var int
198     * @cvalue NOT_FOUND_ERR
199     */
200    const DOM_NOT_FOUND_ERR = UNKNOWN;
201    /**
202     * @var int
203     * @cvalue NOT_SUPPORTED_ERR
204     */
205    const DOM_NOT_SUPPORTED_ERR = UNKNOWN;
206    /**
207     * @var int
208     * @cvalue INUSE_ATTRIBUTE_ERR
209     */
210    const DOM_INUSE_ATTRIBUTE_ERR = UNKNOWN;
211    /**
212     * @var int
213     * @cvalue INVALID_STATE_ERR
214     */
215    const DOM_INVALID_STATE_ERR = UNKNOWN;
216    /**
217     * @var int
218     * @cvalue SYNTAX_ERR
219     */
220    const DOM_SYNTAX_ERR = UNKNOWN;
221    /**
222     * @var int
223     * @cvalue INVALID_MODIFICATION_ERR
224     */
225    const DOM_INVALID_MODIFICATION_ERR = UNKNOWN;
226    /**
227     * @var int
228     * @cvalue NAMESPACE_ERR
229     */
230    const DOM_NAMESPACE_ERR = UNKNOWN;
231    /**
232     * @var int
233     * @cvalue INVALID_ACCESS_ERR
234     */
235    const DOM_INVALID_ACCESS_ERR = UNKNOWN;
236    /**
237     * @var int
238     * @cvalue VALIDATION_ERR
239     */
240    const DOM_VALIDATION_ERR = UNKNOWN;
241
242    /** @alias DOM\DocumentType */
243    class DOMDocumentType extends DOMNode
244    {
245        /** @readonly */
246        public string $name;
247
248        /** @readonly */
249        public DOMNamedNodeMap $entities;
250
251        /** @readonly */
252        public DOMNamedNodeMap $notations;
253
254        /** @readonly */
255        public string $publicId;
256
257        /** @readonly */
258        public string $systemId;
259
260        /** @readonly */
261        public ?string $internalSubset;
262    }
263
264    /** @alias DOM\CDATASection */
265    class DOMCdataSection extends DOMText
266    {
267        public function __construct(string $data) {}
268    }
269
270    /** @alias DOM\Comment */
271    class DOMComment extends DOMCharacterData
272    {
273        public function __construct(string $data = "") {}
274    }
275
276    /** @alias DOM\ParentNode */
277    interface DOMParentNode
278    {
279        /** @param DOMNode|string $nodes */
280        public function append(...$nodes): void;
281
282        /** @param DOMNode|string $nodes */
283        public function prepend(...$nodes): void;
284
285        /** @param DOMNode|string $nodes */
286        public function replaceChildren(...$nodes): void;
287    }
288
289    /** @alias DOM\ChildNode */
290    interface DOMChildNode
291    {
292        public function remove(): void;
293
294        /** @param DOMNode|string $nodes */
295        public function before(... $nodes): void;
296
297        /** @param DOMNode|string $nodes */
298        public function after(...$nodes): void;
299
300        /** @param DOMNode|string $nodes */
301        public function replaceWith(...$nodes): void;
302    }
303
304    /** @alias DOM\Node */
305    class DOMNode
306    {
307        public const int DOCUMENT_POSITION_DISCONNECTED = 0x01;
308        public const int DOCUMENT_POSITION_PRECEDING = 0x02;
309        public const int DOCUMENT_POSITION_FOLLOWING = 0x04;
310        public const int DOCUMENT_POSITION_CONTAINS = 0x08;
311        public const int DOCUMENT_POSITION_CONTAINED_BY = 0x10;
312        public const int DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20;
313
314        /** @readonly */
315        public string $nodeName;
316
317        public ?string $nodeValue;
318
319        /** @readonly */
320        public int $nodeType;
321
322        /** @readonly */
323        public ?DOMNode $parentNode;
324
325        /** @readonly */
326        public ?DOMElement $parentElement;
327
328        /** @readonly */
329        public DOMNodeList $childNodes;
330
331        /** @readonly */
332        public ?DOMNode $firstChild;
333
334        /** @readonly */
335        public ?DOMNode $lastChild;
336
337        /** @readonly */
338        public ?DOMNode $previousSibling;
339
340        /** @readonly */
341        public ?DOMNode $nextSibling;
342
343        /** @readonly */
344        public ?DOMNamedNodeMap $attributes;
345
346        /** @readonly */
347        public bool $isConnected;
348
349        /** @readonly */
350        public ?DOM\Document $ownerDocument;
351
352        /** @readonly */
353        public ?string $namespaceURI;
354
355        public string $prefix;
356
357        /** @readonly */
358        public ?string $localName;
359
360        /** @readonly */
361        public ?string $baseURI;
362
363        public string $textContent;
364
365        /** @return DOMNode|false */
366        public function appendChild(DOMNode $node) {}
367
368        /** @tentative-return-type */
369        public function C14N(bool $exclusive = false, bool $withComments = false, ?array $xpath = null, ?array $nsPrefixes = null): string|false {}
370
371        /** @tentative-return-type */
372        public function C14NFile(string $uri, bool $exclusive = false, bool $withComments = false, ?array $xpath = null, ?array $nsPrefixes = null): int|false {}
373
374        /** @return DOMNode|false */
375        public function cloneNode(bool $deep = false) {}
376
377        /** @tentative-return-type */
378        public function getLineNo(): int {}
379
380        /** @tentative-return-type */
381        public function getNodePath(): ?string {}
382
383        /** @tentative-return-type */
384        public function hasAttributes(): bool {}
385
386        /** @tentative-return-type */
387        public function hasChildNodes(): bool {}
388
389        /** @return DOMNode|false */
390        public function insertBefore(DOMNode $node, ?DOMNode $child = null) {}
391
392        /** @tentative-return-type */
393        public function isDefaultNamespace(string $namespace): bool {}
394
395        /** @tentative-return-type */
396        public function isSameNode(DOMNode $otherNode): bool {}
397
398        public function isEqualNode(?DOMNode $otherNode): bool {}
399
400        /** @tentative-return-type */
401        public function isSupported(string $feature, string $version): bool {}
402
403        /** @tentative-return-type */
404        public function lookupNamespaceURI(?string $prefix): ?string {}
405
406        /** @tentative-return-type */
407        public function lookupPrefix(string $namespace): ?string {}
408
409        /** @tentative-return-type */
410        public function normalize(): void {}
411
412        /** @return DOMNode|false */
413        public function removeChild(DOMNode $child) {}
414
415        /** @return DOMNode|false */
416        public function replaceChild(DOMNode $node, DOMNode $child) {}
417
418        public function contains(DOMNode|DOMNameSpaceNode|null $other): bool {}
419
420        public function getRootNode(?array $options = null): DOMNode {}
421
422        public function compareDocumentPosition(DOMNode $other): int {}
423
424        public function __sleep(): array {}
425
426        public function __wakeup(): void {}
427    }
428
429    /** @alias DOM\NameSpaceNode */
430    class DOMNameSpaceNode
431    {
432        /** @readonly */
433        public string $nodeName;
434
435        /** @readonly */
436        public ?string $nodeValue;
437
438        /** @readonly */
439        public int $nodeType;
440
441        /** @readonly */
442        public string $prefix;
443
444        /** @readonly */
445        public ?string $localName;
446
447        /** @readonly */
448        public ?string $namespaceURI;
449
450        /** @readonly */
451        public bool $isConnected;
452
453        /** @readonly */
454        public ?DOMDocument $ownerDocument;
455
456        /** @readonly */
457        public ?DOMNode $parentNode;
458
459        /** @readonly */
460        public ?DOMElement $parentElement;
461
462        /** @implementation-alias DOMNode::__sleep */
463        public function __sleep(): array {}
464
465        /** @implementation-alias DOMNode::__wakeup */
466        public function __wakeup(): void {}
467    }
468
469    class DOMImplementation
470    {
471        /** @tentative-return-type */
472        public function getFeature(string $feature, string $version): never {}
473
474        /** @tentative-return-type */
475        public function hasFeature(string $feature, string $version): bool {}
476
477        /** @return DOMDocumentType|false */
478        public function createDocumentType(string $qualifiedName, string $publicId = "", string $systemId = "") {}
479
480        /** @tentative-return-type */
481        public function createDocument(?string $namespace = null, string $qualifiedName = "", ?DOMDocumentType $doctype = null): DOMDocument {}
482    }
483
484    /** @alias DOM\DocumentFragment */
485    class DOMDocumentFragment extends DOMNode implements DOMParentNode
486    {
487        /** @readonly */
488        public ?DOMElement $firstElementChild;
489
490        /** @readonly */
491        public ?DOMElement $lastElementChild;
492
493        /** @readonly */
494        public int $childElementCount;
495
496        public function __construct() {}
497
498        /** @tentative-return-type */
499        public function appendXML(string $data): bool {}
500
501        /**
502         * @param DOMNode|string $nodes
503         * @implementation-alias DOMElement::append
504         */
505        public function append(...$nodes): void {}
506
507        /**
508         * @param DOMNode|string $nodes
509         * @implementation-alias DOMElement::prepend
510         */
511        public function prepend(...$nodes): void {}
512
513        /**
514         * @param DOMNode|string $nodes
515         * @implementation-alias DOM\Document::replaceChildren
516         */
517        public function replaceChildren(...$nodes): void {}
518    }
519
520    /** @alias DOM\NodeList */
521    class DOMNodeList implements IteratorAggregate, Countable
522    {
523        /** @readonly */
524        public int $length;
525
526        /** @tentative-return-type */
527        public function count(): int {}
528
529        public function getIterator(): Iterator {}
530
531        /** @return DOMElement|DOMNode|DOMNameSpaceNode|null */
532        public function item(int $index) {}
533    }
534
535    /** @alias DOM\CharacterData */
536    class DOMCharacterData extends DOMNode implements DOMChildNode
537    {
538        public string $data;
539
540        /** @readonly */
541        public int $length;
542
543        /** @readonly */
544        public ?DOMElement $previousElementSibling;
545
546        /** @readonly */
547        public ?DOMElement $nextElementSibling;
548
549        /** @tentative-return-type */
550        public function appendData(string $data): true {}
551
552        /** @return string|false */
553        public function substringData(int $offset, int $count) {}
554
555        /** @tentative-return-type */
556        public function insertData(int $offset, string $data): bool {}
557
558        /** @tentative-return-type */
559        public function deleteData(int $offset, int $count): bool {}
560
561        /** @tentative-return-type */
562        public function replaceData(int $offset, int $count, string $data): bool {}
563
564        /**
565         * @param DOMNode|string $nodes
566         * @implementation-alias DOMElement::replaceWith
567         */
568        public function replaceWith(...$nodes): void {}
569
570        /** @implementation-alias DOMElement::remove */
571        public function remove(): void {}
572
573        /**
574         * @param DOMNode|string $nodes
575         * @implementation-alias DOMElement::before
576         */
577        public function before(... $nodes): void {}
578
579        /**
580         * @param DOMNode|string $nodes
581         * @implementation-alias DOMElement::after
582         */
583        public function after(...$nodes): void {}
584    }
585
586    /** @alias DOM\Attr */
587    class DOMAttr extends DOMNode
588    {
589        /** @readonly */
590        public string $name;
591
592        /** @readonly */
593        public bool $specified = true;
594
595        public string $value;
596
597        /** @readonly */
598        public ?DOMElement $ownerElement;
599
600        /** @readonly */
601        public mixed $schemaTypeInfo = null;
602
603        public function __construct(string $name, string $value = "") {}
604
605        /** @tentative-return-type */
606        public function isId(): bool {}
607    }
608
609    /** @alias DOM\Element */
610    class DOMElement extends DOMNode implements \DOMParentNode, \DOMChildNode
611    {
612        /** @readonly */
613        public string $tagName;
614
615        public string $className;
616
617        public string $id;
618
619        /** @readonly */
620        public mixed $schemaTypeInfo = null;
621
622        /** @readonly */
623        public ?DOMElement $firstElementChild;
624
625        /** @readonly */
626        public ?DOMElement $lastElementChild;
627
628        /** @readonly */
629        public int $childElementCount;
630
631        /** @readonly */
632        public ?DOMElement $previousElementSibling;
633
634        /** @readonly */
635        public ?DOMElement $nextElementSibling;
636
637        public function __construct(string $qualifiedName, ?string $value = null, string $namespace = "") {}
638
639        /** @tentative-return-type */
640        public function getAttribute(string $qualifiedName): string {}
641
642        public function getAttributeNames(): array {}
643
644        /** @tentative-return-type */
645        public function getAttributeNS(?string $namespace, string $localName): string {}
646
647        /** @return DOMAttr|DOMNameSpaceNode|false */
648        public function getAttributeNode(string $qualifiedName) {}
649
650        /** @return DOMAttr|DOMNameSpaceNode|null */
651        public function getAttributeNodeNS(?string $namespace, string $localName) {}
652
653        /** @tentative-return-type */
654        public function getElementsByTagName(string $qualifiedName): DOMNodeList {}
655
656        /** @tentative-return-type */
657        public function getElementsByTagNameNS(?string $namespace, string $localName): DOMNodeList {}
658
659        /** @tentative-return-type */
660        public function hasAttribute(string $qualifiedName): bool {}
661
662        /** @tentative-return-type */
663        public function hasAttributeNS(?string $namespace, string $localName): bool {}
664
665        /** @tentative-return-type */
666        public function removeAttribute(string $qualifiedName): bool {}
667
668        /** @tentative-return-type */
669        public function removeAttributeNS(?string $namespace, string $localName): void {}
670
671        /** @return DOMAttr|false */
672        public function removeAttributeNode(DOMAttr $attr) {}
673
674        /** @return DOMAttr|bool */
675        public function setAttribute(string $qualifiedName, string $value) {} // TODO return type shouldn't depend on the call scope
676
677        /** @tentative-return-type */
678        public function setAttributeNS(?string $namespace, string $qualifiedName, string $value): void {}
679
680        /** @return DOMAttr|null|false */
681        public function setAttributeNode(DOMAttr $attr) {}
682
683        /** @return DOMAttr|null|false */
684        public function setAttributeNodeNS(DOMAttr $attr) {}
685
686        /** @tentative-return-type */
687        public function setIdAttribute(string $qualifiedName, bool $isId): void {}
688
689        /** @tentative-return-type */
690        public function setIdAttributeNS(string $namespace, string $qualifiedName, bool $isId): void {}
691
692        /** @tentative-return-type */
693        public function setIdAttributeNode(DOMAttr $attr, bool $isId): void {}
694
695        public function toggleAttribute(string $qualifiedName, ?bool $force = null): bool {}
696
697        public function remove(): void {}
698
699        /** @param DOMNode|string $nodes */
700        public function before(... $nodes): void {}
701
702        /** @param DOMNode|string $nodes */
703        public function after(...$nodes): void {}
704
705        /** @param DOMNode|string $nodes */
706        public function replaceWith(...$nodes): void {}
707
708        /** @param DOMNode|string $nodes */
709        public function append(...$nodes): void {}
710
711        /** @param DOMNode|string $nodes */
712        public function prepend(...$nodes): void {}
713
714        /** @param DOMNode|string $nodes */
715        public function replaceChildren(...$nodes): void {}
716
717        public function insertAdjacentElement(string $where, DOMElement $element): ?DOMElement {}
718
719        public function insertAdjacentText(string $where, string $data): void {}
720    }
721
722    class DOMDocument extends DOM\Document
723    {
724        /** @readonly */
725        public DOMImplementation $implementation;
726
727        /**
728         * @readonly
729         * @deprecated
730         */
731        public ?string $actualEncoding;
732
733        /** @readonly */
734        public ?string $xmlEncoding;
735
736        public bool $standalone;
737
738        public bool $xmlStandalone;
739
740        public ?string $version;
741
742        public ?string $xmlVersion;
743
744        /**
745         * @readonly
746         * @deprecated
747         */
748        public mixed $config;
749
750        public bool $formatOutput;
751
752        public bool $validateOnParse;
753
754        public bool $resolveExternals;
755
756        public bool $preserveWhiteSpace;
757
758        public bool $recover;
759
760        public bool $substituteEntities;
761
762        public function __construct(string $version = "1.0", string $encoding = "") {}
763
764        /** @return DOMEntityReference|false */
765        public function createEntityReference(string $name) {}
766
767        /** @tentative-return-type */
768        public function load(string $filename, int $options = 0): bool {}
769
770        /** @tentative-return-type */
771        public function loadXML(string $source, int $options = 0): bool {}
772
773        /** @tentative-return-type */
774        public function save(string $filename, int $options = 0): int|false {}
775
776#ifdef LIBXML_HTML_ENABLED
777        /** @tentative-return-type */
778        public function loadHTML(string $source, int $options = 0): bool {}
779
780        /** @tentative-return-type */
781        public function loadHTMLFile(string $filename, int $options = 0): bool {}
782
783        /** @tentative-return-type */
784        public function saveHTML(?DOMNode $node = null): string|false {}
785
786        /** @tentative-return-type */
787        public function saveHTMLFile(string $filename): int|false {}
788#endif
789
790        /** @tentative-return-type */
791        public function saveXML(?DOMNode $node = null, int $options = 0): string|false {}
792
793        /** @tentative-return-type */
794        public function validate(): bool {}
795
796        /** @tentative-return-type */
797        public function xinclude(int $options = 0): int|false {}
798    }
799
800    /** @alias DOM\DOMException */
801    final class DOMException extends Exception
802    {
803        /**
804         * Intentionally left untyped for BC reasons
805         * @var int
806         */
807        public $code = 0; // TODO add proper type (i.e. int|string)
808    }
809
810    /** @alias DOM\Text */
811    class DOMText extends DOMCharacterData
812    {
813        /** @readonly */
814        public string $wholeText;
815
816        public function __construct(string $data = "") {}
817
818        /** @tentative-return-type */
819        public function isWhitespaceInElementContent(): bool {}
820
821        /**
822         * @tentative-return-type
823         * @alias DOMText::isWhitespaceInElementContent
824         */
825        public function isElementContentWhitespace(): bool {}
826
827        /** @return DOMText|false */
828        public function splitText(int $offset) {}
829    }
830
831    /** @alias DOM\NamedNodeMap */
832    class DOMNamedNodeMap implements IteratorAggregate, Countable
833    {
834        /** @readonly */
835        public int $length;
836
837        /** @tentative-return-type */
838        public function getNamedItem(string $qualifiedName): ?DOMNode {} // TODO DOM spec returns DOMAttr
839
840        /** @tentative-return-type */
841        public function getNamedItemNS(?string $namespace, string $localName): ?DOMNode {} // TODO DOM spec returns DOMAttr
842
843        /** @tentative-return-type */
844        public function item(int $index): ?DOMNode {} // TODO DOM spec returns DOMAttr
845
846        /** @tentative-return-type */
847        public function count(): int {}
848
849        public function getIterator(): Iterator {}
850    }
851
852    /** @alias DOM\Entity */
853    class DOMEntity extends DOMNode
854    {
855        /** @readonly */
856        public ?string $publicId;
857
858        /** @readonly */
859        public ?string $systemId;
860
861        /** @readonly */
862        public ?string $notationName;
863
864        /**
865         * @readonly
866         * @deprecated
867         */
868        public ?string $actualEncoding = null;
869
870        /**
871         * @readonly
872         * @deprecated
873         */
874        public ?string $encoding = null;
875
876        /**
877         * @readonly
878         * @deprecated
879         */
880        public ?string $version = null;
881    }
882
883    /** @alias DOM\EntityReference */
884    class DOMEntityReference extends DOMNode
885    {
886        public function __construct(string $name) {}
887    }
888
889    /** @alias DOM\Notation */
890    class DOMNotation extends DOMNode
891    {
892        /** @readonly */
893        public string $publicId;
894
895        /** @readonly */
896        public string $systemId;
897    }
898
899    /** @alias DOM\ProcessingInstruction */
900    class DOMProcessingInstruction extends DOMNode
901    {
902        /** @readonly */
903        public string $target;
904
905        public string $data;
906
907        public function __construct(string $name, string $value = "") {}
908    }
909
910#ifdef LIBXML_XPATH_ENABLED
911    /**
912     * @not-serializable
913     * @alias DOM\XPath
914     */
915    class DOMXPath
916    {
917        /** @readonly */
918        public DOM\Document $document;
919
920        public bool $registerNodeNamespaces;
921
922        public function __construct(DOM\Document $document, bool $registerNodeNS = true) {}
923
924        /** @tentative-return-type */
925        public function evaluate(string $expression, ?DOMNode $contextNode = null, bool $registerNodeNS = true): mixed {}
926
927        /** @tentative-return-type */
928        public function query(string $expression, ?DOMNode $contextNode = null, bool $registerNodeNS = true): mixed {}
929
930        /** @tentative-return-type */
931        public function registerNamespace(string $prefix, string $namespace): bool {}
932
933        /** @tentative-return-type */
934        public function registerPhpFunctions(string|array|null $restrict = null): void {}
935
936        public function registerPhpFunctionNS(string $namespaceURI, string $name, callable $callable): void {}
937    }
938#endif
939
940    function dom_import_simplexml(object $node): DOMElement {}
941}
942
943namespace DOM
944{
945    /**
946     * @var int
947     * @cvalue PHP_ERR
948     */
949    const PHP_ERR = UNKNOWN;
950    /**
951     * @var int
952     * @cvalue INDEX_SIZE_ERR
953     */
954    const INDEX_SIZE_ERR = UNKNOWN;
955    /**
956     * @var int
957     * @cvalue DOMSTRING_SIZE_ERR
958     */
959    const STRING_SIZE_ERR = UNKNOWN;
960    /**
961     * @var int
962     * @cvalue HIERARCHY_REQUEST_ERR
963     */
964    const HIERARCHY_REQUEST_ERR = UNKNOWN;
965    /**
966     * @var int
967     * @cvalue WRONG_DOCUMENT_ERR
968     */
969    const WRONG_DOCUMENT_ERR = UNKNOWN;
970    /**
971     * @var int
972     * @cvalue INVALID_CHARACTER_ERR
973     */
974    const INVALID_CHARACTER_ERR = UNKNOWN;
975    /**
976     * @var int
977     * @cvalue NO_DATA_ALLOWED_ERR
978     */
979    const NO_DATA_ALLOWED_ERR = UNKNOWN;
980    /**
981     * @var int
982     * @cvalue NO_MODIFICATION_ALLOWED_ERR
983     */
984    const NO_MODIFICATION_ALLOWED_ERR = UNKNOWN;
985    /**
986     * @var int
987     * @cvalue NOT_FOUND_ERR
988     */
989    const NOT_FOUND_ERR = UNKNOWN;
990    /**
991     * @var int
992     * @cvalue NOT_SUPPORTED_ERR
993     */
994    const NOT_SUPPORTED_ERR = UNKNOWN;
995    /**
996     * @var int
997     * @cvalue INUSE_ATTRIBUTE_ERR
998     */
999    const INUSE_ATTRIBUTE_ERR = UNKNOWN;
1000    /**
1001     * @var int
1002     * @cvalue INVALID_STATE_ERR
1003     */
1004    const INVALID_STATE_ERR = UNKNOWN;
1005    /**
1006     * @var int
1007     * @cvalue SYNTAX_ERR
1008     */
1009    const SYNTAX_ERR = UNKNOWN;
1010    /**
1011     * @var int
1012     * @cvalue INVALID_MODIFICATION_ERR
1013     */
1014    const INVALID_MODIFICATION_ERR = UNKNOWN;
1015    /**
1016     * @var int
1017     * @cvalue NAMESPACE_ERR
1018     */
1019    const NAMESPACE_ERR = UNKNOWN;
1020    /**
1021     * @var int
1022     * @cvalue INVALID_ACCESS_ERR
1023     */
1024    const INVALID_ACCESS_ERR = UNKNOWN;
1025    /**
1026     * @var int
1027     * @cvalue VALIDATION_ERR
1028     */
1029    const VALIDATION_ERR = UNKNOWN;
1030
1031    /**
1032     * @var int
1033     * @cvalue DOM_HTML_NO_DEFAULT_NS
1034     */
1035    const HTML_NO_DEFAULT_NS = UNKNOWN;
1036
1037    abstract class Document extends \DOMNode implements \DOMParentNode
1038    {
1039        /** @readonly */
1040        public ?DocumentType $doctype;
1041
1042        /** @readonly */
1043        public ?Element $documentElement;
1044
1045        public ?string $encoding;
1046
1047        public bool $strictErrorChecking;
1048
1049        public ?string $documentURI;
1050
1051        /** @readonly */
1052        public ?Element $firstElementChild;
1053
1054        /** @readonly */
1055        public ?Element $lastElementChild;
1056
1057        /** @readonly */
1058        public int $childElementCount;
1059
1060        /** @return Attr|false */
1061        public function createAttribute(string $localName) {}
1062
1063        /** @return Attr|false */
1064        public function createAttributeNS(?string $namespace, string $qualifiedName) {}
1065
1066        /** @return CDATASection|false */
1067        public function createCDATASection(string $data) {}
1068
1069        /** @tentative-return-type */
1070        public function createComment(string $data): Comment {}
1071
1072        /** @tentative-return-type */
1073        public function createDocumentFragment(): DocumentFragment {}
1074
1075        /** @return Element|false */
1076        public function createElement(string $localName, string $value = "")  {}
1077
1078        /** @return Element|false */
1079        public function createElementNS(?string $namespace, string $qualifiedName, string $value = "") {}
1080
1081        /** @return ProcessingInstruction|false */
1082        public function createProcessingInstruction(string $target, string $data = "") {}
1083
1084        /** @tentative-return-type */
1085        public function createTextNode(string $data): Text {}
1086
1087        /** @tentative-return-type */
1088        public function getElementById(string $elementId): ?Element {}
1089
1090        /** @tentative-return-type */
1091        public function getElementsByTagName(string $qualifiedName): NodeList {}
1092
1093        /** @tentative-return-type */
1094        public function getElementsByTagNameNS(?string $namespace, string $localName): NodeList {}
1095
1096        /** @return Node|false */
1097        public function importNode(Node $node, bool $deep = false) {}
1098
1099        /** @tentative-return-type */
1100        public function normalizeDocument(): void {}
1101
1102        /** @tentative-return-type */
1103        public function registerNodeClass(string $baseClass, ?string $extendedClass): true {}
1104
1105#ifdef LIBXML_SCHEMAS_ENABLED
1106        /** @tentative-return-type */
1107        public function schemaValidate(string $filename, int $flags = 0): bool {}
1108
1109        /** @tentative-return-type */
1110        public function schemaValidateSource(string $source, int $flags = 0): bool {}
1111
1112        /** @tentative-return-type */
1113        public function relaxNGValidate(string $filename): bool {}
1114
1115        /** @tentative-return-type */
1116        public function relaxNGValidateSource(string $source): bool {}
1117#endif
1118
1119        /** @tentative-return-type */
1120        public function adoptNode(Node $node): Node|false {}
1121
1122        /**
1123         * @param Node|string $nodes
1124         * @implementation-alias DOMElement::append
1125         */
1126        public function append(...$nodes): void {}
1127
1128        /**
1129         * @param Node|string $nodes
1130         * @implementation-alias DOMElement::prepend
1131         */
1132        public function prepend(...$nodes): void {}
1133
1134        /** @param Node|string $nodes */
1135        public function replaceChildren(...$nodes): void {}
1136    }
1137
1138    /** @strict-properties */
1139    final class HTMLDocument extends Document
1140    {
1141        private function __construct() {}
1142
1143        public static function createEmpty(string $encoding = "UTF-8"): HTMLDocument {}
1144
1145        public static function createFromFile(string $path, int $options = 0, ?string $overrideEncoding = null): HTMLDocument {}
1146
1147        public static function createFromString(string $source, int $options = 0, ?string $overrideEncoding = null): HTMLDocument {}
1148
1149        /** @implementation-alias DOMDocument::saveXML */
1150        public function saveXML(?Node $node = null, int $options = 0): string|false {}
1151
1152        /** @implementation-alias DOMDocument::save */
1153        public function saveXMLFile(string $filename, int $options = 0): int|false {}
1154
1155        public function saveHTML(?Node $node = null): string|false {}
1156
1157        public function saveHTMLFile(string $filename): int|false {}
1158    }
1159
1160    /** @strict-properties */
1161    final class XMLDocument extends Document
1162    {
1163        /** @implementation-alias DOM\HTMLDocument::__construct */
1164        private function __construct() {}
1165
1166        public static function createEmpty(string $version = "1.0", string $encoding = "UTF-8"): XMLDocument {}
1167
1168        public static function createFromFile(string $path, int $options = 0, ?string $overrideEncoding = null): XMLDocument {}
1169
1170        public static function createFromString(string $source, int $options = 0, ?string $overrideEncoding = null): XMLDocument {}
1171
1172        /** @readonly */
1173        public ?string $xmlEncoding;
1174
1175        public bool $standalone;
1176
1177        public bool $xmlStandalone;
1178
1179        public ?string $version;
1180
1181        public ?string $xmlVersion;
1182
1183        public bool $formatOutput;
1184
1185        public bool $validateOnParse;
1186
1187        public bool $resolveExternals;
1188
1189        public bool $preserveWhiteSpace;
1190
1191        public bool $recover;
1192
1193        public bool $substituteEntities;
1194
1195        /**
1196         * @implementation-alias DOMDocument::createEntityReference
1197         * @return EntityReference|false
1198         */
1199        public function createEntityReference(string $name) {}
1200
1201        /**
1202         * @implementation-alias DOMDocument::validate
1203         */
1204        public function validate(): bool {}
1205
1206        /**
1207         * @tentative-return-type
1208         * @implementation-alias DOMDocument::xinclude
1209         */
1210        public function xinclude(int $options = 0): int|false {}
1211
1212        /**
1213         * @tentative-return-type
1214         * @implementation-alias DOMDocument::saveXML
1215         */
1216        public function saveXML(?Node $node = null, int $options = 0): string|false {}
1217
1218        /**
1219         * @tentative-return-type
1220         * @implementation-alias DOMDocument::save
1221         */
1222        public function saveXMLFile(string $filename, int $options = 0): int|false {}
1223    }
1224
1225    /** @implementation-alias dom_import_simplexml */
1226    function import_simplexml(object $node): Element {}
1227}
1228