Skip to content

Commit a5e938d

Browse files
committed
Declare dynamic properties in ext/dom
Closes GH-6644
1 parent 8d715b8 commit a5e938d

8 files changed

+862
-53
lines changed

ext/dom/php_dom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) /
421421
zend_string_addref(object_str);
422422
}
423423

424-
zend_hash_add(debug_info, string_key, &value);
424+
zend_hash_update(debug_info, string_key, &value);
425425
} ZEND_HASH_FOREACH_END();
426426

427427
zend_string_release_ex(object_str, 0);

ext/dom/php_dom.stub.php

Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@
44

55
class DOMDocumentType extends DOMNode
66
{
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;
724
}
825

926
class DOMCdataSection extends DOMText
@@ -41,6 +58,54 @@ public function replaceWith(...$nodes): void;
4158

4259
class DOMNode
4360
{
61+
/** @readonly */
62+
public string $nodeName;
63+
64+
/** @var string|null */
65+
public $nodeValue;
66+
67+
/** @readonly */
68+
public int $nodeType;
69+
70+
/** @readonly */
71+
public ?DOMNode $parentNode;
72+
73+
/** @readonly */
74+
public DOMNodeList $childNodes;
75+
76+
/** @readonly */
77+
public ?DOMNode $firstChild;
78+
79+
/** @readonly */
80+
public ?DOMNode $lastChild;
81+
82+
/** @readonly */
83+
public ?DOMNode $previousSibling;
84+
85+
/** @readonly */
86+
public ?DOMNode $nextSibling;
87+
88+
/** @readonly */
89+
public ?DOMNamedNodeMap $attributes;
90+
91+
/** @readonly */
92+
public ?DOMDocument $ownerDocument;
93+
94+
/** @readonly */
95+
public ?string $namespaceURI;
96+
97+
/** @var string */
98+
public $prefix = "";
99+
100+
/** @readonly */
101+
public ?string $localName;
102+
103+
/** @readonly */
104+
public ?string $baseURI;
105+
106+
/** @var string */
107+
public $textContent = "";
108+
44109
/** @return DOMNode|false */
45110
public function appendChild(DOMNode $node) {}
46111

@@ -95,6 +160,29 @@ public function replaceChild(DOMNode $node, DOMNode $child) {}
95160

96161
class DOMNameSpaceNode
97162
{
163+
/** @readonly */
164+
public string $nodeName;
165+
166+
/** @readonly */
167+
public ?string $nodeValue;
168+
169+
/** @readonly */
170+
public int $nodeType;
171+
172+
/** @readonly */
173+
public string $prefix;
174+
175+
/** @readonly */
176+
public ?string $localName;
177+
178+
/** @readonly */
179+
public ?string $namespaceURI;
180+
181+
/** @readonly */
182+
public ?DOMDocument $ownerDocument;
183+
184+
/** @readonly */
185+
public ?DOMNode $parentNode;
98186
}
99187

100188
class DOMImplementation
@@ -114,6 +202,15 @@ public function createDocument(?string $namespace = null, string $qualifiedName
114202

115203
class DOMDocumentFragment extends DOMNode implements DOMParentNode
116204
{
205+
/** @readonly */
206+
public ?DOMElement $firstElementChild;
207+
208+
/** @readonly */
209+
public ?DOMElement $lastElementChild;
210+
211+
/** @readonly */
212+
public int $childElementCount;
213+
117214
public function __construct() {}
118215

119216
/** @return bool */
@@ -128,6 +225,9 @@ public function prepend(...$nodes): void {}
128225

129226
class DOMNodeList implements IteratorAggregate, Countable
130227
{
228+
/** @readonly */
229+
public int $length;
230+
131231
/** @return int|false */
132232
public function count() {}
133233

@@ -139,6 +239,18 @@ public function item(int $index) {}
139239

140240
class DOMCharacterData extends DOMNode implements DOMChildNode
141241
{
242+
/** @readonly */
243+
public string $data;
244+
245+
/** @readonly */
246+
public int $length;
247+
248+
/** @readonly */
249+
public ?DOMElement $previousElementSibling;
250+
251+
/** @readonly */
252+
public ?DOMElement $nextElementSibling;
253+
142254
/** @return bool */
143255
public function appendData(string $data) {}
144256

@@ -168,6 +280,21 @@ public function after(...$nodes): void {}
168280

169281
class DOMAttr extends DOMNode
170282
{
283+
/** @readonly */
284+
public string $name;
285+
286+
/** @readonly */
287+
public bool $specified = true;
288+
289+
/** @readonly */
290+
public string $value;
291+
292+
/** @readonly */
293+
public ?DOMElement $ownerElement;
294+
295+
/** @readonly */
296+
public mixed $schemaTypeInfo = null;
297+
171298
public function __construct(string $name, string $value = "") {}
172299

173300
/** @return bool */
@@ -176,6 +303,27 @@ public function isId() {}
176303

177304
class DOMElement extends DOMNode implements DOMParentNode, DOMChildNode
178305
{
306+
/** @readonly */
307+
public string $tagName;
308+
309+
/** @readonly */
310+
public mixed $schemaTypeInfo = null;
311+
312+
/** @readonly */
313+
public ?DOMElement $firstElementChild;
314+
315+
/** @readonly */
316+
public ?DOMElement $lastElementChild;
317+
318+
/** @readonly */
319+
public int $childElementCount;
320+
321+
/** @readonly */
322+
public ?DOMElement $previousElementSibling;
323+
324+
/** @readonly */
325+
public ?DOMElement $nextElementSibling;
326+
179327
public function __construct(string $qualifiedName, ?string $value = null, string $namespace = "") {}
180328

181329
/** @return string */
@@ -252,6 +400,78 @@ public function prepend(...$nodes): void {}
252400

253401
class DOMDocument extends DOMNode implements DOMParentNode
254402
{
403+
/** @readonly */
404+
public ?DOMDocumentType $doctype;
405+
406+
/** @readonly */
407+
public DOMImplementation $implementation;
408+
409+
/** @readonly */
410+
public ?DOMElement $documentElement;
411+
412+
/**
413+
* @readonly
414+
* @deprecated
415+
*/
416+
public ?string $actualEncoding;
417+
418+
/** @var string|null */
419+
public $encoding;
420+
421+
/** @readonly */
422+
public ?string $xmlEncoding;
423+
424+
/** @var bool */
425+
public $standalone = false;
426+
427+
/** @var bool */
428+
public $xmlStandalone = false;
429+
430+
/** @var string|null */
431+
public $version;
432+
433+
/** @var string|null */
434+
public $xmlVersion;
435+
436+
/** @var bool */
437+
public $strictErrorChecking = false;
438+
439+
/** @var string|null */
440+
public $documentURI;
441+
442+
/**
443+
* @readonly
444+
* @deprecated
445+
*/
446+
public mixed $config = null;
447+
448+
/** @var bool */
449+
public $formatOutput = false;
450+
451+
/** @var bool */
452+
public $validateOnParse = false;
453+
454+
/** @var bool */
455+
public $resolveExternals = false;
456+
457+
/** @var bool */
458+
public $preserveWhiteSpace = false;
459+
460+
/** @var bool */
461+
public $recover = false;
462+
463+
/** @var bool */
464+
public $substituteEntities = false;
465+
466+
/** @readonly */
467+
public ?DOMElement $firstElementChild;
468+
469+
/** @readonly */
470+
public ?DOMElement $lastElementChild;
471+
472+
/** @readonly */
473+
public int $childElementCount;
474+
255475
public function __construct(string $version = "1.0", string $encoding = "") {}
256476

257477
/** @return DOMAttr|false */
@@ -366,6 +586,9 @@ final class DOMException extends Exception
366586

367587
class DOMText extends DOMCharacterData
368588
{
589+
/** @readonly */
590+
public string $wholeText;
591+
369592
public function __construct(string $data = "") {}
370593

371594
/** @return bool */
@@ -383,6 +606,9 @@ public function splitText(int $offset) {}
383606

384607
class DOMNamedNodeMap implements IteratorAggregate, Countable
385608
{
609+
/** @readonly */
610+
public int $length;
611+
386612
/** @return DOMNode|null */
387613
public function getNamedItem(string $qualifiedName) {}
388614

@@ -400,6 +626,23 @@ public function getIterator(): Iterator {}
400626

401627
class DOMEntity extends DOMNode
402628
{
629+
/** @readonly */
630+
public ?string $publicId;
631+
632+
/** @readonly */
633+
public ?string $systemId;
634+
635+
/** @readonly */
636+
public ?string $notationName;
637+
638+
/** @readonly */
639+
public mixed $actualEncoding = null;
640+
641+
/** @readonly */
642+
public mixed $encoding = null;
643+
644+
/** @readonly */
645+
public mixed $version = null;
403646
}
404647

405648
class DOMEntityReference extends DOMNode
@@ -409,16 +652,33 @@ public function __construct(string $name) {}
409652

410653
class DOMNotation extends DOMNode
411654
{
655+
/** @readonly */
656+
public string $publicId;
657+
658+
/** @readonly */
659+
public string $systemId;
412660
}
413661

414662
class DOMProcessingInstruction extends DOMNode
415663
{
664+
/** @readonly */
665+
public string $target;
666+
667+
/** @var string */
668+
public $data = "";
669+
416670
public function __construct(string $name, string $value = "") {}
417671
}
418672

419673
#ifdef LIBXML_XPATH_ENABLED
420674
class DOMXPath
421675
{
676+
/** @readonly */
677+
public DOMDocument $document;
678+
679+
/** @var bool */
680+
public $registerNodeNamespaces = false;
681+
422682
public function __construct(DOMDocument $document, bool $registerNodeNS = true) {}
423683

424684
/** @return mixed */

0 commit comments

Comments
 (0)