Skip to content

Declare dynamic properties in ext/dom #6644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/dom/php_dom.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) /
zend_string_addref(object_str);
}

zend_hash_add(debug_info, string_key, &value);
zend_hash_update(debug_info, string_key, &value);
} ZEND_HASH_FOREACH_END();

zend_string_release_ex(object_str, 0);
Expand Down
260 changes: 260 additions & 0 deletions ext/dom/php_dom.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@

class DOMDocumentType extends DOMNode
{
/** @readonly */
public string $name;

/** @readonly */
public DOMNamedNodeMap $entities;

/** @readonly */
public DOMNamedNodeMap $notations;

/** @readonly */
public string $publicId;

/** @readonly */
public string $systemId;

/** @readonly */
public ?string $internalSubset;
}

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

class DOMNode
{
/** @readonly */
public string $nodeName;

/** @var string|null */
public $nodeValue;

/** @readonly */
public int $nodeType;

/** @readonly */
public ?DOMNode $parentNode;

/** @readonly */
public DOMNodeList $childNodes;

/** @readonly */
public ?DOMNode $firstChild;

/** @readonly */
public ?DOMNode $lastChild;

/** @readonly */
public ?DOMNode $previousSibling;

/** @readonly */
public ?DOMNode $nextSibling;

/** @readonly */
public ?DOMNamedNodeMap $attributes;

/** @readonly */
public ?DOMDocument $ownerDocument;

/** @readonly */
public ?string $namespaceURI;

/** @var string */
public $prefix = "";

/** @readonly */
public ?string $localName;

/** @readonly */
public ?string $baseURI;

/** @var string */
public $textContent = "";

/** @return DOMNode|false */
public function appendChild(DOMNode $node) {}

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

class DOMNameSpaceNode
{
/** @readonly */
public string $nodeName;

/** @readonly */
public ?string $nodeValue;

/** @readonly */
public int $nodeType;

/** @readonly */
public string $prefix;

/** @readonly */
public ?string $localName;

/** @readonly */
public ?string $namespaceURI;

/** @readonly */
public ?DOMDocument $ownerDocument;

/** @readonly */
public ?DOMNode $parentNode;
}

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

class DOMDocumentFragment extends DOMNode implements DOMParentNode
{
/** @readonly */
public ?DOMElement $firstElementChild;

/** @readonly */
public ?DOMElement $lastElementChild;

/** @readonly */
public int $childElementCount;

public function __construct() {}

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

class DOMNodeList implements IteratorAggregate, Countable
{
/** @readonly */
public int $length;

/** @return int|false */
public function count() {}

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

class DOMCharacterData extends DOMNode implements DOMChildNode
{
/** @readonly */
public string $data;

/** @readonly */
public int $length;

/** @readonly */
public ?DOMElement $previousElementSibling;

/** @readonly */
public ?DOMElement $nextElementSibling;

/** @return bool */
public function appendData(string $data) {}

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

class DOMAttr extends DOMNode
{
/** @readonly */
public string $name;

/** @readonly */
public bool $specified = true;

/** @readonly */
public string $value;

/** @readonly */
public ?DOMElement $ownerElement;

/** @readonly */
public mixed $schemaTypeInfo = null;

public function __construct(string $name, string $value = "") {}

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

class DOMElement extends DOMNode implements DOMParentNode, DOMChildNode
{
/** @readonly */
public string $tagName;

/** @readonly */
public mixed $schemaTypeInfo = null;

/** @readonly */
public ?DOMElement $firstElementChild;

/** @readonly */
public ?DOMElement $lastElementChild;

/** @readonly */
public int $childElementCount;

/** @readonly */
public ?DOMElement $previousElementSibling;

/** @readonly */
public ?DOMElement $nextElementSibling;

public function __construct(string $qualifiedName, ?string $value = null, string $namespace = "") {}

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

class DOMDocument extends DOMNode implements DOMParentNode
{
/** @readonly */
public ?DOMDocumentType $doctype;

/** @readonly */
public DOMImplementation $implementation;

/** @readonly */
public ?DOMElement $documentElement;

/**
* @readonly
* @deprecated
*/
public ?string $actualEncoding;

/** @var string|null */
public $encoding;

/** @readonly */
public ?string $xmlEncoding;

/** @var bool */
public $standalone = false;

/** @var bool */
public $xmlStandalone = false;

/** @var string|null */
public $version;

/** @var string|null */
public $xmlVersion;

/** @var bool */
public $strictErrorChecking = false;

/** @var string|null */
public $documentURI;

/**
* @readonly
* @deprecated
*/
public mixed $config = null;

/** @var bool */
public $formatOutput = false;

/** @var bool */
public $validateOnParse = false;

/** @var bool */
public $resolveExternals = false;

/** @var bool */
public $preserveWhiteSpace = false;

/** @var bool */
public $recover = false;

/** @var bool */
public $substituteEntities = false;

/** @readonly */
public ?DOMElement $firstElementChild;

/** @readonly */
public ?DOMElement $lastElementChild;

/** @readonly */
public int $childElementCount;

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

/** @return DOMAttr|false */
Expand Down Expand Up @@ -366,6 +586,9 @@ final class DOMException extends Exception

class DOMText extends DOMCharacterData
{
/** @readonly */
public string $wholeText;

public function __construct(string $data = "") {}

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

class DOMNamedNodeMap implements IteratorAggregate, Countable
{
/** @readonly */
public int $length;

/** @return DOMNode|null */
public function getNamedItem(string $qualifiedName) {}

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

class DOMEntity extends DOMNode
{
/** @readonly */
public ?string $publicId;

/** @readonly */
public ?string $systemId;

/** @readonly */
public ?string $notationName;

/** @readonly */
public mixed $actualEncoding = null;

/** @readonly */
public mixed $encoding = null;

/** @readonly */
public mixed $version = null;
}

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

class DOMNotation extends DOMNode
{
/** @readonly */
public string $publicId;

/** @readonly */
public string $systemId;
}

class DOMProcessingInstruction extends DOMNode
{
/** @readonly */
public string $target;

/** @var string */
public $data = "";

public function __construct(string $name, string $value = "") {}
}

#ifdef LIBXML_XPATH_ENABLED
class DOMXPath
{
/** @readonly */
public DOMDocument $document;

/** @var bool */
public $registerNodeNamespaces = false;

public function __construct(DOMDocument $document, bool $registerNodeNS = true) {}

/** @return mixed */
Expand Down
Loading