-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PropertyAccess] Readonly properties must have no PropertyWriteInfo #48108
[PropertyAccess] Readonly properties must have no PropertyWriteInfo #48108
Conversation
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
Hey! I think @Tomanhez has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
@dunglas or @nicolas-grekas is it possible to review this PR? |
@dunglas @nicolas-grekas any chance to see this merged? 🙏 |
@@ -397,8 +397,11 @@ public function getWriteInfo(string $class, string $property, array $context = [ | |||
|
|||
if ($reflClass->hasProperty($property) && ($reflClass->getProperty($property)->getModifiers() & $this->propertyReflectionFlags)) { | |||
$reflProperty = $reflClass->getProperty($property); | |||
if (\PHP_VERSION_ID < 80100 || (false === $reflProperty->isReadOnly() && false === $reflProperty->isPromoted())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remove the part about $reflProperty->isPromoted()
(which I just did and pushed), tests still pass. This makes me wonder what how this relates to property promotion? Isn't this only about readonly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's my mistake. I've missed the part that readonly properties in the constructor are automatically promoted. The change above indeed is correct.
d0d1096
to
813b950
Compare
src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php
Outdated
Show resolved
Hide resolved
813b950
to
2aa6c7d
Compare
Thank you @CasvanDongen. |
The reported WriteInfo of readonly promoted properties is incorrectly returned as a writeable property when constructor extraction is disabled. This PR fixes that by correctly returning
PropertyWriteInfo::TYPE_NONE
whenenable_constructor_extraction
isfalse
.Obviously, this fix only applies to PHP8.1 or higher.