note 130107 added to reflectionproperty.hasdefaultvalue
| From: | vuryss@gmail.com | Date: | Sun, 02 Mar 2025 12:21:18 +0000 |
| Subject: | note 130107 added to reflectionproperty.hasdefaultvalue | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221935@lists.php.net to get a copy of this message | ||
It is useful to note that if this is used on a promoted property, which has a default value, it does
not work as expected. The default value is related to the constructor parameter, not to the property
itself. So for example, if you reflect this property:
<?php
class SomeClass
{
public function __construct(
public ?string $property = null,
) {
}
}
?>
The ReflectionProperty::hasDefaultValue will return false.
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 78.130.250.41)
----
Manual Page -- https://php.net/manual/en/reflectionproperty.hasdefaultvalue.php
Edit -- https://main.php.net/note/edit/130107
Del: integrated -- https://main.php.net/note/delete/130107/integrated
Del: useless -- https://main.php.net/note/delete/130107/useless
Del: bad code -- https://main.php.net/note/delete/130107/bad+code
Del: spam -- https://main.php.net/note/delete/130107/spam
Del: non-english -- https://main.php.net/note/delete/130107/non-english
Del: in docs -- https://main.php.net/note/delete/130107/in+docs
Del: other reasons-- https://main.php.net/note/delete/130107
Reject -- https://main.php.net/note/reject/130107
Search -- https://main.php.net/manage/user-notes.php