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

Hi,
I am trying to upgrade to php 8.2, but running into the deprecated dynamic properties issues and I am not sure how to solve it.
In my BaseController, I prepare some elements I need within the views, but that generates the deprecated error. Here how it looks like:

PHP Code:
abstract class BaseController extends Controller
{

protected 
$request;

protected 
$helpers = [];

    public function initController(RequestInterface $requestResponseInterface $responseLoggerInterface $logger)
    {
        // Do Not Edit This Line
        parent::initController($request$response$logger);

        // Preload any models, libraries, etc, here.
        helper('html');

        // E.g.: $this->session = \Config\Services::session();
        $this->viewData['locale'] = $request->getLocale();
        $this->viewData['supportedLocales'] = $request->config->supportedLocales;
        $this->viewData['currentMenu'] = '';
        $this->viewData['axeptioID'] = getenv('axeptioID');
        $this->viewData['axeptioCookiesVersion'] = getenv('axeptioCookiesVersion');

        $this->session = \Config\Services::session();
        $this->session->set('locale',$request->getLocale());


    }



I tried adding as suggested here https://stitcher.io/blog/deprecated-dyna...-in-php-82 the built-in attribute, but without success.

PHP Code:
#[AllowDynamicProperties]
abstract class BaseController extends Controller
{
... 

{What is the best way to solve this? Thanks for your help

Reply


Messages In This Thread
Migrating to php 8.2 - how to solve deprecated dynamics properties - by kcs - 12-18-2022, 06:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB