Open KFRANCMM opened 2 years ago
For me, I get a "Deprecated" notice with the same text (when saving a Word document), which can be ignored (until PHP 9) by adding #[\ReturnTypeWillChange]
before the public function writeAttribute($name, $value)
declaration in ...\phpoffice\phpword\src\PhpWord\Shared\XMLWriter.php
.
So coming back to this, I now realize that the proper fix for this is actually to add the proper return type to the writeAttribute
function:
public function writeAttribute($name, $value): bool
Since it's actually calling parent::writeAttribute
, the return type will not change. The deprecation notice is only shown because the overloaded function doesn't tell PHP it will return a bool
.
When will this be fixed in future updates?
Is there any update on a fix for this? I must upgrade my web apps to php 8.1 before the end of May 2023
Describe the Bug
I am trying to use the library in Code Igniter 4, with PHP 8.1.2 but when I try to use XMLWritter an exception appears. I don't know if PHPWord is compatible with this php version or a downgrade is required. I tried using the 3 ways to save documents, only the HTML option works.
Steps to Reproduce
I have only tested executing the example code, the IOFactory::createWriter() object does its function but when using the save() method, the exception appears.
Code
Expected Behavior
Save document on server or expose via web browser.
Current Behavior
Function stopped by XMLWritter exception.
Context
Environment information: