-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHP 8.2 - Deprecate dynamic properties #307
Comments
I think this is impossible to fix. Zend_View created properties dynamically. This looks like zend_view is not usable like this in php8.2 |
The |
This would also be a solution for https://github.com/Shardj/zf1-future/blob/release-1.21.4/library/Zend/Form/Element.php#L863-L878 |
The |
Would this be a temporary solution? or permanent? |
Reading up on https://www.php.net/manual/en/language.oop5.properties.php#language.oop5.properties.dynamic-properties it looks like implementing a __set() and __get() method is more future-proof. |
On the other hand, not using this repository is even way more future-proof |
but we love this repository, so we have to do the best we can. |
You can also |
I see |
no. |
ok that's good then adding the attribute should be the way to go |
Can anyone give a permanent solution to this issue? |
This should have been fixed in 1.22.0 if I'm not mistaken. Zend_View_Abstract contains changes needed, see #261. |
@thijsvdanker you need to provide a standalone reproducer for your report to be useful. |
@glensc I understand. |
Same here, broken after putting the Actually, I don't mind the zf1-future change, but just to help others I'll explain the fix... In our codebase we had
Well that doesn't work now the dynamic properties are stored in a Easily changed our code to fix with
So maybe a mistake to ever use |
When using the ContextSwitch ActionHelper, a 'contextKey' is used which defaults to
No setters are available to influence the value of the 'contextKey'. In various parts of the class it then checks whether this property is set on the Controller and if not, will set it: zf1-future/library/Zend/Controller/Action/Helper/ContextSwitch.php Lines 1145 to 1149 in 7fa9c5f
I circumvented / resolved this specific deprecation by adding But as suggested in #307 (comment) |
Feel free to create an PR for that and add #[AllowDynamicProperties]. It makes no sense to rework it. |
@hungtrinh well, using private properties should be forbidden, unless properly justified. Completely breaking possible inheritance. Anyway, thanks for pointing that out, we are done here then :) |
It looks like it's safe to use the `#[AllowDynamicProperties]` attribute, and it should still be valid for php 9.0 and not throw an error, contrary to what I understood at first. As per RFC: https://wiki.php.net/rfc/deprecate_dynamic_properties#proposal "The creation of dynamic properties on classes that aren't marked with the #[AllowDynamicProperties] attribute is deprecated in PHP 8.2 and becomes an Error exception in PHP 9.0." Related issues from zf1-future where they went with refactoring those classes to use a defined property to store all previously dynamic props in an array, which introduced breaking changes: Shardj/zf1-future#307 (comment) Shardj/zf1-future#261 Shardj/zf1-future#268 Shardj/zf1-future#328 Shardj/zf1-future#329
It looks like it's safe to use the `#[AllowDynamicProperties]` attribute, and it should still be valid for php 9.0 and not throw an error, contrary to what I understood at first. As per RFC: https://wiki.php.net/rfc/deprecate_dynamic_properties#proposal "The creation of dynamic properties on classes that aren't marked with the #[AllowDynamicProperties] attribute is deprecated in PHP 8.2 and becomes an Error exception in PHP 9.0." Related issues from zf1-future where they went with refactoring those classes to use a defined property to store all previously dynamic props in an array, which introduced breaking changes: Shardj/zf1-future#307 (comment) Shardj/zf1-future#261 Shardj/zf1-future#268 Shardj/zf1-future#328 Shardj/zf1-future#329
It looks like it's safe to use the `#[AllowDynamicProperties]` attribute, and it should still be valid for php 9.0 and not throw an error, contrary to what I understood at first. As per RFC: https://wiki.php.net/rfc/deprecate_dynamic_properties#proposal "The creation of dynamic properties on classes that aren't marked with the #[AllowDynamicProperties] attribute is deprecated in PHP 8.2 and becomes an Error exception in PHP 9.0." Related issues from zf1-future where they went with refactoring those classes to use a defined property to store all previously dynamic props in an array, which introduced breaking changes: Shardj/zf1-future#307 (comment) Shardj/zf1-future#261 Shardj/zf1-future#268 Shardj/zf1-future#328 Shardj/zf1-future#329
hello everyone,
is it planned to face the problem of "Creation of dynamic property"? I don't know, but this will be a bit painful.
Deprecated: Creation of dynamic property Zend_View::$var is deprecated
The text was updated successfully, but these errors were encountered: