[php-src] Issue #21077: Accessing Dom\Node::baseURI can throw TypeError

[email protected] (mbeccati)
Newsgroups php.bugs
Message-ID <u2Op9pQJBWsNoP1aa8ItBws0OsdByG64JDvSRHcmPhs@main.internal.php.net>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.