[php-src] Issue #21097: Accessing Dom\Node properties can can throw TypeError(s)
[email protected] (mbeccati)
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <[email protected]> |
Issue: https://github.com/php/php-src/issues/21097
Author: mbeccati
### Description
The following code:
```php
<?php
$implementation = new \Dom\Implementation();
$node = $implementation->createDocumentType('html', 'publicId', 'systemId');
$r = new \ReflectionClass($node);
foreach ($r->getProperties(\ReflectionProperty::IS_PUBLIC) as $p) {
$node->{$p->getName()};
}
```
Resulted in this output:
```
Fatal error: Uncaught TypeError: Cannot assign DOMNodeList to property Dom\Node::$childNodes of type Dom\NodeList
```
But I expected no output instead.
A follow up after #21077 has been fixed, again coming from the same test in the Symfony test suite.
This time however, I've used Reflection in the example to make sure there are no other properties misbehaving after `childNodes` has been fixed. I didn't assign the issue to @ndossche as I might give it a shot at fixing myself during the weekend.
### PHP Version
```plain
PHP 8.4.19-dev (cli) (built: Jan 30 2026 19:25:50) (NTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.4.19-dev, Copyright (c) Zend Technologies
```
### Operating System
Irrelevant