yiisoft / yii

Yii PHP Framework 1.1.x
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
4.84k stars 2.28k forks source link

#[\AllowDynamicProperties] in ActiveRecord Models #4531

Closed eduardor2k closed 1 year ago

eduardor2k commented 1 year ago

Set this class to Allow Dynamic Properties, this will allow all child classes to allow dynamic properties

https://www.php.net/manual/en/migration82.deprecated.php

This will prevent getting a warning trying to set a dynamic property in CActiveRecord objects

This can be fixed in userland code, but since this is the expected behaviour, I would expect not getting a warning when using dynamic properties.

Q A
Is bugfix? ✔️
New feature?
Breaks BC?
Tests pass? ✔️
what-the-diff[bot] commented 1 year ago

PR Summary

rob006 commented 1 year ago

How do you get this warning? AR should already disallow dynamic properties with __set() implementation, and AllowDynamicProperties should not change anything.

eduardor2k commented 1 year ago

I will be looking into this, the official php docs don't say much about this, but the RFC has some clear examples:

https://wiki.php.net/rfc/deprecate_dynamic_properties

Closing down until I do some testing, thanks @rob006 for pointing that out!

rob006 commented 1 year ago

This is implemented by framework, so I doubt you will find any PHP docs regarding this:

https://github.com/yiisoft/yii/blob/d7845aa29dcc81846b5be35591781613a61244b5/framework/base/CComponent.php#L173-L174