Skip to content

Commit

Permalink
Merge pull request #106 from devteam-emroc/php-83
Browse files Browse the repository at this point in the history
Adding 'id' to DOMNodes with type string.
  • Loading branch information
voku authored May 25, 2024
2 parents e2ced08 + 445c8a3 commit b473c38
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/voku/helper/AbstractSimpleHtmlDom.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ abstract class AbstractSimpleHtmlDom
'innerhtmlkeep' => 'innerHtmlKeep',
];

/**
* @var string[]
*/
protected static $stringDomNodes = [
'id',
'prefix',
'content'
];

/**
* @var \DOMElement|\DOMNode|null
*/
Expand Down Expand Up @@ -167,7 +176,7 @@ public function __set($name, $value)
default:
if ($this->node && \property_exists($this->node, $nameOrig)) {
// INFO: Cannot assign null to property DOMNode::* of type string
if ($nameOrig === 'prefix' || $nameOrig === 'textContent') {
if (in_array($nameOrig, self::$stringDomNodes)) {
$value = (string)$value;
}

Expand Down

0 comments on commit b473c38

Please sign in to comment.