Closed jonathangreco closed 9 hours ago
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.
Sorry, where exactly does the documentation state that you should not declare the properties that you assign to?
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!