mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DynamicProperties and collection for PHP > 8.2 #7448
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jonathangreco on GitHub (Dec 4, 2024).
Hi everyone,
I noticed in the official documentation (both for the current version and the upcoming version 4) that collections are still being instantiated dynamically within constructors.
With PHP 8.2 and above, this behavior triggers deprecation warnings, and it will result in fatal errors starting with PHP 9.0.
It seems there are no official guidelines or workarounds addressing this issue yet. Is this behavior intentional?
Suggestions for Improvement
Update the Documentation:
Provide clear guidance on how to address this deprecation issue.
Temporary Solution:
Add the
#[AllowDynamicProperties]attribute to the top of each entity where dynamic instantiation of collections occurs, as a quick fix.Long-term Solution:
Update constructors on those documentation to reflect the new PHP 8 best practices
Looking forward to hearing thoughts or suggested best practices from the community!
@derrabus commented on GitHub (Dec 4, 2024):
Sorry, where exactly does the documentation state that you should not declare the properties that you assign to?