Skip to content

Commit f432aa1

Browse files
committed
Only add tentative return types where the DOM spec is compatible
1 parent 1ddde7c commit f432aa1

File tree

2 files changed

+89
-95
lines changed

2 files changed

+89
-95
lines changed

ext/dom/php_dom.stub.php

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,17 @@ class DOMNode
103103

104104
public string $textContent;
105105

106-
/** @tentative-return-type */
107-
public function appendChild(DOMNode $node): DOMNode|false {}
106+
/** @return DOMNode|false */
107+
public function appendChild(DOMNode $node) {}
108108

109109
/** @tentative-return-type */
110110
public function C14N(bool $exclusive = false, bool $withComments = false, ?array $xpath = null, ?array $nsPrefixes = null): string|false {}
111111

112112
/** @tentative-return-type */
113113
public function C14NFile(string $uri, bool $exclusive = false, bool $withComments = false, ?array $xpath = null, ?array $nsPrefixes = null): int|false {}
114114

115-
/** @tentative-return-type */
116-
public function cloneNode(bool $deep = false): DOMNode|false {}
115+
/** @return DOMNode|false */
116+
public function cloneNode(bool $deep = false) {}
117117

118118
/** @tentative-return-type */
119119
public function getLineNo(): int {}
@@ -127,8 +127,8 @@ public function hasAttributes(): bool {}
127127
/** @tentative-return-type */
128128
public function hasChildNodes(): bool {}
129129

130-
/** @tentative-return-type */
131-
public function insertBefore(DOMNode $node, ?DOMNode $child = null): DOMNode|false {}
130+
/** @return DOMNode|false */
131+
public function insertBefore(DOMNode $node, ?DOMNode $child = null) {}
132132

133133
/** @tentative-return-type */
134134
public function isDefaultNamespace(string $namespace): bool {}
@@ -148,11 +148,11 @@ public function lookupPrefix(string $namespace): ?string {}
148148
/** @tentative-return-type */
149149
public function normalize(): void {}
150150

151-
/** @tentative-return-type */
152-
public function removeChild(DOMNode $child): DOMNode|false {}
151+
/** @return DOMNode|false */
152+
public function removeChild(DOMNode $child) {}
153153

154-
/** @tentative-return-type */
155-
public function replaceChild(DOMNode $node, DOMNode $child): DOMNode|false {}
154+
/** @return DOMNode|false */
155+
public function replaceChild(DOMNode $node, DOMNode $child) {}
156156
}
157157

158158
class DOMNameSpaceNode
@@ -190,11 +190,11 @@ public function getFeature(string $feature, string $version): never {}
190190
/** @tentative-return-type */
191191
public function hasFeature(string $feature, string $version): bool {}
192192

193-
/** @tentative-return-type */
194-
public function createDocumentType(string $qualifiedName, string $publicId = "", string $systemId = ""): DOMDocumentType|false {}
193+
/** @return DOMDocumentType|false */
194+
public function createDocumentType(string $qualifiedName, string $publicId = "", string $systemId = "") {}
195195

196-
/** @tentative-return-type */
197-
public function createDocument(?string $namespace = null, string $qualifiedName = "", ?DOMDocumentType $doctype = null): DOMDocument|false {}
196+
/** @return DOMDocument|false */
197+
public function createDocument(?string $namespace = null, string $qualifiedName = "", ?DOMDocumentType $doctype = null) {}
198198
}
199199

200200
class DOMDocumentFragment extends DOMNode implements DOMParentNode
@@ -251,8 +251,8 @@ class DOMCharacterData extends DOMNode implements DOMChildNode
251251
/** @tentative-return-type */
252252
public function appendData(string $data): bool {}
253253

254-
/** @tentative-return-type */
255-
public function substringData(int $offset, int $count): string|false {}
254+
/** @return string|false */
255+
public function substringData(int $offset, int $count) {}
256256

257257
/** @tentative-return-type */
258258
public function insertData(int $offset, string $data): bool {}
@@ -329,11 +329,11 @@ public function getAttribute(string $qualifiedName): string {}
329329
/** @tentative-return-type */
330330
public function getAttributeNS(?string $namespace, string $localName): string {}
331331

