[php-src] Issue #21077: Accessing Dom\Node::baseURI can throw TypeError
| From: | mbeccati | Date: | Thu, 29 Jan 2026 11:10:07 +0000 |
| Subject: | [php-src] Issue #21077: Accessing Dom\Node::baseURI can throw TypeError | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-251623@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/21077
Author: mbeccati
### Description
The following code:
```php
<?php
$implementation = new \Dom\Implementation();
$node = $implementation->createDocumentType('html', 'publicId',
'systemId');
var_dump($node->baseURI);
```
Resulted in this output:
```
Fatal error: Uncaught TypeError: Cannot assign null to property Dom\Node::$baseURI of type string in
ext/dom/tests/node_baseuri_null.php:6
```
But I expected this output instead:
```
NULL
```
Found running the Symfony test suite, failure in PHP 8.4+. Implementation is capable of generating a
NULL baseURI, which isn't allowed in the stub, even if the property is expected to be nullable.
```
1) Symfony\Component\VarDumper\Tests\Caster\DOMCasterTest::testCastModernDocumentType
TypeError: Cannot assign null to property Dom\Node::$baseURI of type string
/home/runner/work/php-latest-builds/php-latest-builds/src/Symfony/Component/VarDumper/Caster/DOMCaster.php:190
```
### PHP Version
```plain
PHP 8.4.19-dev (cli) (built: Jan 29 2026 11:56:43) (NTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.4.19-dev, Copyright (c) Zend Technologies
```
### Operating System
Irrelevant