[php-src] Issue #13250: Default value from a constructor promoted property isn't present in ReflectionProperty but is in ReflectionParameter

From: Date: Fri, 26 Jan 2024 11:10:01 +0000
Subject: [php-src] Issue #13250: Default value from a constructor promoted property isn't present in ReflectionProperty but is in ReflectionParameter
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246345@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/13250 Author: Korbeil ### Description When using Reflection onto constructor promoted properties, we don't have the default value of the property/parameter onto the ReflectionProperty object. The following code: ```php <?php class Foo { public function __construct( private string $bar = 'content', ) { } } $class = new \ReflectionClass(Foo::class); $properties = $class->getProperties(); var_dump($properties[0]->getDefaultValue()); // not working $constructMethod = $class->getMethod('__construct'); $parameters = $constructMethod->getParameters(); var_dump($parameters[0]->getDefaultValue()); ``` Resulted in this output: ``` NULL string(7) "content" ``` But I expected this output instead: ``` string(7) "content" string(7) "content" ``` 3v4l.org link: https://3v4l.org/o1C23 ### PHP Version any ### Operating System Ubuntu

« previous php.bugs (#246345) next »