ReflectionProperty::getDefaultValue() and promoted properties
Nobody has claimed this yet.
- Dominant language
- XML
- Stars
- 596
- Forks
- 890
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 55
Description
Copied from https://bugs.php.net/bug.php?id=81386
Currently when you declare a promoted property with a default value the ReflectionProperty::getDefaultValue() won't return that value.
I'm not sure if this behavior is expected or not but in either case something needs to be changed.
If this behavior is unexpected then it should be fixed to return the correct value.
If this behavior is expected then the documentation of ReflectionProperty::getDefaultValue() should mention this drawback along with a few lines of code how to get to the relevant ReflectionParameter and get the value there.
<?php
class X {
public function __construct(
public bool $y = false
) {
}
}
var_export((new ReflectionProperty('X', 'y'))->getDefaultValue());
Expected result: either the value should be returned or this behavior needs to be documented.
Actual result: the default value is not returned and there is no mention of this behavior in the documentation
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the documentation for ReflectionProperty::getDefaultValue() and the related ReflectionParameter default-value behavior shown in the issue. Determine whether promoted-property defaults are expected to be returned; done means the documented behavior and access path are accurate, or the issue is clarified for an implementation change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100