PHP 8.2. Message: Creation of dynamic property blitz::$tpl is deprecated
Closed this issue · 5 comments
As is common with minor releases, [PHP 8.2] adds some deprecations and Blitz get error:
Severity: 8192
Message: Creation of dynamic property blitz::$tpl is deprecated
Dmitry, could you please provide a code to reproduce the message?
Hi, Alexey!
This code triggers deprecation error:
$b = new \Blitz();
See the attached make tests
results. Only one test passes on php8.2 on Debian.
Dynamic properties were deprecated in 8.2. Old extensions were just constructing objects using add_property_* functions and this started generating deprecation errors. There are two ways to fix: either using ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES when registering blitz class, or using other zend property declaration API.
ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES hack works fine.
Steps to fix quickly - below.
Updated version will be here soon.
add the following line in module initialization section:
INIT_CLASS_ENTRY(blitz_class_entry, "blitz", blitz_functions);
+ blitz_class_entry.ce_flags |= ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES;
zend_register_internal_class(&blitz_class_entry);
This blocks add_property_* from generating the error.
fisher@fisher blitz % cat test.php
<?
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
dl('blitz.so');
$T = new Blitz();
$T->load("hello, {{ \$who }}!\n");
$T->display(['who' => 'world']);
?>
fisher@fisher blitz % /local/php-8.2.1/bin/php test.php
hello, world!