Technical issue
Since PHP 8.2, dynamic properties are deprecated. Unfortunately, Minz_View
relies heavily on them to declare variables accessible in the views. I guess FreshRSS_View
was added to resolve this problem.
Problem is: extensions that add new controllers/actions cannot declare new view variables with these classes.
Solution 1
Let the extensions declare their own View
class with their own variables.
Advantage: variables are well defined with their types, the code is more robust.
Downside: from a developer point of view, the experience is pretty poor and I would bet that a lot of extensions will break with PHP 8.2.
Solution 2
Allow Minz_View
to accept dynamic properties. There are three solutions (c.f. PHP.Watch):
- use the
#[AllowDynamicProperties]
attribute (introduced in PHP 8.2 so this is not an actual option) - extends the
stdClass
(the easiest solution) - declare
__set
and__get
magic methods
Advantage: it doesn't break the current extensions API and it's easy for developers to create their own view variables.
Downside: we lose the type hinting.
Solution 3
We could combine solution 2 with the actual FreshRSS_View
class by adding the magic methods to it.
The core variables would still benefit from type hinting, while extensions variables would be stored in an array of variables.
Advantage: it combines both advantages of previous solution.
Downside: I think it's quite complicated/weird for new developers to understand why some variables are type hinted while being optional.
IMO
I would go with solution 2, with the magic methods variant as it makes the behaviour more explicit.
What do you think?