zendtech / IbmiToolkit

PHP frontend to XMLSERVICE for IBM i development.
BSD 3-Clause "New" or "Revised" License
46 stars 34 forks source link

Dynamic property deprecated error in ToolkitServiceParameter.php #189

Closed alanseiden closed 11 months ago

alanseiden commented 11 months ago

A developer writes: We ran into trouble with an RPG program call in PHP 8.2.

Exception: PHP ERROR Exception: [Creation of dynamic property ToolkitApi\\PackedDecParam::$returnParameter is deprecated][8192]; File: [\/QOpenSys\/chroots\/php8_2\/QOpenSys\/pkgs\/lib\/php\/ToolkitApi\/ToolkitServiceParameter.php]; Line Number: [66]

The constructor is setting a returnParameter that isn't declared. I added this below line below 23 protected $returnParameter;

(This is only a deprecation, but their framework elevated it into an exception. We should correct the issue now.)

alanseiden commented 11 months ago

More info about the deprecation: https://stitcher.io/blog/deprecated-dynamic-properties-in-php-82

alanseiden commented 11 months ago

I asked what kind of code triggers the deprecation notice.

Anything that creates an instance of ToolkitServiceParameter is going to generate a warning. We've got the code wrapped, so this isn't exactly it, but it will be something like this:

include_once 'iToolkitService.php';

$toolkit = \ToolkitService::getInstance('', '', '');
$params = [];
$params []= $this->toolkit->AddParameterPackDec('both',10,0,'P1','P1',0);
$result = $this->toolkit->PgmCall('PGM1','MYLIB',$params, null, null);