xref: /php-src/ext/dom/php_dom.stub.php (revision 47ec3204)
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    class DOMDocumentType extends DOMNode
243    {
244        /** @readonly */
245        public string $name;
246
247        /** @readonly */
248        public DOMNamedNodeMap $entities;
249
250        /** @readonly */
251        public DOMNamedNodeMap $notations;
252
253        /** @readonly */
254        public string $publicId;
255
256        /** @readonly */
257        public string $systemId;
258
259        /** @readonly */
260        public ?string $internalSubset;
261    }
262
263    class DOMCdataSection extends DOMText
264    {
265        public function __construct(string $data) {}
266    }
267
268    class DOMComment extends DOMCharacterData
269    {
270        public function __construct(string $data = "") {}
271    }
272
273    interface DOMParentNode
274    {
275        /** @param DOMNode|string $nodes */
276        public function append(...$nodes): void;
277
278        /** @param DOMNode|string $nodes */
279        public function prepend(...$nodes): void;
280
281        /** @param DOMNode|string $nodes */
282        public function replaceChildren(...$nodes): void;
283    }
284
285    interface DOMChildNode
286    {
287        public function remove(): void;
288
289        /** @param DOMNode|string $nodes */
290        public function before(... $nodes): void;
291
292        /** @param DOMNode|string $nodes */
293        public function after(...$nodes): void;
294
295        /** @param DOMNode|string $nodes */
296        public function replaceWith(...$nodes): void;
297    }
298
299    class DOMNode
300    {
301        public const int DOCUMENT_POSITION_DISCONNECTED = 0x01;
302        public const int DOCUMENT_POSITION_PRECEDING = 0x02;
303        public const int DOCUMENT_POSITION_FOLLOWING = 0x04;
304        public const int DOCUMENT_POSITION_CONTAINS = 0x08;
305        public const int DOCUMENT_POSITION_CONTAINED_BY = 0x10;
306        public const int DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20;
307
308        /** @readonly */
309        public string $nodeName;
310
311        public ?string $nodeValue;
312
313        /** @readonly */
314        public int $nodeType;
315
316        /** @readonly */
317        public ?DOMNode $parentNode;
318
319        /** @readonly */
320        public ?DOMElement $parentElement;
321
322        /** @readonly */
323        public DOMNodeList $childNodes;
324
325        /** @readonly */
326        public ?DOMNode $firstChild;
327
328        /** @readonly */
329        public ?DOMNode $lastChild;
330
331        /** @readonly */
332        public ?DOMNode $previousSibling;
333
334        /** @readonly */
335        public ?DOMNode $nextSibling;
336
337        /** @readonly */
338        public ?DOMNamedNodeMap $attributes;
339
340        /** @readonly */
341        public bool $isConnected;
342
343        /** @readonly */
344        public ?DOMDocument $ownerDocument;
345
346        /** @readonly */
347        public ?string $namespaceURI;
348
349        public string $prefix;
350
351        /** @readonly */
352        public ?string $localName;
353
354        /** @readonly */
355        public ?string $baseURI;
356
357        public string $textContent;
358
359        /** @return DOMNode|false */
360        public function appendChild(DOMNode $node) {}
361
362        /** @tentative-return-type */
363        public function C14N(bool $exclusive = false, bool $withComments = false, ?array $xpath = null, ?array $nsPrefixes = null): string|false {}
364
365        /** @tentative-return-type */
366        public function C14NFile(string $uri, bool $exclusive = false, bool $withComments = false, ?array $xpath = null, ?array $nsPrefixes = null): int|false {}
367
368        /** @return DOMNode|false */
369        public function cloneNode(bool $deep = false) {}
370
371        /** @tentative-return-type */
372        public function getLineNo(): int {}
373
374        /** @tentative-return-type */
375        public function getNodePath(): ?string {}
376
377        /** @tentative-return-type */
378        public function hasAttributes(): bool {}
379
380        /** @tentative-return-type */
381        public function hasChildNodes(): bool {}
382
383        /** @return DOMNode|false */
384        public function insertBefore(DOMNode $node, ?DOMNode $child = null) {}
385
386        /** @tentative-return-type */
387        public function isDefaultNamespace(string $namespace): bool {}
388
389        /** @tentative-return-type */
390        public function isSameNode(DOMNode $otherNode): bool {}
391
392        public function isEqualNode(?DOMNode $otherNode): bool {}
393
394        /** @tentative-return-type */
395        public function isSupported(string $feature, string $version): bool {}
396
397        /** @tentative-return-type */
398        public function lookupNamespaceURI(?string $prefix): ?string {}
399
400        /** @tentative-return-type */
401        public function lookupPrefix(string $namespace): ?string {}
402
403        /** @tentative-return-type */
404        public function normalize(): void {}
405
406        /** @return DOMNode|false */
407        public function removeChild(DOMNode $child) {}
408
409        /** @return DOMNode|false */
410        public function replaceChild(DOMNode $node, DOMNode $child) {}
411
412        public function contains(DOMNode|DOMNameSpaceNode|null $other): bool {}
413
414        public function getRootNode(?array $options = null): DOMNode {}
415
416        public function compareDocumentPosition(DOMNode $other): int {}
417
418        public function __sleep(): array {}
419
420        public function __wakeup(): void {}
421    }
422
423    class DOMNameSpaceNode
424    {
425        /** @readonly */
426        public string $nodeName;
427
428        /** @readonly */
429        public ?string $nodeValue;
430
431        /** @readonly */
432        public int $nodeType;
433
434        /** @readonly */
435        public string $prefix;
436
437        /** @readonly */
438        public ?string $localName;
439
440        /** @readonly */
441        public ?string $namespaceURI;
442
443        /** @readonly */
444        public bool $isConnected;
445
446        /** @readonly */
447        public ?DOMDocument $ownerDocument;
448
449        /** @readonly */
450        public ?DOMNode $parentNode;
451
452        /** @readonly */
453        public ?DOMElement $parentElement;
454
455        /** @implementation-alias DOMNode::__sleep */
456        public function __sleep(): array {}
457
458        /** @implementation-alias DOMNode::__wakeup */
459        public function __wakeup(): void {}
460    }
461
462    class DOMImplementation
463    {
464        /** @tentative-return-type */
465        public function getFeature(string $feature, string $version): never {}
466
467        /** @tentative-return-type */
468        public function hasFeature(string $feature, string $version): bool {}
469
470        /** @return DOMDocumentType|false */
471        public function createDocumentType(string $qualifiedName, string $publicId = "", string $systemId = "") {}
472
473        /** @tentative-return-type */
474        public function createDocument(?string $namespace = null, string $qualifiedName = "", ?DOMDocumentType $doctype = null): DOMDocument {}
475    }
476
477    class DOMDocumentFragment extends DOMNode implements DOMParentNode
478    {
479        /** @readonly */
480        public ?DOMElement $firstElementChild;
481
482        /** @readonly */
483        public ?DOMElement $lastElementChild;
484
485        /** @readonly */
486        public int $childElementCount;
487
488        public function __construct() {}
489
490        /** @tentative-return-type */
491        public function appendXML(string $data): bool {}
492
493        /**
494         * @param DOMNode|string $nodes
495         * @implementation-alias DOMElement::append
496         */
497        public function append(...$nodes): void {}
498
499        /**
500         * @param DOMNode|string $nodes
501         * @implementation-alias DOMElement::prepend
502         */
503        public function prepend(...$nodes): void {}
504
505        /**
506         * @param DOMNode|string $nodes
507         * @implementation-alias DOMDocument::replaceChildren
508         */
509        public function replaceChildren(...$nodes): void {}
510    }
511
512    class DOMNodeList implements IteratorAggregate, Countable
513    {
514        /** @readonly */
515        public int $length;
516
517        /** @tentative-return-type */
518        public function count(): int {}
519
520        public function getIterator(): Iterator {}
521
522        /** @return DOMElement|DOMNode|DOMNameSpaceNode|null */
523        public function item(int $index) {}
524    }
525
526    class DOMCharacterData extends DOMNode implements DOMChildNode
527    {
528        public string $data;
529
530        /** @readonly */
531        public int $length;
532
533        /** @readonly */
534        public ?DOMElement $previousElementSibling;
535
536        /** @readonly */
537        public ?DOMElement $nextElementSibling;
538
539        /** @tentative-return-type */
540        public function appendData(string $data): true {}
541
542        /** @return string|false */
543        public function substringData(int $offset, int $count) {}
544
545        /** @tentative-return-type */
546        public function insertData(int $offset, string $data): bool {}
547
548        /** @tentative-return-type */
549        public function deleteData(int $offset, int $count): bool {}
550
551        /** @tentative-return-type */
552        public function replaceData(int $offset, int $count, string $data): bool {}
553
554        /**
555         * @param DOMNode|string $nodes
556         * @implementation-alias DOMElement::replaceWith
557         */
558        public function replaceWith(...$nodes): void {}
559
560        /** @implementation-alias DOMElement::remove */
561        public function remove(): void {}
562
563        /**
564         * @param DOMNode|string $nodes
565         * @implementation-alias DOMElement::before
566         */
567        public function before(... $nodes): void {}
568
569        /**
570         * @param DOMNode|string $nodes
571         * @implementation-alias DOMElement::after
572         */
573        public function after(...$nodes): void {}
574    }
575
576    class DOMAttr extends DOMNode
577    {
578        /** @readonly */
579        public string $name;
580
581        /** @readonly */
582        public bool $specified = true;
583
584        public string $value;
585
586        /** @readonly */
587        public ?DOMElement $ownerElement;
588
589        /** @readonly */
590        public mixed $schemaTypeInfo = null;
591
592        public function __construct(string $name, string $value = "") {}
593
594        /** @tentative-return-type */
595        public function isId(): bool {}
596    }
597
598    class DOMElement extends DOMNode implements \DOMParentNode, \DOMChildNode
599    {
600        /** @readonly */
601        public string $tagName;
602
603        public string $className;
604
605        public string $id;
606
607        /** @readonly */
608        public mixed $schemaTypeInfo = null;
609
610        /** @readonly */
611        public ?DOMElement $firstElementChild;
612
613        /** @readonly */
614        public ?DOMElement $lastElementChild;
615
616        /** @readonly */
617        public int $childElementCount;
618
619        /** @readonly */
620        public ?DOMElement $previousElementSibling;
621
622        /** @readonly */
623        public ?DOMElement $nextElementSibling;
624
625        public function __construct(string $qualifiedName, ?string $value = null, string $namespace = "") {}
626
627        /** @tentative-return-type */
628        public function getAttribute(string $qualifiedName): string {}
629
630        public function getAttributeNames(): array {}
631
632        /** @tentative-return-type */
633        public function getAttributeNS(?string $namespace, string $localName): string {}
634
635        /** @return DOMAttr|DOMNameSpaceNode|false */
636        public function getAttributeNode(string $qualifiedName) {}
637
638        /** @return DOMAttr|DOMNameSpaceNode|null */
639        public function getAttributeNodeNS(?string $namespace, string $localName) {}
640
641        /** @tentative-return-type */
642        public function getElementsByTagName(string $qualifiedName): DOMNodeList {}
643
644        /** @tentative-return-type */
645        public function getElementsByTagNameNS(?string $namespace, string $localName): DOMNodeList {}
646
647        /** @tentative-return-type */
648        public function hasAttribute(string $qualifiedName): bool {}
649
650        /** @tentative-return-type */
651        public function hasAttributeNS(?string $namespace, string $localName): bool {}
652
653        /** @tentative-return-type */
654        public function removeAttribute(string $qualifiedName): bool {}
655
656        /** @tentative-return-type */
657        public function removeAttributeNS(?string $namespace, string $localName): void {}
658
659        /** @return DOMAttr|false */
660        public function removeAttributeNode(DOMAttr $attr) {}
661
662        /** @return DOMAttr|bool */
663        public function setAttribute(string $qualifiedName, string $value) {}
664
665        /** @tentative-return-type */
666        public function setAttributeNS(?string $namespace, string $qualifiedName, string $value): void {}
667
668        /** @return DOMAttr|null|false */
669        public function setAttributeNode(DOMAttr $attr) {}
670
671        /** @return DOMAttr|null|false */
672        public function setAttributeNodeNS(DOMAttr $attr) {}
673
674        /** @tentative-return-type */
675        public function setIdAttribute(string $qualifiedName, bool $isId): void {}
676
677        /** @tentative-return-type */
678        public function setIdAttributeNS(string $namespace, string $qualifiedName, bool $isId): void {}
679
680        /** @tentative-return-type */
681        public function setIdAttributeNode(DOMAttr $attr, bool $isId): void {}
682
683        public function toggleAttribute(string $qualifiedName, ?bool $force = null): bool {}
684
685        public function remove(): void {}
686
687        /** @param DOMNode|string $nodes */
688        public function before(... $nodes): void {}
689
690        /** @param DOMNode|string $nodes */
691        public function after(...$nodes): void {}
692
693        /** @param DOMNode|string $nodes */
694        public function replaceWith(...$nodes): void {}
695
696        /** @param DOMNode|string $nodes */
697        public function append(...$nodes): void {}
698
699        /** @param DOMNode|string $nodes */
700        public function prepend(...$nodes): void {}
701
702        /** @param DOMNode|string $nodes */
703        public function replaceChildren(...$nodes): void {}
704
705        public function insertAdjacentElement(string $where, DOMElement $element): ?DOMElement {}
706
707        public function insertAdjacentText(string $where, string $data): void {}
708    }
709
710    class DOMDocument extends DOMNode implements DOMParentNode
711    {
712        /** @readonly */
713        public ?DOMDocumentType $doctype;
714
715        /** @readonly */
716        public DOMImplementation $implementation;
717
718        /** @readonly */
719        public ?DOMElement $documentElement;
720
721        /**
722         * @readonly
723         * @deprecated
724         */
725        public ?string $actualEncoding;
726
727        public ?string $encoding;
728
729        /** @readonly */
730        public ?string $xmlEncoding;
731
732        public bool $standalone;
733
734        public bool $xmlStandalone;
735
736        public ?string $version;
737
738        public ?string $xmlVersion;
739
740        public bool $strictErrorChecking;
741
742        public ?string $documentURI;
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        /** @readonly */
763        public ?DOMElement $firstElementChild;
764
765        /** @readonly */
766        public ?DOMElement $lastElementChild;
767
768        /** @readonly */
769        public int $childElementCount;
770
771        public function __construct(string $version = "1.0", string $encoding = "") {}
772
773        /** @return DOMAttr|false */
774        public function createAttribute(string $localName) {}
775
776        /** @return DOMAttr|false */
777        public function createAttributeNS(?string $namespace, string $qualifiedName) {}
778
779        /** @return DOMCdataSection|false */
780        public function createCDATASection(string $data) {}
781
782        /** @tentative-return-type */
783        public function createComment(string $data): DOMComment {}
784
785        /** @tentative-return-type */
786        public function createDocumentFragment(): DOMDocumentFragment {}
787
788        /** @return DOMElement|false */
789        public function createElement(string $localName, string $value = "")  {}
790
791        /** @return DOMElement|false */
792        public function createElementNS(?string $namespace, string $qualifiedName, string $value = "") {}
793
794        /** @return DOMEntityReference|false */
795        public function createEntityReference(string $name) {}
796
797        /** @return DOMProcessingInstruction|false */
798        public function createProcessingInstruction(string $target, string $data = "") {}
799
800        /** @tentative-return-type */
801        public function createTextNode(string $data): DOMText {}
802
803        /** @tentative-return-type */
804        public function getElementById(string $elementId): ?DOMElement {}
805
806        /**
807         * @tentative-return-type
808         * @implementation-alias DOMElement::getElementsByTagName
809         */
810        public function getElementsByTagName(string $qualifiedName): DOMNodeList {}
811
812        /**
813         * @tentative-return-type
814         * @implementation-alias DOMElement::getElementsByTagNameNS
815         */
816        public function getElementsByTagNameNS(?string $namespace, string $localName): DOMNodeList {}
817
818        /** @return DOMNode|false */
819        public function importNode(DOMNode $node, bool $deep = false) {}
820
821        /** @tentative-return-type */
822        public function load(string $filename, int $options = 0): bool {}
823
824        /** @tentative-return-type */
825        public function loadXML(string $source, int $options = 0): bool {}
826
827        /** @tentative-return-type */
828        public function normalizeDocument(): void {}
829
830        /** @tentative-return-type */
831        public function registerNodeClass(string $baseClass, ?string $extendedClass): true {}
832
833        /** @tentative-return-type */
834        public function save(string $filename, int $options = 0): int|false {}
835
836#ifdef LIBXML_HTML_ENABLED
837        /** @tentative-return-type */
838        public function loadHTML(string $source, int $options = 0): bool {}
839
840        /** @tentative-return-type */
841        public function loadHTMLFile(string $filename, int $options = 0): bool {}
842
843        /** @tentative-return-type */
844        public function saveHTML(?DOMNode $node = null): string|false {}
845
846        /** @tentative-return-type */
847        public function saveHTMLFile(string $filename): int|false {}
848#endif
849
850        /** @tentative-return-type */
851        public function saveXML(?DOMNode $node = null, int $options = 0): string|false {}
852
853#ifdef LIBXML_SCHEMAS_ENABLED
854        /** @tentative-return-type */
855        public function schemaValidate(string $filename, int $flags = 0): bool {}
856
857        /** @tentative-return-type */
858        public function schemaValidateSource(string $source, int $flags = 0): bool {}
859
860        /** @tentative-return-type */
861        public function relaxNGValidate(string $filename): bool {}
862
863        /** @tentative-return-type */
864        public function relaxNGValidateSource(string $source): bool {}
865#endif
866
867        /** @tentative-return-type */
868        public function validate(): bool {}
869
870        /** @tentative-return-type */
871        public function xinclude(int $options = 0): int|false {}
872
873        /** @tentative-return-type */
874        public function adoptNode(DOMNode $node): DOMNode|false {}
875
876        /**
877         * @param DOMNode|string $nodes
878         * @implementation-alias DOMElement::append
879         */
880        public function append(...$nodes): void {}
881
882        /**
883         * @param DOMNode|string $nodes
884         * @implementation-alias DOMElement::prepend
885         */
886        public function prepend(...$nodes): void {}
887
888        /** @param DOMNode|string $nodes */
889        public function replaceChildren(...$nodes): void {}
890    }
891
892    /** @alias DOM\DOMException */
893    final class DOMException extends Exception
894    {
895        /**
896         * Intentionally left untyped for BC reasons
897         * @var int
898         */
899        public $code = 0; // TODO add proper type (i.e. int|string)
900    }
901
902    class DOMText extends DOMCharacterData
903    {
904        /** @readonly */
905        public string $wholeText;
906
907        public function __construct(string $data = "") {}
908
909        /** @tentative-return-type */
910        public function isWhitespaceInElementContent(): bool {}
911
912        /**
913         * @tentative-return-type
914         * @alias DOMText::isWhitespaceInElementContent
915         */
916        public function isElementContentWhitespace(): bool {}
917
918        /** @return DOMText|false */
919        public function splitText(int $offset) {}
920    }
921
922    class DOMNamedNodeMap implements IteratorAggregate, Countable
923    {
924        /** @readonly */
925        public int $length;
926
927        /** @tentative-return-type */
928        public function getNamedItem(string $qualifiedName): ?DOMNode {}
929
930        /** @tentative-return-type */
931        public function getNamedItemNS(?string $namespace, string $localName): ?DOMNode {}
932
933        /** @tentative-return-type */
934        public function item(int $index): ?DOMNode {}
935
936        /** @tentative-return-type */
937        public function count(): int {}
938
939        public function getIterator(): Iterator {}
940    }
941
942    class DOMEntity extends DOMNode
943    {
944        /** @readonly */
945        public ?string $publicId;
946
947        /** @readonly */
948        public ?string $systemId;
949
950        /** @readonly */
951        public ?string $notationName;
952
953        /**
954         * @readonly
955         * @deprecated
956         */
957        public ?string $actualEncoding = null;
958
959        /**
960         * @readonly
961         * @deprecated
962         */
963        public ?string $encoding = null;
964
965        /**
966         * @readonly
967         * @deprecated
968         */
969        public ?string $version = null;
970    }
971
972    class DOMEntityReference extends DOMNode
973    {
974        public function __construct(string $name) {}
975    }
976
977    class DOMNotation extends DOMNode
978    {
979        /** @readonly */
980        public string $publicId;
981
982        /** @readonly */
983        public string $systemId;
984    }
985
986    class DOMProcessingInstruction extends DOMNode
987    {
988        /** @readonly */
989        public string $target;
990
991        public string $data;
992
993        public function __construct(string $name, string $value = "") {}
994    }
995
996#ifdef LIBXML_XPATH_ENABLED
997    /** @not-serializable */
998    class DOMXPath
999    {
1000        /** @readonly */
1001        public DOMDocument $document;
1002
1003        public bool $registerNodeNamespaces;
1004
1005        public function __construct(DOMDocument $document, bool $registerNodeNS = true) {}
1006
1007        /** @tentative-return-type */
1008        public function evaluate(string $expression, ?DOMNode $contextNode = null, bool $registerNodeNS = true): mixed {}
1009
1010        /** @tentative-return-type */
1011        public function query(string $expression, ?DOMNode $contextNode = null, bool $registerNodeNS = true): mixed {}
1012
1013        /** @tentative-return-type */
1014        public function registerNamespace(string $prefix, string $namespace): bool {}
1015
1016        /** @tentative-return-type */
1017        public function registerPhpFunctions(string|array|null $restrict = null): void {}
1018
1019        public function registerPhpFunctionNS(string $namespaceURI, string $name, callable $callable): void {}
1020
1021        public static function quote(string $str): string {}
1022    }
1023#endif
1024
1025    function dom_import_simplexml(object $node): DOMElement {}
1026}
1027
1028namespace DOM
1029{
1030    /**
1031     * @var int
1032     * @cvalue INDEX_SIZE_ERR
1033     */
1034    const INDEX_SIZE_ERR = UNKNOWN;
1035    /**
1036     * @var int
1037     * @cvalue DOMSTRING_SIZE_ERR
1038     */
1039    const STRING_SIZE_ERR = UNKNOWN;
1040    /**
1041     * @var int
1042     * @cvalue HIERARCHY_REQUEST_ERR
1043     */
1044    const HIERARCHY_REQUEST_ERR = UNKNOWN;
1045    /**
1046     * @var int
1047     * @cvalue WRONG_DOCUMENT_ERR
1048     */
1049    const WRONG_DOCUMENT_ERR = UNKNOWN;
1050    /**
1051     * @var int
1052     * @cvalue INVALID_CHARACTER_ERR
1053     */
1054    const INVALID_CHARACTER_ERR = UNKNOWN;
1055    /**
1056     * @var int
1057     * @cvalue NO_DATA_ALLOWED_ERR
1058     */
1059    const NO_DATA_ALLOWED_ERR = UNKNOWN;
1060    /**
1061     * @var int
1062     * @cvalue NO_MODIFICATION_ALLOWED_ERR
1063     */
1064    const NO_MODIFICATION_ALLOWED_ERR = UNKNOWN;
1065    /**
1066     * @var int
1067     * @cvalue NOT_FOUND_ERR
1068     */
1069    const NOT_FOUND_ERR = UNKNOWN;
1070    /**
1071     * @var int
1072     * @cvalue NOT_SUPPORTED_ERR
1073     */
1074    const NOT_SUPPORTED_ERR = UNKNOWN;
1075    /**
1076     * @var int
1077     * @cvalue INUSE_ATTRIBUTE_ERR
1078     */
1079    const INUSE_ATTRIBUTE_ERR = UNKNOWN;
1080    /**
1081     * @var int
1082     * @cvalue INVALID_STATE_ERR
1083     */
1084    const INVALID_STATE_ERR = UNKNOWN;
1085    /**
1086     * @var int
1087     * @cvalue SYNTAX_ERR
1088     */
1089    const SYNTAX_ERR = UNKNOWN;
1090    /**
1091     * @var int
1092     * @cvalue INVALID_MODIFICATION_ERR
1093     */
1094    const INVALID_MODIFICATION_ERR = UNKNOWN;
1095    /**
1096     * @var int
1097     * @cvalue NAMESPACE_ERR
1098     */
1099    const NAMESPACE_ERR = UNKNOWN;
1100    /**
1101     * @var int
1102     * @cvalue VALIDATION_ERR
1103     */
1104    const VALIDATION_ERR = UNKNOWN;
1105
1106    /**
1107     * @var int
1108     * @cvalue DOM_HTML_NO_DEFAULT_NS
1109     */
1110    const HTML_NO_DEFAULT_NS = UNKNOWN;
1111
1112    interface ParentNode
1113    {
1114        public function append(Node|string ...$nodes): void;
1115        public function prepend(Node|string ...$nodes): void;
1116        public function replaceChildren(Node|string ...$nodes): void;
1117    }
1118
1119    interface ChildNode
1120    {
1121        public function remove(): void;
1122        public function before(Node|string ...$nodes): void;
1123        public function after(Node|string ...$nodes): void;
1124        public function replaceWith(Node|string ...$nodes): void;
1125    }
1126
1127    /**
1128     * @strict-properties
1129     * @not-serializable
1130     */
1131    class Implementation
1132    {
1133        public function createDocumentType(string $qualifiedName, string $publicId, string $systemId): DocumentType {}
1134
1135        public function createDocument(?string $namespace, string $qualifiedName, ?DocumentType $doctype = null): XMLDocument {}
1136
1137        public function createHTMLDocument(?string $title = null): HTMLDocument {}
1138    }
1139
1140    /** @strict-properties */
1141    class Node
1142    {
1143        private final function __construct() {}
1144
1145        /** @readonly */
1146        public int $nodeType;
1147        /** @readonly */
1148        public string $nodeName;
1149
1150        /** @readonly */
1151        public string $baseURI;
1152
1153        /** @readonly */
1154        public bool $isConnected;
1155        /** @readonly */
1156        public ?Document $ownerDocument;
1157
1158        /** @implementation-alias DOMNode::getRootNode */
1159        public function getRootNode(array $options = []): Node {}
1160        /** @readonly */
1161        public ?Node $parentNode;
1162        /** @readonly */
1163        public ?Element $parentElement;
1164        /** @implementation-alias DOMNode::hasChildNodes */
1165        public function hasChildNodes(): bool {}
1166        /** @readonly */
1167        public NodeList $childNodes;
1168        /** @readonly */
1169        public ?Node $firstChild;
1170        /** @readonly */
1171        public ?Node $lastChild;
1172        /** @readonly */
1173        public ?Node $previousSibling;
1174        /** @readonly */
1175        public ?Node $nextSibling;
1176
1177        public ?string $nodeValue;
1178        public ?string $textContent;
1179        /** @implementation-alias DOMNode::normalize */
1180        public function normalize(): void {}
1181
1182        /** @implementation-alias DOMNode::cloneNode */
1183        public function cloneNode(bool $deep = false): Node {}
1184        public function isEqualNode(?Node $otherNode): bool {}
1185        public function isSameNode(?Node $otherNode): bool {}
1186
1187        public const int DOCUMENT_POSITION_DISCONNECTED = 0x01;
1188        public const int DOCUMENT_POSITION_PRECEDING = 0x02;
1189        public const int DOCUMENT_POSITION_FOLLOWING = 0x04;
1190        public const int DOCUMENT_POSITION_CONTAINS = 0x08;
1191        public const int DOCUMENT_POSITION_CONTAINED_BY = 0x10;
1192        public const int DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20;
1193        public function compareDocumentPosition(Node $other): int {}
1194        public function contains(?Node $other): bool {}
1195
1196        public function lookupPrefix(?string $namespace): ?string {}
1197        /** @implementation-alias DOMNode::lookupNamespaceURI */
1198        public function lookupNamespaceURI(?string $prefix): ?string {}
1199        public function isDefaultNamespace(?string $namespace): bool {}
1200
1201        public function insertBefore(Node $node, ?Node $child): Node {}
1202        public function appendChild(Node $node): Node {}
1203        public function replaceChild(Node $node, Node $child): Node {}
1204        public function removeChild(Node $child): Node {}
1205
1206        /** @implementation-alias DOMNode::getLineNo */
1207        public function getLineNo(): int {}
1208        public function getNodePath(): string {}
1209
1210        /** @implementation-alias DOMNode::C14N */
1211        public function C14N(bool $exclusive = false, bool $withComments = false, ?array $xpath = null, ?array $nsPrefixes = null): string|false {}
1212        /** @implementation-alias DOMNode::C14NFile */
1213        public function C14NFile(string $uri, bool $exclusive = false, bool $withComments = false, ?array $xpath = null, ?array $nsPrefixes = null): int|false {}
1214
1215        /** @implementation-alias DOMNode::__sleep */
1216        public function __sleep(): array {}
1217        /** @implementation-alias DOMNode::__wakeup */
1218        public function __wakeup(): void {}
1219    }
1220
1221    class NodeList implements \IteratorAggregate, \Countable
1222    {
1223        /** @readonly */
1224        public int $length;
1225
1226        /** @implementation-alias DOMNodeList::count */
1227        public function count(): int {}
1228
1229        /** @implementation-alias DOMNodeList::getIterator */
1230        public function getIterator(): \Iterator {}
1231
1232        /** @implementation-alias DOMNodeList::item */
1233        public function item(int $index): ?Node {}
1234    }
1235
1236    class NamedNodeMap implements \IteratorAggregate, \Countable
1237    {
1238        /** @readonly */
1239        public int $length;
1240
1241        /** @implementation-alias DOMNamedNodeMap::item */
1242        public function item(int $index): ?Attr {}
1243        /** @implementation-alias DOMNamedNodeMap::getNamedItem */
1244        public function getNamedItem(string $qualifiedName): ?Attr {}
1245        /** @implementation-alias DOMNamedNodeMap::getNamedItemNS */
1246        public function getNamedItemNS(?string $namespace, string $localName): ?Attr {}
1247
1248        /** @implementation-alias DOMNamedNodeMap::count */
1249        public function count(): int {}
1250
1251        /** @implementation-alias DOMNamedNodeMap::getIterator */
1252        public function getIterator(): \Iterator {}
1253    }
1254
1255    class DTDNamedNodeMap implements \IteratorAggregate, \Countable
1256    {
1257        /** @readonly */
1258        public int $length;
1259
1260        /** @implementation-alias DOMNamedNodeMap::item */
1261        public function item(int $index): Entity|Notation|null {}
1262        /** @implementation-alias DOMNamedNodeMap::getNamedItem */
1263        public function getNamedItem(string $qualifiedName): Entity|Notation|null {}
1264        /** @implementation-alias DOMNamedNodeMap::getNamedItemNS */
1265        public function getNamedItemNS(?string $namespace, string $localName): Entity|Notation|null {}
1266
1267        /** @implementation-alias DOMNamedNodeMap::count */
1268        public function count(): int {}
1269
1270        /** @implementation-alias DOMNamedNodeMap::getIterator */
1271        public function getIterator(): \Iterator {}
1272    }
1273
1274    class HTMLCollection implements \IteratorAggregate, \Countable
1275    {
1276        /** @readonly */
1277        public int $length;
1278
1279        /** @implementation-alias DOMNodeList::item */
1280        public function item(int $index): ?Element {}
1281
1282        public function namedItem(string $key): ?Element {}
1283
1284        /** @implementation-alias DOMNodeList::count */
1285        public function count(): int {}
1286
1287        /** @implementation-alias DOMNodeList::getIterator */
1288        public function getIterator(): \Iterator {}
1289    }
1290
1291    class Element extends Node implements ParentNode, ChildNode
1292    {
1293        /** @readonly */
1294        public ?string $namespaceURI;
1295        /** @readonly */
1296        public ?string $prefix;
1297        /** @readonly */
1298        public string $localName;
1299        /** @readonly */
1300        public string $tagName;
1301
1302        public string $id;
1303        public string $className;
1304
1305        /** @implementation-alias DOMNode::hasAttributes */
1306        public function hasAttributes(): bool {}
1307        /** @readonly */
1308        public NamedNodeMap $attributes;
1309        /** @implementation-alias DOMElement::getAttributeNames */
1310        public function getAttributeNames(): array {}
1311        /** @implementation-alias DOMElement::getAttribute */
1312        public function getAttribute(string $qualifiedName): ?string {}
1313        /** @implementation-alias DOMElement::getAttributeNS */
1314        public function getAttributeNS(?string $namespace, string $localName): ?string {}
1315        /** @implementation-alias DOMElement::setAttribute */
1316        public function setAttribute(string $qualifiedName, string $value): void {}
1317        /** @implementation-alias DOMElement::setAttributeNS */
1318        public function setAttributeNS(?string $namespace, string $qualifiedName, string $value): void {}
1319        public function removeAttribute(string $qualifiedName): void {}
1320        /** @implementation-alias DOMElement::removeAttributeNS */
1321        public function removeAttributeNS(?string $namespace, string $localName): void {}
1322        /** @implementation-alias DOMElement::toggleAttribute */
1323        public function toggleAttribute(string $qualifiedName, ?bool $force = null): bool {}
1324        /** @implementation-alias DOMElement::hasAttribute */
1325        public function hasAttribute(string $qualifiedName): bool {}
1326        /** @implementation-alias DOMElement::hasAttributeNS */
1327        public function hasAttributeNS(?string $namespace, string $localName): bool {}
1328
1329        /** @implementation-alias DOMElement::getAttributeNode */
1330        public function getAttributeNode(string $qualifiedName): ?Attr {}
1331        /** @implementation-alias DOMElement::getAttributeNodeNS */
1332        public function getAttributeNodeNS(?string $namespace, string $localName): ?Attr {}
1333        /** @implementation-alias DOM\Element::setAttributeNodeNS */
1334        public function setAttributeNode(Attr $attr) : ?Attr {}
1335        public function setAttributeNodeNS(Attr $attr) : ?Attr {}
1336        public function removeAttributeNode(Attr $attr) : Attr {}
1337
1338        public function getElementsByTagName(string $qualifiedName): HTMLCollection {}
1339        public function getElementsByTagNameNS(?string $namespace, string $localName): HTMLCollection {}
1340
1341        public function insertAdjacentElement(string $where, Element $element): ?Element {}
1342        /** @implementation-alias DOMElement::insertAdjacentText */
1343        public function insertAdjacentText(string $where, string $data): void {}
1344
1345        /** @readonly */
1346        public ?Element $firstElementChild;
1347        /** @readonly */
1348        public ?Element $lastElementChild;
1349        /** @readonly */
1350        public int $childElementCount;
1351        /** @readonly */
1352        public ?Element $previousElementSibling;
1353        /** @readonly */
1354        public ?Element $nextElementSibling;
1355
1356        /** @implementation-alias DOMElement::setIdAttribute */
1357        public function setIdAttribute(string $qualifiedName, bool $isId): void {}
1358        /** @implementation-alias DOMElement::setIdAttributeNS */
1359        public function setIdAttributeNS(?string $namespace, string $qualifiedName, bool $isId): void {}
1360        public function setIdAttributeNode(Attr $attr, bool $isId): void {}
1361
1362        /** @implementation-alias DOMElement::remove */
1363        public function remove(): void {}
1364        /** @implementation-alias DOMElement::before */
1365        public function before(Node|string ...$nodes): void {}
1366        /** @implementation-alias DOMElement::after */
1367        public function after(Node|string ...$nodes): void {}
1368        /** @implementation-alias DOMElement::replaceWith */
1369        public function replaceWith(Node|string ...$nodes): void {}
1370        /** @implementation-alias DOMElement::append */
1371        public function append(Node|string ...$nodes): void {}
1372        /** @implementation-alias DOMElement::prepend */
1373        public function prepend(Node|string ...$nodes): void {}
1374        /** @implementation-alias DOMElement::replaceChildren */
1375        public function replaceChildren(Node|string ...$nodes): void {}
1376    }
1377
1378    class Attr extends Node
1379    {
1380        /** @readonly */
1381        public ?string $namespaceURI;
1382        /** @readonly */
1383        public ?string $prefix;
1384        /** @readonly */
1385        public string $localName;
1386        /** @readonly */
1387        public string $name;
1388        public string $value;
1389
1390        /** @readonly */
1391        public ?Element $ownerElement;
1392
1393        /** @readonly */
1394        public bool $specified = true;
1395
1396        /** @implementation-alias DOMAttr::isId */
1397        public function isId(): bool {}
1398    }
1399
1400    class CharacterData extends Node implements ChildNode
1401    {
1402        /** @readonly */
1403        public ?Element $previousElementSibling;
1404        /** @readonly */
1405        public ?Element $nextElementSibling;
1406
1407        public string $data;
1408        /** @readonly */
1409        public int $length;
1410        /** @implementation-alias DOMCharacterData::substringData */
1411        public function substringData(int $offset, int $count): string {}
1412        public function appendData(string $data): void {}
1413        public function insertData(int $offset, string $data): void {}
1414        public function deleteData(int $offset, int $count): void {}
1415        public function replaceData(int $offset, int $count, string $data): void {}
1416
1417        /** @implementation-alias DOMElement::remove */
1418        public function remove(): void {}
1419        /** @implementation-alias DOMElement::before */
1420        public function before(Node|string ...$nodes): void {}
1421        /** @implementation-alias DOMElement::after */
1422        public function after(Node|string ...$nodes): void {}
1423        /** @implementation-alias DOMElement::replaceWith */
1424        public function replaceWith(Node|string ...$nodes): void {}
1425    }
1426
1427    class Text extends CharacterData
1428    {
1429        /* No constructor because Node has a final private constructor, so PHP does not allow overriding that. */
1430
1431        /** @implementation-alias DOMText::splitText */
1432        public function splitText(int $offset): Text {}
1433        /** @readonly */
1434        public string $wholeText;
1435    }
1436
1437    class CDATASection extends Text {}
1438
1439    class ProcessingInstruction extends CharacterData
1440    {
1441        /** @readonly */
1442        public string $target;
1443    }
1444
1445    class Comment extends CharacterData
1446    {
1447        /* No constructor because Node has a final private constructor, so PHP does not allow overriding that. */
1448    }
1449
1450    class DocumentType extends Node implements ChildNode
1451    {
1452        /** @readonly */
1453        public string $name;
1454        /** @readonly */
1455        public DTDNamedNodeMap $entities;
1456        /** @readonly */
1457        public DTDNamedNodeMap $notations;
1458        /** @readonly */
1459        public string $publicId;
1460        /** @readonly */
1461        public string $systemId;
1462        /** @readonly */
1463        public ?string $internalSubset;
1464
1465        /** @implementation-alias DOMElement::remove */
1466        public function remove(): void {}
1467        /** @implementation-alias DOMElement::before */
1468        public function before(Node|string ...$nodes): void {}
1469        /** @implementation-alias DOMElement::after */
1470        public function after(Node|string ...$nodes): void {}
1471        /** @implementation-alias DOMElement::replaceWith */
1472        public function replaceWith(Node|string ...$nodes): void {}
1473    }
1474
1475    class DocumentFragment extends Node implements ParentNode
1476    {
1477        /** @readonly */
1478        public ?Element $firstElementChild;
1479        /** @readonly */
1480        public ?Element $lastElementChild;
1481        /** @readonly */
1482        public int $childElementCount;
1483
1484        /** @implementation-alias DOMDocumentFragment::appendXML */
1485        public function appendXML(string $data): bool {}
1486        /** @implementation-alias DOMElement::append */
1487        public function append(Node|string ...$nodes): void {}
1488        /** @implementation-alias DOMElement::prepend */
1489        public function prepend(Node|string ...$nodes): void {}
1490        /** @implementation-alias DOMElement::replaceChildren */
1491        public function replaceChildren(Node|string ...$nodes): void {}
1492    }
1493
1494    class Entity extends Node
1495    {
1496        /** @readonly */
1497        public ?string $publicId;
1498        /** @readonly */
1499        public ?string $systemId;
1500        /** @readonly */
1501        public ?string $notationName;
1502    }
1503
1504    class EntityReference extends Node {}
1505
1506    class Notation extends Node
1507    {
1508        /** @readonly */
1509        public string $publicId;
1510        /** @readonly */
1511        public string $systemId;
1512    }
1513
1514    abstract class Document extends Node implements ParentNode
1515    {
1516        /** @readonly */
1517        public Implementation $implementation;
1518        public string $URL;
1519        public string $documentURI;
1520        public string $characterSet;
1521        public string $charset;
1522        public string $inputEncoding;
1523
1524        /** @readonly */
1525        public ?DocumentType $doctype;
1526        /** @readonly */
1527        public ?Element $documentElement;
1528        /** @implementation-alias DOM\Element::getElementsByTagName */
1529        public function getElementsByTagName(string $qualifiedName): HTMLCollection {}
1530        /** @implementation-alias DOM\Element::getElementsByTagNameNS */
1531        public function getElementsByTagNameNS(?string $namespace, string $localName): HTMLCollection {}
1532
1533        public function createElement(string $localName): Element {}
1534        public function createElementNS(?string $namespace, string $qualifiedName): Element {}
1535        /** @implementation-alias DOMDocument::createDocumentFragment */
1536        public function createDocumentFragment(): DocumentFragment {}
1537        /** @implementation-alias DOMDocument::createTextNode */
1538        public function createTextNode(string $data): Text {}
1539        /** @implementation-alias DOMDocument::createCDATASection */
1540        public function createCDATASection(string $data): CDATASection {}
1541        /** @implementation-alias DOMDocument::createComment */
1542        public function createComment(string $data): Comment {}
1543        public function createProcessingInstruction(string $target, string $data): ProcessingInstruction {}
1544
1545        public function importNode(?Node $node, bool $deep = false): Node {}
1546        public function adoptNode(Node $node): Node {}
1547
1548        /** @implementation-alias DOMDocument::createAttribute */
1549        public function createAttribute(string $localName): Attr {}
1550        /** @implementation-alias DOMDocument::createAttributeNS */
1551        public function createAttributeNS(?string $namespace, string $qualifiedName): Attr {}
1552
1553        /** @readonly */
1554        public ?Element $firstElementChild;
1555        /** @readonly */
1556        public ?Element $lastElementChild;
1557        /** @readonly */
1558        public int $childElementCount;
1559
1560        /** @implementation-alias DOMDocument::getElementById */
1561        public function getElementById(string $elementId): ?Element {}
1562
1563        public function registerNodeClass(string $baseClass, ?string $extendedClass): void {}
1564
1565#ifdef LIBXML_SCHEMAS_ENABLED
1566        /** @implementation-alias DOMDocument::schemaValidate */
1567        public function schemaValidate(string $filename, int $flags = 0): bool {}
1568        /** @implementation-alias DOMDocument::schemaValidateSource */
1569        public function schemaValidateSource(string $source, int $flags = 0): bool {}
1570        /** @implementation-alias DOMDocument::relaxNGValidate */
1571        public function relaxNGValidate(string $filename): bool {}
1572        /** @implementation-alias DOMDocument::relaxNGValidateSource */
1573        public function relaxNGValidateSource(string $source): bool {}
1574#endif
1575
1576        /** @implementation-alias DOMElement::append */
1577        public function append(Node|string ...$nodes): void {}
1578        /** @implementation-alias DOMElement::prepend */
1579        public function prepend(Node|string ...$nodes): void {}
1580        /** @implementation-alias DOMDocument::replaceChildren */
1581        public function replaceChildren(Node|string ...$nodes): void {}
1582
1583        public function importLegacyNode(\DOMNode $node, bool $deep = false): Node {}
1584    }
1585
1586    final class HTMLDocument extends Document
1587    {
1588        public static function createEmpty(string $encoding = "UTF-8"): HTMLDocument {}
1589
1590        public static function createFromFile(string $path, int $options = 0, ?string $overrideEncoding = null): HTMLDocument {}
1591
1592        public static function createFromString(string $source, int $options = 0, ?string $overrideEncoding = null): HTMLDocument {}
1593
1594        /** @implementation-alias DOM\XMLDocument::saveXML */
1595        public function saveXML(?Node $node = null, int $options = 0): string|false {}
1596
1597        /** @implementation-alias DOMDocument::save */
1598        public function saveXMLFile(string $filename, int $options = 0): int|false {}
1599
1600        public function saveHTML(?Node $node = null): string {}
1601
1602        public function saveHTMLFile(string $filename): int|false {}
1603    }
1604
1605    final class XMLDocument extends Document
1606    {
1607        public static function createEmpty(string $version = "1.0", string $encoding = "UTF-8"): XMLDocument {}
1608
1609        public static function createFromFile(string $path, int $options = 0, ?string $overrideEncoding = null): XMLDocument {}
1610
1611        public static function createFromString(string $source, int $options = 0, ?string $overrideEncoding = null): XMLDocument {}
1612
1613        /** @readonly */
1614        public string $xmlEncoding;
1615
1616        public bool $xmlStandalone;
1617
1618        public string $xmlVersion;
1619
1620        public bool $formatOutput;
1621
1622        /** @implementation-alias DOMDocument::createEntityReference */
1623        public function createEntityReference(string $name): EntityReference {}
1624
1625        /** @implementation-alias DOMDocument::validate */
1626        public function validate(): bool {}
1627
1628        /** @implementation-alias DOMDocument::xinclude */
1629        public function xinclude(int $options = 0): int|false {}
1630
1631        public function saveXML(?Node $node = null, int $options = 0): string|false {}
1632
1633        /** @implementation-alias DOMDocument::save */
1634        public function saveXMLFile(string $filename, int $options = 0): int|false {}
1635    }
1636
1637#ifdef LIBXML_XPATH_ENABLED
1638    /** @not-serializable */
1639    final class XPath
1640    {
1641        /** @readonly */
1642        public Document $document;
1643
1644        public bool $registerNodeNamespaces;
1645
1646        public function __construct(Document $document, bool $registerNodeNS = true) {}
1647
1648        public function evaluate(string $expression, ?Node $contextNode = null, bool $registerNodeNS = true): null|bool|float|string|NodeList {}
1649
1650        public function query(string $expression, ?Node $contextNode = null, bool $registerNodeNS = true): NodeList {}
1651
1652        /** @implementation-alias DOMXPath::registerNamespace */
1653        public function registerNamespace(string $prefix, string $namespace): bool {}
1654
1655        /** @implementation-alias DOMXPath::registerPhpFunctions */
1656        public function registerPhpFunctions(string|array|null $restrict = null): void {}
1657
1658        /** @implementation-alias DOMXPath::registerPhpFunctionNS */
1659        public function registerPhpFunctionNS(string $namespaceURI, string $name, callable $callable): void {}
1660
1661        /** @implementation-alias DOMXPath::quote */
1662        public static function quote(string $str): string {}
1663    }
1664#endif
1665
1666    function import_simplexml(object $node): Element {}
1667}
1668