php_dom.stub.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. <?php
  2. /** @generate-class-entries */
  3. class DOMDocumentType extends DOMNode
  4. {
  5. /** @readonly */
  6. public string $name;
  7. /** @readonly */
  8. public DOMNamedNodeMap $entities;
  9. /** @readonly */
  10. public DOMNamedNodeMap $notations;
  11. /** @readonly */
  12. public string $publicId;
  13. /** @readonly */
  14. public string $systemId;
  15. /** @readonly */
  16. public ?string $internalSubset;
  17. }
  18. class DOMCdataSection extends DOMText
  19. {
  20. public function __construct(string $data) {}
  21. }
  22. class DOMComment extends DOMCharacterData
  23. {
  24. public function __construct(string $data = "") {}
  25. }
  26. interface DOMParentNode
  27. {
  28. /** @param DOMNode|string $nodes */
  29. public function append(...$nodes): void;
  30. /** @param DOMNode|string $nodes */
  31. public function prepend(...$nodes): void;
  32. }
  33. interface DOMChildNode
  34. {
  35. public function remove(): void;
  36. /** @param DOMNode|string $nodes */
  37. public function before(... $nodes): void;
  38. /** @param DOMNode|string $nodes */
  39. public function after(...$nodes): void;
  40. /** @param DOMNode|string $nodes */
  41. public function replaceWith(...$nodes): void;
  42. }
  43. /** @not-serializable */
  44. class DOMNode
  45. {
  46. /** @readonly */
  47. public string $nodeName;
  48. public ?string $nodeValue;
  49. /** @readonly */
  50. public int $nodeType;
  51. /** @readonly */
  52. public ?DOMNode $parentNode;
  53. /** @readonly */
  54. public DOMNodeList $childNodes;
  55. /** @readonly */
  56. public ?DOMNode $firstChild;
  57. /** @readonly */
  58. public ?DOMNode $lastChild;
  59. /** @readonly */
  60. public ?DOMNode $previousSibling;
  61. /** @readonly */
  62. public ?DOMNode $nextSibling;
  63. /** @readonly */
  64. public ?DOMNamedNodeMap $attributes;
  65. /** @readonly */
  66. public ?DOMDocument $ownerDocument;
  67. /** @readonly */
  68. public ?string $namespaceURI;
  69. public string $prefix;
  70. /** @readonly */
  71. public ?string $localName;
  72. /** @readonly */
  73. public ?string $baseURI;
  74. public string $textContent;
  75. /** @return DOMNode|false */
  76. public function appendChild(DOMNode $node) {}
  77. /** @tentative-return-type */
  78. public function C14N(bool $exclusive = false, bool $withComments = false, ?array $xpath = null, ?array $nsPrefixes = null): string|false {}
  79. /** @tentative-return-type */
  80. public function C14NFile(string $uri, bool $exclusive = false, bool $withComments = false, ?array $xpath = null, ?array $nsPrefixes = null): int|false {}
  81. /** @return DOMNode|false */
  82. public function cloneNode(bool $deep = false) {}
  83. /** @tentative-return-type */
  84. public function getLineNo(): int {}
  85. /** @tentative-return-type */
  86. public function getNodePath(): ?string {}
  87. /** @tentative-return-type */
  88. public function hasAttributes(): bool {}
  89. /** @tentative-return-type */
  90. public function hasChildNodes(): bool {}
  91. /** @return DOMNode|false */
  92. public function insertBefore(DOMNode $node, ?DOMNode $child = null) {}
  93. /** @tentative-return-type */
  94. public function isDefaultNamespace(string $namespace): bool {}
  95. /** @tentative-return-type */
  96. public function isSameNode(DOMNode $otherNode): bool {}
  97. /** @tentative-return-type */
  98. public function isSupported(string $feature, string $version): bool {}
  99. /** @tentative-return-type */
  100. public function lookupNamespaceURI(?string $prefix): ?string {}
  101. /** @tentative-return-type */
  102. public function lookupPrefix(string $namespace): ?string {}
  103. /** @tentative-return-type */
  104. public function normalize(): void {}
  105. /** @return DOMNode|false */
  106. public function removeChild(DOMNode $child) {}
  107. /** @return DOMNode|false */
  108. public function replaceChild(DOMNode $node, DOMNode $child) {}
  109. }
  110. /** @not-serializable */
  111. class DOMNameSpaceNode
  112. {
  113. /** @readonly */
  114. public string $nodeName;
  115. /** @readonly */
  116. public ?string $nodeValue;
  117. /** @readonly */
  118. public int $nodeType;
  119. /** @readonly */
  120. public string $prefix;
  121. /** @readonly */
  122. public ?string $localName;
  123. /** @readonly */
  124. public ?string $namespaceURI;
  125. /** @readonly */
  126. public ?DOMDocument $ownerDocument;
  127. /** @readonly */
  128. public ?DOMNode $parentNode;
  129. }
  130. class DOMImplementation
  131. {
  132. /** @tentative-return-type */
  133. public function getFeature(string $feature, string $version): never {}
  134. /** @tentative-return-type */
  135. public function hasFeature(string $feature, string $version): bool {}
  136. /** @return DOMDocumentType|false */
  137. public function createDocumentType(string $qualifiedName, string $publicId = "", string $systemId = "") {}
  138. /** @return DOMDocument|false */
  139. public function createDocument(?string $namespace = null, string $qualifiedName = "", ?DOMDocumentType $doctype = null) {}
  140. }
  141. class DOMDocumentFragment extends DOMNode implements DOMParentNode
  142. {
  143. /** @readonly */
  144. public ?DOMElement $firstElementChild;
  145. /** @readonly */
  146. public ?DOMElement $lastElementChild;
  147. /** @readonly */
  148. public int $childElementCount;
  149. public function __construct() {}
  150. /** @tentative-return-type */
  151. public function appendXML(string $data): bool {}
  152. /** @param DOMNode|string $nodes */
  153. public function append(...$nodes): void {}
  154. /** @param DOMNode|string $nodes */
  155. public function prepend(...$nodes): void {}
  156. }
  157. class DOMNodeList implements IteratorAggregate, Countable
  158. {
  159. /** @readonly */
  160. public int $length;
  161. /** @tentative-return-type */
  162. public function count(): int {}
  163. public function getIterator(): Iterator {}
  164. /** @return DOMNode|DOMNameSpaceNode|null */
  165. public function item(int $index) {}
  166. }
  167. class DOMCharacterData extends DOMNode implements DOMChildNode
  168. {
  169. public string $data;
  170. /** @readonly */
  171. public int $length;
  172. /** @readonly */
  173. public ?DOMElement $previousElementSibling;
  174. /** @readonly */
  175. public ?DOMElement $nextElementSibling;
  176. /** @tentative-return-type */
  177. public function appendData(string $data): bool {}
  178. /** @return string|false */
  179. public function substringData(int $offset, int $count) {}
  180. /** @tentative-return-type */
  181. public function insertData(int $offset, string $data): bool {}
  182. /** @tentative-return-type */
  183. public function deleteData(int $offset, int $count): bool {}
  184. /** @tentative-return-type */
  185. public function replaceData(int $offset, int $count, string $data): bool {}
  186. /** @param DOMNode|string $nodes */
  187. public function replaceWith(...$nodes): void {}
  188. public function remove(): void {}
  189. /** @param DOMNode|string $nodes */
  190. public function before(... $nodes): void {}
  191. /** @param DOMNode|string $nodes */
  192. public function after(...$nodes): void {}
  193. }
  194. class DOMAttr extends DOMNode
  195. {
  196. /** @readonly */
  197. public string $name;
  198. /** @readonly */
  199. public bool $specified = true;
  200. public string $value;
  201. /** @readonly */
  202. public ?DOMElement $ownerElement;
  203. /** @readonly */
  204. public mixed $schemaTypeInfo = null;
  205. public function __construct(string $name, string $value = "") {}
  206. /** @tentative-return-type */
  207. public function isId(): bool {}
  208. }
  209. class DOMElement extends DOMNode implements DOMParentNode, DOMChildNode
  210. {
  211. /** @readonly */
  212. public string $tagName;
  213. /** @readonly */
  214. public mixed $schemaTypeInfo = null;
  215. /** @readonly */
  216. public ?DOMElement $firstElementChild;
  217. /** @readonly */
  218. public ?DOMElement $lastElementChild;
  219. /** @readonly */
  220. public int $childElementCount;
  221. /** @readonly */
  222. public ?DOMElement $previousElementSibling;
  223. /** @readonly */
  224. public ?DOMElement $nextElementSibling;
  225. public function __construct(string $qualifiedName, ?string $value = null, string $namespace = "") {}
  226. /** @tentative-return-type */
  227. public function getAttribute(string $qualifiedName): string {}
  228. /** @tentative-return-type */
  229. public function getAttributeNS(?string $namespace, string $localName): string {}
  230. /** @return DOMAttr|DOMNameSpaceNode|false */
  231. public function getAttributeNode(string $qualifiedName) {}
  232. /** @return DOMAttr|DOMNameSpaceNode|null */
  233. public function getAttributeNodeNS(?string $namespace, string $localName) {}
  234. /** @tentative-return-type */
  235. public function getElementsByTagName(string $qualifiedName): DOMNodeList {}
  236. /** @tentative-return-type */
  237. public function getElementsByTagNameNS(?string $namespace, string $localName): DOMNodeList {}
  238. /** @tentative-return-type */
  239. public function hasAttribute(string $qualifiedName): bool {}
  240. /** @tentative-return-type */
  241. public function hasAttributeNS(?string $namespace, string $localName): bool {}
  242. /** @tentative-return-type */
  243. public function removeAttribute(string $qualifiedName): bool {}
  244. /** @tentative-return-type */
  245. public function removeAttributeNS(?string $namespace, string $localName): void {}
  246. /** @return DOMAttr|false */
  247. public function removeAttributeNode(DOMAttr $attr) {}
  248. /** @return DOMAttr|bool */
  249. public function setAttribute(string $qualifiedName, string $value) {} // TODO return type shouldn't depend on the call scope
  250. /** @tentative-return-type */
  251. public function setAttributeNS(?string $namespace, string $qualifiedName, string $value): void {}
  252. /** @return DOMAttr|null|false */
  253. public function setAttributeNode(DOMAttr $attr) {}
  254. /** @return DOMAttr|null|false */
  255. public function setAttributeNodeNS(DOMAttr $attr) {}
  256. /** @tentative-return-type */
  257. public function setIdAttribute(string $qualifiedName, bool $isId): void {}
  258. /** @tentative-return-type */
  259. public function setIdAttributeNS(string $namespace, string $qualifiedName, bool $isId): void {}
  260. /** @tentative-return-type */
  261. public function setIdAttributeNode(DOMAttr $attr, bool $isId): void {}
  262. public function remove(): void {}
  263. /** @param DOMNode|string $nodes */
  264. public function before(... $nodes): void {}
  265. /** @param DOMNode|string $nodes */
  266. public function after(...$nodes): void {}
  267. /** @param DOMNode|string $nodes */
  268. public function replaceWith(...$nodes): void {}
  269. /** @param DOMNode|string $nodes */
  270. public function append(...$nodes): void {}
  271. /** @param DOMNode|string $nodes */
  272. public function prepend(...$nodes): void {}
  273. }
  274. class DOMDocument extends DOMNode implements DOMParentNode
  275. {
  276. /** @readonly */
  277. public ?DOMDocumentType $doctype;
  278. /** @readonly */
  279. public DOMImplementation $implementation;
  280. /** @readonly */
  281. public ?DOMElement $documentElement;
  282. /**
  283. * @readonly
  284. * @deprecated
  285. */
  286. public ?string $actualEncoding;
  287. public ?string $encoding;
  288. /** @readonly */
  289. public ?string $xmlEncoding;
  290. public bool $standalone;
  291. public bool $xmlStandalone;
  292. public ?string $version;
  293. public ?string $xmlVersion;
  294. public bool $strictErrorChecking;
  295. public ?string $documentURI;
  296. /**
  297. * @readonly
  298. * @deprecated
  299. */
  300. public mixed $config = null;
  301. public bool $formatOutput;
  302. public bool $validateOnParse;
  303. public bool $resolveExternals;
  304. public bool $preserveWhiteSpace;
  305. public bool $recover;
  306. public bool $substituteEntities;
  307. /** @readonly */
  308. public ?DOMElement $firstElementChild;
  309. /** @readonly */
  310. public ?DOMElement $lastElementChild;
  311. /** @readonly */
  312. public int $childElementCount;
  313. public function __construct(string $version = "1.0", string $encoding = "") {}
  314. /** @return DOMAttr|false */
  315. public function createAttribute(string $localName) {}
  316. /** @return DOMAttr|false */
  317. public function createAttributeNS(?string $namespace, string $qualifiedName) {}
  318. /** @return DOMCdataSection|false */
  319. public function createCDATASection(string $data) {}
  320. /** @tentative-return-type */
  321. public function createComment(string $data): DOMComment {}
  322. /** @tentative-return-type */
  323. public function createDocumentFragment(): DOMDocumentFragment {}
  324. /** @return DOMElement|false */
  325. public function createElement(string $localName, string $value = "") {}
  326. /** @return DOMElement|false */
  327. public function createElementNS(?string $namespace, string $qualifiedName, string $value = "") {}
  328. /** @return DOMEntityReference|false */
  329. public function createEntityReference(string $name) {}
  330. /** @return DOMProcessingInstruction|false */
  331. public function createProcessingInstruction(string $target, string $data = "") {}
  332. /** @tentative-return-type */
  333. public function createTextNode(string $data): DOMText {}
  334. /** @tentative-return-type */
  335. public function getElementById(string $elementId): ?DOMElement {}
  336. /** @tentative-return-type */
  337. public function getElementsByTagName(string $qualifiedName): DOMNodeList {}
  338. /** @tentative-return-type */
  339. public function getElementsByTagNameNS(?string $namespace, string $localName): DOMNodeList {}
  340. /** @return DOMNode|false */
  341. public function importNode(DOMNode $node, bool $deep = false) {}
  342. /** @return DOMDocument|bool */
  343. public function load(string $filename, int $options = 0) {} // TODO return type shouldn't depend on the call scope
  344. /** @return DOMDocument|bool */
  345. public function loadXML(string $source, int $options = 0) {} // TODO return type shouldn't depend on the call scope
  346. /** @tentative-return-type */
  347. public function normalizeDocument(): void {}
  348. /** @tentative-return-type */
  349. public function registerNodeClass(string $baseClass, ?string $extendedClass): bool {}
  350. /** @tentative-return-type */
  351. public function save(string $filename, int $options = 0): int|false {}
  352. #ifdef LIBXML_HTML_ENABLED
  353. /** @return DOMDocument|bool */
  354. public function loadHTML(string $source, int $options = 0) {} // TODO return type shouldn't depend on the call scope
  355. /** @return DOMDocument|bool */
  356. public function loadHTMLFile(string $filename, int $options = 0) {} // TODO return type shouldn't depend on the call scope
  357. /** @tentative-return-type */
  358. public function saveHTML(?DOMNode $node = null): string|false {}
  359. /** @tentative-return-type */
  360. public function saveHTMLFile(string $filename): int|false {}
  361. #endif
  362. /** @tentative-return-type */
  363. public function saveXML(?DOMNode $node = null, int $options = 0): string|false {}
  364. #ifdef LIBXML_SCHEMAS_ENABLED
  365. /** @tentative-return-type */
  366. public function schemaValidate(string $filename, int $flags = 0): bool {}
  367. /** @tentative-return-type */
  368. public function schemaValidateSource(string $source, int $flags = 0): bool {}
  369. /** @tentative-return-type */
  370. public function relaxNGValidate(string $filename): bool {}
  371. /** @tentative-return-type */
  372. public function relaxNGValidateSource(string $source): bool {}
  373. #endif
  374. /** @tentative-return-type */
  375. public function validate(): bool {}
  376. /** @tentative-return-type */
  377. public function xinclude(int $options = 0): int|false {}
  378. /** @return DOMNode|false */
  379. public function adoptNode(DOMNode $node) {}
  380. /** @param DOMNode|string $nodes */
  381. public function append(...$nodes): void {}
  382. /** @param DOMNode|string $nodes */
  383. public function prepend(...$nodes): void {}
  384. }
  385. final class DOMException extends Exception
  386. {
  387. /**
  388. * Intentionally left untyped for BC reasons
  389. * @var int
  390. */
  391. public $code = 0;
  392. }
  393. class DOMText extends DOMCharacterData
  394. {
  395. /** @readonly */
  396. public string $wholeText;
  397. public function __construct(string $data = "") {}
  398. /** @tentative-return-type */
  399. public function isWhitespaceInElementContent(): bool {}
  400. /**
  401. * @tentative-return-type
  402. * @alias DOMText::isWhitespaceInElementContent
  403. */
  404. public function isElementContentWhitespace(): bool {}
  405. /** @return DOMText|false */
  406. public function splitText(int $offset) {}
  407. }
  408. class DOMNamedNodeMap implements IteratorAggregate, Countable
  409. {
  410. /** @readonly */
  411. public int $length;
  412. /** @tentative-return-type */
  413. public function getNamedItem(string $qualifiedName): ?DOMNode {} // TODO DOM spec returns DOMAttr
  414. /** @tentative-return-type */
  415. public function getNamedItemNS(?string $namespace, string $localName): ?DOMNode {} // TODO DOM spec returns DOMAttr
  416. /** @tentative-return-type */
  417. public function item(int $index): ?DOMNode {} // TODO DOM spec returns DOMAttr
  418. /** @tentative-return-type */
  419. public function count(): int {}
  420. public function getIterator(): Iterator {}
  421. }
  422. class DOMEntity extends DOMNode
  423. {
  424. /** @readonly */
  425. public ?string $publicId;
  426. /** @readonly */
  427. public ?string $systemId;
  428. /** @readonly */
  429. public ?string $notationName;
  430. /**
  431. * @readonly
  432. * @deprecated
  433. */
  434. public ?string $actualEncoding = null;
  435. /**
  436. * @readonly
  437. * @deprecated
  438. */
  439. public ?string $encoding = null;
  440. /**
  441. * @readonly
  442. * @deprecated
  443. */
  444. public ?string $version = null;
  445. }
  446. class DOMEntityReference extends DOMNode
  447. {
  448. public function __construct(string $name) {}
  449. }
  450. class DOMNotation extends DOMNode
  451. {
  452. /** @readonly */
  453. public string $publicId;
  454. /** @readonly */
  455. public string $systemId;
  456. }
  457. class DOMProcessingInstruction extends DOMNode
  458. {
  459. /** @readonly */
  460. public string $target;
  461. public string $data;
  462. public function __construct(string $name, string $value = "") {}
  463. }
  464. #ifdef LIBXML_XPATH_ENABLED
  465. /** @not-serializable */
  466. class DOMXPath
  467. {
  468. /** @readonly */
  469. public DOMDocument $document;
  470. public bool $registerNodeNamespaces;
  471. public function __construct(DOMDocument $document, bool $registerNodeNS = true) {}
  472. /** @tentative-return-type */
  473. public function evaluate(string $expression, ?DOMNode $contextNode = null, bool $registerNodeNS = true): mixed {}
  474. /** @tentative-return-type */
  475. public function query(string $expression, ?DOMNode $contextNode = null, bool $registerNodeNS = true): mixed {}
  476. /** @tentative-return-type */
  477. public function registerNamespace(string $prefix, string $namespace): bool {}
  478. /** @tentative-return-type */
  479. public function registerPhpFunctions(string|array|null $restrict = null): void {}
  480. }
  481. #endif
  482. function dom_import_simplexml(object $node): DOMElement {}