- Edited
I'm working on a site implemented in CodeIgniter 3. We are trying to upgrade the server because it's running Ubuntu 16 / PHP 7 which are both now EOL. The website code works pretty great with PHP 8.1 but the latest release is PHP 8.2.1 and we'd like to get as up-to-date as possible if we are going through the trouble of upgrading. Unfortunately, PHP 8.2 deprecates dynamic properties for a class object, and CI3 rampantly assigns such dynamic properties.
I know we can address this problem by A) creating magic __set and __get methods or by B) adding this new attribute before each class that endures this abuse:
#[\AllowDynamicProperties]
class FooClass {
// blah blah blah
}
$foo = new FooClass();
$foo->some_new_property = 42;
Question 1: Which solution do you guys prefer for this sort of problem?
The magic methods approach, A, might let you include some logic to respond to possibly abusive behaviors, Whereas the attribute approach, B, is briefer.
Question 2: Is there some efficient way to identify all the classes that undergo this abuse?
I wonder if there is some IDE tool that might detect this problem? Or can anyone suggest an approach to identifying all the poor classes that are subject to this abominable mistreatment?
EDIT: Note that there's a discussion of this very question on github. If anyone is interested in chiming in over there, it would probably draw more attention to the issue, which would be nice.