Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation on PHP 8.1 in ZipArchive #2187

Closed
garethellis36 opened this issue Jan 31, 2022 · 1 comment · Fixed by #2193
Closed

Deprecation on PHP 8.1 in ZipArchive #2187

garethellis36 opened this issue Jan 31, 2022 · 1 comment · Fixed by #2193

Comments

@garethellis36
Copy link
Contributor

Deprecated: ZipArchive::open(): Passing null to parameter #2 ($flags) of type int is deprecated in /var/itrans/one/app/Vendor/phpoffice/phpword/src/PhpWord/Shared/ZipArchive.php on line 136

The current method signature of ZipArchive::open() is public function open($filename, $flags = null).

If no argument is passed as the second argument here, null is passed as the second argument on line 136:

            $zip = new \ZipArchive();
            $result = $zip->open($this->filename, $flags); // <-- line 136

Passing 0 achieves the same behaviour as passing null. Therefore, I believe the appropriate fix here would be:

$zip = new \ZipArchive();

if ($flags === null) {
 $flags = 0;
}

$result = $zip->open($this->filename, $flags);

This would eliminate the deprecation and not break any BC within the library.

I'm happy to submit a PR if required.

@str
Copy link

str commented Mar 9, 2022

I just wanted to thank you for your great work. So, thank you in the name of everyone who uses PHPWord and are migrating to PHP 8.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants