magento / magento-zend-pdf

BSD 3-Clause "New" or "Revised" License
2 stars 3 forks source link

Fixed regression from fixing PHP 8.2 deprecated usages earlier, which… #2

Closed hostep closed 1 year ago

hostep commented 1 year ago

… broke rendering certain elements in a pdf in Magento

This fixes a regression bug that was created in #1 The bug is described here: https://github.com/magento/magento2/issues/37897

I can not really explain how it triggers, it's very weird and unexpected. But reverting the $value member back to each individual child class and removing it again from the parent Zend_Pdf_Element class fixes the problem.

In order to fix the PHP 8.2 deprecated usage of this->value in Zend_Pdf_Element, I turned the toPhp function into an abstract function which forces the classes that inherit from it to implement it, so I did that. It's a bit of duplicated code each time, but can't find a better way to solve it. At least the return types in docblocks will be more correct now for the toPhp function ...

(the double new lines in between methods is to stay consistent with the coding style of the original code)

hostep commented 1 year ago

See https://github.com/magento/magento-zend-pdf/compare/1.16.2..6047a4a91f273513364c5a384f0ce8c018088265 for the diff between the original code and both #1 and #2 combined.