332-
/** @tentative-return-type */
333-
public function getAttributeNode(string $qualifiedName): DOMAttr|DOMNameSpaceNode|false {}
332+
/** @return DOMAttr|DOMNameSpaceNode|false */
333+
public function getAttributeNode(string $qualifiedName) {}
334334

335-
/** @tentative-return-type */
336-
public function getAttributeNodeNS(?string $namespace, string $localName): DOMAttr|DOMNameSpaceNode|null {}
335+
/** @return DOMAttr|DOMNameSpaceNode|null */
336+
public function getAttributeNodeNS(?string $namespace, string $localName) {}
337337

338338
/** @tentative-return-type */
339339
public function getElementsByTagName(string $qualifiedName): DOMNodeList {}
@@ -353,20 +353,20 @@ public function removeAttribute(string $qualifiedName): bool {}
353353
/** @tentative-return-type */
354354
public function removeAttributeNS(?string $namespace, string $localName): void {}
355355

356-
/** @tentative-return-type */
357-
public function removeAttributeNode(DOMAttr $attr): DOMAttr|false {}
356+
/** @return DOMAttr|false */
357+
public function removeAttributeNode(DOMAttr $attr) {}
358358

359-
/** @tentative-return-type */
360-
public function setAttribute(string $qualifiedName, string $value): DOMAttr|bool {}
359+
/** @return DOMAttr|bool */
360+
public function setAttribute(string $qualifiedName, string $value) {} // TODO return type shouldn't depend on the call scope
361361

362362
/** @tentative-return-type */
363363
public function setAttributeNS(?string $namespace, string $qualifiedName, string $value): void {}
364364

365-
/** @tentative-return-type */
366-
public function setAttributeNode(DOMAttr $attr): DOMAttr|null|false {}
365+
/** @return DOMAttr|null|false */
366+
public function setAttributeNode(DOMAttr $attr) {}
367367

368-
/** @tentative-return-type */
369-
public function setAttributeNodeNS(DOMAttr $attr): DOMAttr|null|false {}
368+
/** @return DOMAttr|null|false */
369+
public function setAttributeNodeNS(DOMAttr $attr) {}
370370

371371
/** @tentative-return-type */
372372
public function setIdAttribute(string $qualifiedName, bool $isId): void {}
@@ -458,53 +458,53 @@ class DOMDocument extends DOMNode implements DOMParentNode
458458

459459
public function __construct(string $version = "1.0", string $encoding = "") {}
460460

461-
/** @tentative-return-type */
462-
public function createAttribute(string $localName): DOMAttr|false {}
461+
/** @return DOMAttr|false */
462+
public function createAttribute(string $localName) {}
463463

464-
/** @tentative-return-type */
465-
public function createAttributeNS(?string $namespace, string $qualifiedName): DOMAttr|false {}
464+
/** @return DOMAttr|false */
465+
public function createAttributeNS(?string $namespace, string $qualifiedName) {}
466466

467-
/** @tentative-return-type */
468-
public function createCDATASection(string $data): DOMCdataSection|false {}
467+
/** @return DOMCdataSection|false */
468+
public function createCDATASection(string $data) {}
469469

470470
/** @tentative-return-type */
471471
public function createComment(string $data): DOMComment {}
472472

473473
/** @tentative-return-type */
474474
public function createDocumentFragment(): DOMDocumentFragment {}
475475

476-
/** @tentative-return-type */
477-
public function createElement(string $localName, string $value = ""): DOMElement|false {}
476+
/** @return DOMElement|false */
477+
public function createElement(string $localName, string $value = "") {}
478478

479-
/** @tentative-return-type */
480-
public function createElementNS(?string $namespace, string $qualifiedName, string $value = ""): DOMElement|false {}
479+
/** @return DOMElement|false */
480+
public function createElementNS(?string $namespace, string $qualifiedName, string $value = "") {}
481481

482-
/** @tentative-return-type */
483-
public function createEntityReference(string $name): DOMEntityReference|false {}
482+
/** @return DOMEntityReference|false */
483+
public function createEntityReference(string $name) {}
484484

485-
/** @tentative-return-type */
486-
public function createProcessingInstruction(string $target, string $data = ""): DOMProcessingInstruction|false {}
485+
/** @return DOMProcessingInstruction|false */
486+
public function createProcessingInstruction(string $target, string $data = "") {}
487487

