From fc18246b206374ce81d0289c76bba67c6f327ff8 Mon Sep 17 00:00:00 2001 From: Christian Stein Date: Wed, 8 Jun 2022 14:14:25 +0200 Subject: [PATCH 1/2] PreserveText preg_split fix third parameter must be -1 not null (php 8.1 deprecate warning) --- src/PhpWord/Element/PreserveText.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/Element/PreserveText.php b/src/PhpWord/Element/PreserveText.php index c0e64268ba..803ee4f395 100644 --- a/src/PhpWord/Element/PreserveText.php +++ b/src/PhpWord/Element/PreserveText.php @@ -60,7 +60,7 @@ public function __construct($text = null, $fontStyle = null, $paragraphStyle = n $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle); $this->text = SharedText::toUTF8($text); - $matches = preg_split('/({.*?})/', $this->text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + $matches = preg_split('/({.*?})/', $this->text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); if (isset($matches[0])) { $this->text = $matches; } From 91416e48ac4bf320fb4c0949ed238d80e94ee41c Mon Sep 17 00:00:00 2001 From: Christian Stein Date: Wed, 8 Jun 2022 14:22:51 +0200 Subject: [PATCH 2/2] XMLWriter ReturnTypeWillChange fix add #[\ReturnTypeWillChange] Attribute to the function writeAttribute (php 8.1 deprecate warning) --- src/PhpWord/Shared/XMLWriter.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PhpWord/Shared/XMLWriter.php b/src/PhpWord/Shared/XMLWriter.php index 930ad62ee1..dbe0db1dfa 100644 --- a/src/PhpWord/Shared/XMLWriter.php +++ b/src/PhpWord/Shared/XMLWriter.php @@ -171,6 +171,7 @@ public function writeAttributeIf($condition, $attribute, $value) * @param mixed $value * @return bool */ + #[\ReturnTypeWillChange] public function writeAttribute($name, $value) { if (is_float($value)) {