xref: /PHP-8.1/ext/dom/php_dom.stub.php (revision 24e5e4ec)
1<?php
2
3/** @generate-class-entries */
4
5class DOMDocumentType extends DOMNode
6{
7    /** @readonly */
8    public string $name;
9
10    /** @readonly */
11    public DOMNamedNodeMap $entities;
12
13    /** @readonly */
14    public DOMNamedNodeMap $notations;
15
16    /** @readonly */
17    public string $publicId;
18
19    /** @readonly */
20    public string $systemId;
21
22    /** @readonly */
23    public ?string $internalSubset;
24}
25
26class DOMCdataSection extends DOMText
27{
28    public function __construct(string $data) {}
29}
30
31class DOMComment extends DOMCharacterData
32{
33    public function __construct(string $data = "") {}
34}
35
36interface DOMParentNode
37{
38    /** @param DOMNode|string $nodes */
39    public function append(...$nodes): void;
40
41    /** @param DOMNode|string $nodes */
42    public function prepend(...$nodes): void;
43}
44
45interface DOMChildNode
46{
47    public function remove(): void;
48
49    /** @param DOMNode|string $nodes */
50    public function before(... $nodes): void;
51
52    /** @param DOMNode|string $nodes */
53    public function after(...$nodes): void;
54
55    /** @param DOMNode|string $nodes */
56    public function replaceWith(...$nodes): void;
57}
58
59class DOMNode
60{
61    /** @readonly */
62    public string $nodeName;
63
64    public ?string $nodeValue;
65
66    /** @readonly */
67    public int $nodeType;
68
69    /** @readonly */
70    public ?DOMNode $parentNode;
71
72    /** @readonly */
73    public DOMNodeList $childNodes;
74
75    /** @readonly */
76    public ?DOMNode $firstChild;
77
78    /** @readonly */
79    public ?DOMNode $lastChild;
80
81    /** @readonly */
82    public ?DOMNode $previousSibling;
83
84    /** @readonly */
85    public ?DOMNode $nextSibling;
86
87    /** @readonly */
88    public ?DOMNamedNodeMap $attributes;
89
90    /** @readonly */
91    public ?DOMDocument $ownerDocument;
92
93    /** @readonly */
94    public ?string $namespaceURI;
95
96    public string $prefix;
97
98    /** @readonly */
99    public ?string $localName;
100
101    /** @readonly */
102    public ?string $baseURI;
103
104    public string $textContent;
105
106    public function __sleep(): array {}
107
108    public function __wakeup(): void {}
109
110    /** @return DOMNode|false */
111    public function appendChild(DOMNode $node) {}
112
113    /** @tentative-return-type */
114    public function C14N(bool $exclusive = false, bool $withComments = false, ?array $xpath = null, ?array $nsPrefixes = null): string|false {}
115
116    /** @tentative-return-type */
117    public function C14NFile(string $uri, bool $exclusive = false, bool $withComments = false, ?array $xpath = null, ?array $nsPrefixes = null): int|false {}
118
119    /** @return DOMNode|false */
120    public function cloneNode(bool $deep = false) {}
121
122    /** @tentative-return-type */
123    public function getLineNo(): int {}
124
125    /** @tentative-return-type */
126    public function getNodePath(): ?string {}
127
128    /** @tentative-return-type */
129    public function hasAttributes(): bool {}
130
131    /** @tentative-return-type */
132    public function hasChildNodes(): bool {}
133
134    /** @return DOMNode|false */
135    public function insertBefore(DOMNode $node, ?DOMNode $child = null) {}
136
137    /** @tentative-return-type */
138    public function isDefaultNamespace(string $namespace): bool {}
139
140    /** @tentative-return-type */
141    public function isSameNode(DOMNode $otherNode): bool {}
142
143    /** @tentative-return-type */
144    public function isSupported(string $feature, string $version): bool {}
145
146    /** @tentative-return-type */
147    public function lookupNamespaceURI(?string $prefix): ?string {}
148
149    /** @tentative-return-type */
150    public function lookupPrefix(string $namespace): ?string {}
151
152    /** @tentative-return-type */
153    public function normalize(): void {}
154
155    /** @return DOMNode|false */
156    public function removeChild(DOMNode $child) {}
157
158    /** @return DOMNode|false */
159    public function replaceChild(DOMNode $node, DOMNode $child) {}
160}
161
162class DOMNameSpaceNode
163{
164    /** @readonly */
165    public string $nodeName;
166
167    /** @readonly */
168    public ?string $nodeValue;
169
170    /** @readonly */
171    public int $nodeType;
172
173    /** @readonly */
174    public string $prefix;
175
176    /** @readonly */
177    public ?string $localName;
178
179    /** @readonly */
180    public ?string $namespaceURI;
181
182    /** @readonly */
183    public ?DOMDocument $ownerDocument;
184
185    /** @readonly */
186    public ?DOMNode $parentNode;
187
188    /** @implementation-alias DOMNode::__sleep */
189    public function __sleep(): array {}
190
191    /** @implementation-alias DOMNode::__wakeup */
192    public function __wakeup(): void {}
193}
194
195class DOMImplementation
196{
197    /** @tentative-return-type */
198    public function getFeature(string $feature, string $version): never {}
199
200    /** @tentative-return-type */
201    public function hasFeature(string $feature, string $version): bool {}
202
203    /** @return DOMDocumentType|false */
204    public function createDocumentType(string $qualifiedName, string $publicId = "", string $systemId = "") {}
205
206    /** @return DOMDocument|false */
207    public function createDocument(?string $namespace = null, string $qualifiedName = "", ?DOMDocumentType $doctype = null) {}
208}
209
210class DOMDocumentFragment extends DOMNode implements DOMParentNode
211{
212    /** @readonly */
213    public ?DOMElement $firstElementChild;
214
215    /** @readonly */
216    public ?DOMElement $lastElementChild;
217
218    /** @readonly */
219    public int $childElementCount;
220
221    public function __construct() {}
222
223    /** @tentative-return-type */
224    public function appendXML(string $data): bool {}
225
226    /** @param DOMNode|string $nodes */
227    public function append(...$nodes): void {}
228
229    /** @param DOMNode|string $nodes */
230    public function prepend(...$nodes): void {}
231}
232
233class DOMNodeList implements IteratorAggregate, Countable
234{
235    /** @readonly */
236    public int $length;
237
238    /** @tentative-return-type */
239    public function count(): int {}
240
241    public function getIterator(): Iterator {}
242
243    /** @return DOMElement|DOMNode|DOMNameSpaceNode|null */
244    public function item(int $index) {}
245}
246
247class DOMCharacterData extends DOMNode implements DOMChildNode
248{
249    public string $data;
250
251    /** @readonly */
252    public int $length;
253
254    /** @readonly */
255    public ?DOMElement $previousElementSibling;
256
257    /** @readonly */
258    public ?DOMElement $nextElementSibling;
259
260    /** @tentative-return-type */
261    public function appendData(string $data): bool {}
262
263    /** @return string|false */
264    public function substringData(int $offset, int $count) {}
265
266    /** @tentative-return-type */
267    public function insertData(int $offset, string $data): bool {}
268
269    /** @tentative-return-type */
270    public function deleteData(int $offset, int $count): bool {}
271
272    /** @tentative-return-type */
273    public function replaceData(int $offset, int $count, string $data): bool {}
274
275    /** @param DOMNode|string $nodes */
276    public function replaceWith(...$nodes): void {}
277
278    public function remove(): void {}
279
280    /** @param DOMNode|string $nodes */
281    public function before(... $nodes): void {}
282
283    /** @param DOMNode|string $nodes */
284    public function after(...$nodes): void {}
285}
286
287class DOMAttr extends DOMNode
288{
289    /** @readonly */
290    public string $name;
291
292    /** @readonly */
293    public bool $specified = true;
294
295    public string $value;
296
297    /** @readonly */
298    public ?DOMElement $ownerElement;
299
300    /** @readonly */
301    public mixed $schemaTypeInfo = null;
302
303    public function __construct(string $name, string $value = "") {}
304
305    /** @tentative-return-type */
306    public function isId(): bool {}
307}
308
309class DOMElement extends DOMNode implements DOMParentNode, DOMChildNode
310{
311    /** @readonly */
312    public string $tagName;
313
314    /** @readonly */
315    public mixed $schemaTypeInfo = null;
316
317    /** @readonly */
318    public ?DOMElement $firstElementChild;
319
320    /** @readonly */
321    public ?DOMElement $lastElementChild;
322
323    /** @readonly */
324    public int $childElementCount;
325
326    /** @readonly */
327    public ?DOMElement $previousElementSibling;
328
329    /** @readonly */
330    public ?DOMElement $nextElementSibling;
331
332    public function __construct(string $qualifiedName, ?string $value = null, string $namespace = "") {}
333
334    /** @tentative-return-type */
335    public function getAttribute(string $qualifiedName): string {}
336
337    /** @tentative-return-type */
338    public function getAttributeNS(?string $namespace, string $localName): string {}
339
340    /** @return DOMAttr|DOMNameSpaceNode|false */
341    public function getAttributeNode(string $qualifiedName) {}
342
343    /** @return DOMAttr|DOMNameSpaceNode|null */
344    public function getAttributeNodeNS(?string $namespace, string $localName) {}
345
346    /** @tentative-return-type */
347    public function getElementsByTagName(string $qualifiedName): DOMNodeList {}
348
349    /** @tentative-return-type */
350    public function getElementsByTagNameNS(?string $namespace, string $localName): DOMNodeList {}
351
352    /** @tentative-return-type */
353    public function hasAttribute(string $qualifiedName): bool {}
354
355    /** @tentative-return-type */
356    public function hasAttributeNS(?string $namespace, string $localName): bool {}
357
358    /** @tentative-return-type */
359    public function removeAttribute(string $qualifiedName): bool {}
360
361    /** @tentative-return-type */
362    public function removeAttributeNS(?string $namespace, string $localName): void {}
363
364    /** @return DOMAttr|false */
365    public function removeAttributeNode(DOMAttr $attr) {}
366
367    /** @return DOMAttr|bool */
368    public function setAttribute(string $qualifiedName, string $value) {} // TODO return type shouldn't depend on the call scope
369
370    /** @tentative-return-type */
371    public function setAttributeNS(?string $namespace, string $qualifiedName, string $value): void {}
372
373    /** @return DOMAttr|null|false */
374    public function setAttributeNode(DOMAttr $attr) {}
375
376    /** @return DOMAttr|null|false */
377    public function setAttributeNodeNS(DOMAttr $attr) {}
378
379    /** @tentative-return-type */
380    public function setIdAttribute(string $qualifiedName, bool $isId): void {}
381
382    /** @tentative-return-type */
383    public function setIdAttributeNS(string $namespace, string $qualifiedName, bool $isId): void {}
384
385    /** @tentative-return-type */
386    public function setIdAttributeNode(DOMAttr $attr, bool $isId): void {}
387
388    public function remove(): void {}
389
390    /** @param DOMNode|string $nodes */
391    public function before(... $nodes): void {}
392
393    /** @param DOMNode|string $nodes */
394    public function after(...$nodes): void {}
395
396    /** @param DOMNode|string $nodes */
397    public function replaceWith(...$nodes): void {}
398
399    /** @param DOMNode|string $nodes */
400    public function append(...$nodes): void {}
401
402    /** @param DOMNode|string $nodes */
403    public function prepend(...$nodes): void {}
404}
405
406class DOMDocument extends DOMNode implements DOMParentNode
407{
408    /** @readonly */
409    public ?DOMDocumentType $doctype;
410
411    /** @readonly */
412    public DOMImplementation $implementation;
413
414    /** @readonly */
415    public ?DOMElement $documentElement;
416
417    /**
418     * @readonly
419     * @deprecated
420     */
421    public ?string $actualEncoding;
422
423    public ?string $encoding;
424
425    /** @readonly */
426    public ?string $xmlEncoding;
427
428    public bool $standalone;
429
430    public bool $xmlStandalone;
431
432    public ?string $version;
433
434    public ?string $xmlVersion;
435
436    public bool $strictErrorChecking;
437
438    public ?string $documentURI;
439
440    /**
441     * @readonly
442     * @deprecated
443     */
444    public mixed $config;
445
446    public bool $formatOutput;
447
448    public bool $validateOnParse;
449
450    public bool $resolveExternals;
451
452    public bool $preserveWhiteSpace;
453
454    public bool $recover;
455
456    public bool $substituteEntities;
457
458    /** @readonly */
459    public ?DOMElement $firstElementChild;
460
461    /** @readonly */
462    public ?DOMElement $lastElementChild;
463
464    /** @readonly */
465    public int $childElementCount;
466
467    public function __construct(string $version = "1.0", string $encoding = "") {}
468
469    /** @return DOMAttr|false */
470    public function createAttribute(string $localName) {}
471
472    /** @return DOMAttr|false */
473    public function createAttributeNS(?string $namespace, string $qualifiedName) {}
474
475    /** @return DOMCdataSection|false */
476    public function createCDATASection(string $data) {}
477
478    /** @tentative-return-type */
479    public function createComment(string $data): DOMComment {}
480
481    /** @tentative-return-type */
482    public function createDocumentFragment(): DOMDocumentFragment {}
483
484    /** @return DOMElement|false */
485    public function createElement(string $localName, string $value = "")  {}
486
487    /** @return DOMElement|false */
488    public function createElementNS(?string $namespace, string $qualifiedName, string $value = "") {}
489
490    /** @return DOMEntityReference|false */
491    public function createEntityReference(string $name) {}
492
493    /** @return DOMProcessingInstruction|false */
494    public function createProcessingInstruction(string $target, string $data = "") {}
495
496    /** @tentative-return-type */
497    public function createTextNode(string $data): DOMText {}
498
499    /** @tentative-return-type */
500    public function getElementById(string $elementId): ?DOMElement {}
501
502    /** @tentative-return-type */
503    public function getElementsByTagName(string $qualifiedName): DOMNodeList {}
504
505    /** @tentative-return-type */
506    public function getElementsByTagNameNS(?string $namespace, string $localName): DOMNodeList {}
507
508    /** @return DOMNode|false */
509    public function importNode(DOMNode $node, bool $deep = false) {}
510
511    /** @return DOMDocument|bool */
512    public function load(string $filename, int $options = 0) {} // TODO return type shouldn't depend on the call scope
513
514    /** @return DOMDocument|bool */
515    public function loadXML(string $source, int $options = 0) {} // TODO return type shouldn't depend on the call scope
516
517    /** @tentative-return-type */
518    public function normalizeDocument(): void {}
519
520    /** @tentative-return-type */
521    public function registerNodeClass(string $baseClass, ?string $extendedClass): bool {}
522
523    /** @tentative-return-type */
524    public function save(string $filename, int $options = 0): int|false {}
525
526#ifdef LIBXML_HTML_ENABLED
527    /** @return DOMDocument|bool */
528    public function loadHTML(string $source, int $options = 0) {} // TODO return type shouldn't depend on the call scope
529
530    /** @return DOMDocument|bool */
531    public function loadHTMLFile(string $filename, int $options = 0) {} // TODO return type shouldn't depend on the call scope
532
533    /** @tentative-return-type */
534    public function saveHTML(?DOMNode $node = null): string|false {}
535
536    /** @tentative-return-type */
537    public function saveHTMLFile(string $filename): int|false {}
538#endif
539
540    /** @tentative-return-type */
541    public function saveXML(?DOMNode $node = null, int $options = 0): string|false {}
542
543#ifdef LIBXML_SCHEMAS_ENABLED
544    /** @tentative-return-type */
545    public function schemaValidate(string $filename, int $flags = 0): bool {}
546
547    /** @tentative-return-type */
548    public function schemaValidateSource(string $source, int $flags = 0): bool {}
549
550    /** @tentative-return-type */
551    public function relaxNGValidate(string $filename): bool {}
552
553    /** @tentative-return-type */
554    public function relaxNGValidateSource(string $source): bool {}
555#endif
556
557    /** @tentative-return-type */
558    public function validate(): bool {}
559
560    /** @tentative-return-type */
561    public function xinclude(int $options = 0): int|false {}
562
563    /** @return DOMNode|false */
564    public function adoptNode(DOMNode $node) {}
565
566    /** @param DOMNode|string $nodes */
567    public function append(...$nodes): void {}
568
569    /** @param DOMNode|string $nodes */
570    public function prepend(...$nodes): void {}
571}
572
573final class DOMException extends Exception
574{
575    /**
576     * Intentionally left untyped for BC reasons
577     * @var int
578     */
579    public $code = 0;
580}
581
582class DOMText extends DOMCharacterData
583{
584    /** @readonly */
585    public string $wholeText;
586
587    public function __construct(string $data = "") {}
588
589    /** @tentative-return-type */
590    public function isWhitespaceInElementContent(): bool {}
591
592    /**
593     * @tentative-return-type
594     * @alias DOMText::isWhitespaceInElementContent
595     */
596    public function isElementContentWhitespace(): bool {}
597
598    /** @return DOMText|false */
599    public function splitText(int $offset) {}
600}
601
602class DOMNamedNodeMap implements IteratorAggregate, Countable
603{
604    /** @readonly */
605    public int $length;
606
607    /** @tentative-return-type */
608    public function getNamedItem(string $qualifiedName): ?DOMNode {} // TODO DOM spec returns DOMAttr
609
610    /** @tentative-return-type */
611    public function getNamedItemNS(?string $namespace, string $localName): ?DOMNode {} // TODO DOM spec returns DOMAttr
612
613    /** @tentative-return-type */
614    public function item(int $index): ?DOMNode {} // TODO DOM spec returns DOMAttr
615
616    /** @tentative-return-type */
617    public function count(): int {}
618
619    public function getIterator(): Iterator {}
620}
621
622class DOMEntity extends DOMNode
623{
624    /** @readonly */
625    public ?string $publicId;
626
627    /** @readonly */
628    public ?string $systemId;
629
630    /** @readonly */
631    public ?string $notationName;
632
633    /**
634     * @readonly
635     * @deprecated
636     */
637    public ?string $actualEncoding = null;
638
639    /**
640     * @readonly
641     * @deprecated
642     */
643    public ?string $encoding = null;
644
645    /**
646     * @readonly
647     * @deprecated
648     */
649    public ?string $version = null;
650}
651
652class DOMEntityReference extends DOMNode
653{
654    public function __construct(string $name) {}
655}
656
657class DOMNotation extends DOMNode
658{
659    /** @readonly */
660    public string $publicId;
661
662    /** @readonly */
663    public string $systemId;
664}
665
666class DOMProcessingInstruction extends DOMNode
667{
668    /** @readonly */
669    public string $target;
670
671    public string $data;
672
673    public function __construct(string $name, string $value = "") {}
674}
675
676#ifdef LIBXML_XPATH_ENABLED
677/** @not-serializable */
678class DOMXPath
679{
680    /** @readonly */
681    public DOMDocument $document;
682
683    public bool $registerNodeNamespaces;
684
685    public function __construct(DOMDocument $document, bool $registerNodeNS = true) {}
686
687    /** @tentative-return-type */
688    public function evaluate(string $expression, ?DOMNode $contextNode = null, bool $registerNodeNS = true): mixed {}
689
690    /** @tentative-return-type */
691    public function query(string $expression, ?DOMNode $contextNode = null, bool $registerNodeNS = true): mixed {}
692
693    /** @tentative-return-type */
694    public function registerNamespace(string $prefix, string $namespace): bool {}
695
696    /** @tentative-return-type */
697    public function registerPhpFunctions(string|array|null $restrict = null): void {}
698}
699#endif
700
701function dom_import_simplexml(object $node): DOMElement {}
702