Summary:
Deprecated: Creation of dynamic property Captcha::$captchalibs is deprecated in modules\Captcha\Captcha.module.php
Detailed Description:
Under PHP 8.4.6
Deprecated: Creation of dynamic property Captcha::$captchalibs is deprecated in
C:\wamp64\www\eat-lyon\modules\Captcha\Captcha.module.php on line 99
This warning occurs because of changes in PHP 8.2+. PHP now strictly discourages
(and will eventually prohibit) the creation of "dynamic properties"—meaning you
cannot assign a value to a class property that hasn't been explicitly defined at
the top of the class definition.
In your Captcha module, you are assigning $this->captchalibs in the constructor,
but it was never declared as a property in the class header.
The Fix
Open modules\Captcha\Captcha.module.php and add the missing property declaration
near the top of the class.
Locate the class properties (around line 25).
Add the missing line to the block of defined properties.
Change this:
class Captcha extends CMSModule
{
/**
* @var array Messages to be shown to the user
*/
var $messages;
/**
* @var array Error messages to be shown to the user
*/
var $errors;
/**
* The currently active Captcha library
* @var object The active Captcha library
*/
var $active_lib;
To this:
class Captcha extends CMSModule
{
/**
* @var array Messages to be shown to the user
*/
var $messages;
/**
* @var array Error messages to be shown to the user
*/
var $errors;
/**
* The currently active Captcha library
* @var object The active Captcha library
*/
var $active_lib;
/**
* @var array The list of captcha libraries
*/
var $captchalibs;
Why this works:
By adding var $captchalibs; (or public $captchalibs;) to the top of the class,
you are explicitly declaring the variable to the PHP engine. This satisfies the
requirement in PHP 8.2+ that all properties must be declared before they are
used, which eliminates the "Creation of dynamic property" warning.