488488
/** @tentative-return-type */
489489
public function createTextNode(string $data): DOMText {}
490490

491491
/** @tentative-return-type */
492-
public function getElementById(string $elementId): DOMElement|null {}
492+
public function getElementById(string $elementId): ?DOMElement {}
493493

494494
/** @tentative-return-type */
495495
public function getElementsByTagName(string $qualifiedName): DOMNodeList {}
496496

497497
/** @tentative-return-type */
498498
public function getElementsByTagNameNS(?string $namespace, string $localName): DOMNodeList {}
499499

500-
/** @tentative-return-type */
501-
public function importNode(DOMNode $node, bool $deep = false): DOMNode|false {}
500+
/** @return DOMNode|false */
501+
public function importNode(DOMNode $node, bool $deep = false) {}
502502

503-
/** @tentative-return-type */
504-
public function load(string $filename, int $options = 0): DOMDocument|bool {}
503+
/** @return DOMDocument|bool */
504+
public function load(string $filename, int $options = 0) {} // TODO return type shouldn't depend on the call scope
505505

506-
/** @tentative-return-type */
507-
public function loadXML(string $source, int $options = 0): DOMDocument|bool {}
506+
/** @return DOMDocument|bool */
507+
public function loadXML(string $source, int $options = 0) {} // TODO return type shouldn't depend on the call scope
508508

509509
/** @tentative-return-type */
510510
public function normalizeDocument(): void {}
@@ -516,11 +516,11 @@ public function registerNodeClass(string $baseClass, ?string $extendedClass): bo
516516
public function save(string $filename, int $options = 0): int|false {}
517517

518518
#ifdef LIBXML_HTML_ENABLED
519-
/** @tentative-return-type */
520-
public function loadHTML(string $source, int $options = 0): DOMDocument|bool {}
519+
/** @return DOMDocument|bool */
520+
public function loadHTML(string $source, int $options = 0) {} // TODO return type shouldn't depend on the call scope
521521

522-
/** @tentative-return-type */
523-
public function loadHTMLFile(string $filename, int $options = 0): DOMDocument|bool {}
522+
/** @return DOMDocument|bool */
523+
public function loadHTMLFile(string $filename, int $options = 0) {} // TODO return type shouldn't depend on the call scope
524524

525525
/** @tentative-return-type */
526526
public function saveHTML(?DOMNode $node = null): string|false {}
@@ -552,8 +552,8 @@ public function validate(): bool {}
552552
/** @tentative-return-type */
553553
public function xinclude(int $options = 0): int|false {}
554554

555-
/** @tentative-return-type */
556-
public function adoptNode(DOMNode $node): DOMNode|false {}
555+
/** @return DOMNode|false */
556+
public function adoptNode(DOMNode $node) {}
557557

558558
/** @param DOMNode|string $nodes */
559559
public function append(...$nodes): void {}
@@ -584,8 +584,8 @@ public function isWhitespaceInElementContent(): bool {}
584584
*/
585585
public function isElementContentWhitespace(): bool {}
586586

587-
/** @tentative-return-type */
588-
public function splitText(int $offset): DOMText|false {}
587+
/** @return DOMText|false */
588+
public function splitText(int $offset) {}
589589
}
590590

591591
class DOMNamedNodeMap implements IteratorAggregate, Countable
@@ -594,13 +594,13 @@ class DOMNamedNodeMap implements IteratorAggregate, Countable
594594
public int $length;
595595

596596
/** @tentative-return-type */
597-
public function getNamedItem(string $qualifiedName): ?DOMNode {}
597+
public function getNamedItem(string $qualifiedName): ?DOMNode {} // TODO DOM spec returns DOMAttr
598598

599599
/** @tentative-return-type */
600-
public function getNamedItemNS(?string $namespace, string $localName): ?DOMNode {}
600+
public function getNamedItemNS(?string $namespace, string $localName): ?DOMNode {} // TODO DOM spec returns DOMAttr
601601

602602
/** @tentative-return-type */
603-
public function item(int $index): ?DOMNode {}
603+
public function item(int $index): ?DOMNode {} // TODO DOM spec returns DOMAttr
604604

605605
/** @tentative-return-type */
606606
public function count(): int {}

0 commit comments

Comments
 (0)