[php-src] Issue #19187: PHP 8.4: `PropertyReflector::getSettableType` includes "?" in nullable identifier names.
| From: | BusterNeece | Date: | Sun, 20 Jul 2025 12:53:26 +0000 |
| Subject: | [php-src] Issue #19187: PHP 8.4: `PropertyReflector::getSettableType` includes "?" in nullable identifier names. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-250458@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/19187
Author: BusterNeece
### Description
It appears that the type name returned by
ReflectionProperty::getSettableType() will
include the nullable question mark in the case of nullable values (i.e. ?string for
string|null). This is inconsistent with existing behavior and the return type of
ReflectionProperty::getType() given the same type hint.
The following code:
```php
<?php
class Foo {
public string|null $bar {
set (string|null $value) => $value ?? 'default';
}
}
$reflProp = new ReflectionProperty(Foo::class, 'bar');
echo $reflProp->getType()->getName();
echo $reflProp->getSettableType()->getName();
```
Resulted in this output:
```
string
?string
```
But I expected this output instead:
```
string
string
```
### PHP Version
```plain
PHP 8.4.10 (cli) (built: Jul 3 2025 22:57:54) (NTS)
Copyright (c) The PHP Group
Built by https://github.com/docker-library/php
Zend Engine v4.4.10, Copyright (c) Zend Technologies
with Zend OPcache v8.4.10, Copyright (c), by Zend Technologies
with Xdebug v3.4.4, Copyright (c) 2002-2025, by Derick Rethans
```
### Operating System
Debian Bookworm