From c57c2929155f19833c75bafddbe93e82597036fc Mon Sep 17 00:00:00 2001 From: Gareth Ellis Date: Tue, 8 Feb 2022 12:40:06 +0000 Subject: [PATCH] #2187 Addresses deprecation on PHP 8.1 in ZipArchi --- src/PhpWord/Shared/ZipArchive.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/PhpWord/Shared/ZipArchive.php b/src/PhpWord/Shared/ZipArchive.php index bc71e74b17..6517ca8abf 100644 --- a/src/PhpWord/Shared/ZipArchive.php +++ b/src/PhpWord/Shared/ZipArchive.php @@ -133,6 +133,13 @@ public function open($filename, $flags = null) if (!$this->usePclzip) { $zip = new \ZipArchive(); + + // PHP 8.1 compat - passing null as second arg to \ZipArchive::open() is deprecated + // passing 0 achieves the same behaviour + if ($flags === null) { + $flags = 0; + } + $result = $zip->open($this->filename, $flags); // Scrutizer will report the property numFiles does not exist