[php-src] Issue #20895: ReflectionProperty does not return the PHPDoc of a property if it contains an attribute with a Closure
| From: | zavarock | Date: | Sat, 10 Jan 2026 13:48:07 +0000 |
| Subject: | [php-src] Issue #20895: ReflectionProperty does not return the PHPDoc of a property if it contains an attribute with a Closure | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-251523@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/20895
Author: zavarock
### Description
The following code:
```php
<?php
#[\Attribute(\Attribute::TARGET_PROPERTY)]
class Hello {
public function __construct(
public Closure $world,
) {
}
}
class Foo {
/**
* @var string
*/
#[Hello(static function() {
return null;
})]
public $bar;
}
$reflectionProperty = new ReflectionProperty(Foo::class, 'bar');
var_dump($reflectionProperty->getDocComment());
```
Resulted in this output:
```
bool(false)
```
But I expected this output instead:
```
string(30) "/** * @var string */"
```
### PHP Version
```plain
PHP 8.5.0
```
### Operating System
_No response_