-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[PHP8.4]private(set) properties should be skipped to avoid resetting values #11872
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
[PHP8.4]private(set) properties should be skipped to avoid resetting values #11872
Conversation
|
||
#[ORM\Entity] | ||
#[ORM\Table(name: 'DDC11871_Order')] | ||
class DDC11871Order |
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.
Please inline the classes into the Test or create a new modelset.
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.
Inlining classes makes tests with PHP < 8.4 failling. What do you mean by "create a new modelset"?
if (version_compare(PHP_VERSION, '8.4', '<')) { | ||
continue; | ||
} elseif ($property->isPrivateSet() === false) { | ||
continue; | ||
} |
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.
This logic looks wrong, it only skips private set fields in PHP 8.4+ - but not others anymore.
Should maybe be:
if ($property->isStatic() || (($class->hasField($name) || $class->hasAssociation($name)) && ! isset($identifiers[$name])) || (PHP_VERSION_ID >= 80400 && $property->isPrivateSet())) {
continue;
}
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.
I'll try to write a test making sure which properties are skipped. I'll get back to you shortly.
I think similar to property hooks, use of We need to write a positive test, probably only working in conjunction with #11853 . before allowing use. |
Do you have any estimate to have property hook ready to deploy ? |
Ignore phpcs validation as it doesn't support property(set) yet.
This skip will break lazy loading, accessing a private set property would not trigger ir |
Can you try if this issue exists when using the dev version of var-exporter? |
@nicolas-grekas Works fine with 7.2x-dev and 7.3.x-dev 😃 |
Attempt to fix issue #11871
Summary : When an entity is associated with a class declaring private(set) properties. The proxyFactory does not ignore those properties as it does with privates one. This leads to an error such as "Error: Cannot unset private(set) property ".