Welcome Guest, Not a member yet? Register   Sign In
Migrating to php 8.2 - how to solve deprecated dynamics properties
#6

(This post was last modified: 01-16-2023, 10:45 AM by jasonzig.)

(12-19-2022, 02:08 AM)kcs Wrote:
(12-18-2022, 05:47 PM)kenjis Wrote: Try to add:
PHP Code:
use AllowDynamicProperties

But the best way is to define the properties you use.
Because dynamic properties are deprecated.

Use AllowDynamicProperties still does not work (or maybe I did not place it where it should for it to work. 

But I now understand what you meant by "define properties".  
PHP Code:
protected $viewData = [];
protected 
$session = []; 
solved my issue.

Thanks  Cool

This worked for me as well.

Adding
PHP Code:
protected $session = []; 
to my base controller allowed the this statement to work in the base controller initController method:
PHP Code:
$this->session = \Config\Services::session(); 

Thanks so much to kcs for the question, and to kenjis for the solution.

context: PHP 8.2.1 Development Server via homebrew + CI4.2.11 `php spark serve`

(Using CodeIgniter since 1.x)
Reply


Messages In This Thread
RE: Migrating to php 8.2 - how to solve deprecated dynamics properties - by jasonzig - 01-16-2023, 10:43 AM



Theme © iAndrew 2016 - Forum software by © MyBB