[php-src] PR #25493: Fix ReflectionClassConstant::getValue() when $name is a reference
| From: | nicolas-grekas | Date: | Mon, 16 Nov 2026 17:10:01 +0000 |
| Subject: | [php-src] PR #25493: Fix ReflectionClassConstant::getValue() when $name is a reference | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-40696@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25493
Author: nicolas-grekas
ReflectionClassConstant::getValue() reads the $name property without
dereferencing it, unlike getName() and __toString(). After a reference was
taken on the property, the error of a typed constant prints bytes of the reference instead of the
name:
```php
define('RUNTIME_VALUE', 'abc');
class Test {
public const int C = RUNTIME_VALUE;
}
$rc = new ReflectionClassConstant(Test::class, 'C');
$name = &$rc->name;
$rc->getValue(); // TypeError: Cannot assign string to class constant Test::<garbage> of
type int
```