iliaal / php_excel

PHP Extension interface to the Excel writing/reading library
http://ilia.ws
534 stars 131 forks source link

PHP8: object clone warning #266

Closed Jan-E closed 3 years ago

Jan-E commented 3 years ago
/root/php_excel/excel.c:6830:2: note: in expansion of macro ‘REGISTER_EXCEL_CLASS’
 6830 |  REGISTER_EXCEL_CLASS(Format,  format,   excel_format_object_clone);
      |  ^~~~~~~~~~~~~~~~~~~~
/root/php_excel/excel.c:85:47: warning: assignment to ‘zend_object_clone_obj_t’ {aka ‘struct _zend_object * (*)(struct _zend_object *)’} from incompatible pointer type ‘zend_object * (*)(zval *)’ {aka ‘struct _zend_object * (*)(struct _zval_struct *)’} [-Wincompatible-pointer-types]

This warning is generated through levels of macro's from this line: https://github.com/Jan-E/php_excel/blob/da2fb8218aee5b4100329e77ba95e6357adeb858/excel.c#L6910

The REGISTER_EXCEL_CLASS macro is here: https://github.com/Jan-E/php_excel/blob/da2fb8218aee5b4100329e77ba95e6357adeb858/excel.c#L75

And excel_format_object_clone is defined here: https://github.com/Jan-E/php_excel/blob/da2fb8218aee5b4100329e77ba95e6357adeb858/excel.c#L385

See https://github.com/iliaal/php_excel/issues/264#issuecomment-728876611 for a hint to the solution:

The clone_obj handler expects a zval in PHP 7, but a zend_object in PHP 8; see https://github.com/php/php-src/blob/1727d96d0e1057ce140682b79d7f121dee0fc370/UPGRADING.INTERNALS#L236.

Jan-E commented 3 years ago

https://github.com/Jan-E/php_excel/commit/4a99fb6a0341ea75422a10833087479a7115ac2e removes the warning and fixes the Format clone and Font clone tests: https://github.com/iliaal/php_excel/blob/master/tests/018.phpt https://github.com/iliaal/php_excel/blob/master/tests/019.phpt

Jan-E commented 3 years ago

@cmb69 Fixed. thanks