Deprecated dynamic properties in PHP 8.2 |
Deprecated dynamic properties in PHP 8.2
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Is there any plan to fix this in CI3?
From what I recall, CI uses dynamically assigned properties rampantly. I'm trying to upgrade a site running on PHP 7 (which is EOL as of 2022/11/28) and there are a whole lot of dynamic property deprecation errors. These errors in my case are limited to about 6 classes (at least for the one page i've looked at so far) but I suspect there are more classes with this problem. I created an issue on the ci3 repo. I hope others might go chime in over there. Also, is this a problem in CI4? (01-17-2023, 03:58 PM)Codeigniter 3 and PHP 8.2To get rid of the error messages you have to change some variables in the system map.
I think a better way is to implement #[\AllowDynamicProperties]
Easier and much shorter. In all the above mentioned classes add #[\AllowDynamicProperties] above class xxxxxx { I give you my changes: /system/core/URI.php #[\AllowDynamicProperties] class CI_URI { /system/core/Router.php #[\AllowDynamicProperties] class CI_Router { /system/core/Loader.php #[\AllowDynamicProperties] class CI_Loader { /system/core/Controller.php #[\AllowDynamicProperties] class CI_Controller { /system/core/DB_driver.php #[\AllowDynamicProperties] abstract class CI_DB_driver { (08-08-2022, 12:51 PM)InsiteFX Wrote: Deprecated dynamic properties in PHP 8.2 Interesting changes, thanks for the headsup! (01-19-2023, 06:53 AM)ubeljan Wrote:Given the rampant use of dynamic properties that I've seen in CI3's source code, I don't know if adding all of these public object properties is the best approach. Are you sure that you got them all? I expect you haven't. I also think that some of the ways by which CI3 loads libraries may introduce a near-infinite number of new object properties that you have no accounted for.(01-17-2023, 03:58 PM)Codeigniter 3 and PHP 8.2To get rid of the error messages you have to change some variables in the system map. With this changes I could access the database and email libraries without error messages. Add the public variables to the mentioned files./system/core/URI.php Wrote: class CI_URI { If you had read the link in the original post of this thread, you would know there are two other ways which would cover all possible dynamic properties, and these would involve a lot less code: 1) implement __get and __set methods to intercept assignment of properties that have not been expressly defined. 2) Add the AllowDynamicProperties attribute in the relevant classes. Code: #[\AllowDynamicProperties]
Anyone can hack the core .. is a bad practice !!! #6
I don't undestand .. I'm spending a lot of time to try to solve this brutal problem... and only two solution are : implement __get and __set AND hack the core ??? I don't want hack the core... probably there is another solution .. Is it possible that anyone can't release a version with this FIX for PHP V8.2? It is too strange is a solution implement _get and _set with hook? if someone have a solution please can post this here Thank you so much
(01-19-2023, 09:02 AM)ubeljan Wrote: I think a better way is to implement #[\AllowDynamicProperties] This totally worked for me. Thank you
hello
what is the situation for this problem, will a core update will be published? |
Welcome Guest, Not a member yet? Register Sign In |