浏览代码

docs: fix grammar in exception messages, DocBlocks and README

- reword broken English in user-facing exception messages and update
  the matching test assertions (e.g. 'Can not password from entry',
  'Not support encryption zip', 'is exists').
- fix typos and awkward phrasing in DocBlocks across src ('flogs',
  'int local header', 'Amica OS', 'Asi Unix Extra Filed Data').
- fix grammar, articles and a wrong anchor link in README.md; update
  the ArrayIterator example to avoid a PHP 8.5 deprecation.
- grammar fixes in the GitHub issue and pull request templates.
Ne-Lexa 3 周之前
父节点
当前提交
1941e0d7b8

+ 1 - 1
.github/ISSUE_TEMPLATE/1_Bug_report.md

@@ -8,7 +8,7 @@ about: Report errors and problems
 | -----------------------------| ---
 | Library version(s) affected: | x.y.z
 | PHP version(s):              | x.y.z
-| OS (with bit depth):         | <!-- ex. Ubuntu 18.04 64-bit -->
+| OS (with bit depth):         | <!-- e.g. Ubuntu 18.04 64-bit -->
 
 **Description**  
 <!-- A clear and concise description of the problem. -->

+ 12 - 12
.github/PULL_REQUEST_TEMPLATE.md

@@ -1,12 +1,12 @@
-| Q             | A
-| ------------- | ---
-| Bug fix?      | yes/no
-| New feature?  | yes/no <!-- don't forget to update CHANGELOG.md file -->
-
-<!--
-Write a short README entry for your feature/bugfix here (replace this comment block.)
-
-Do NOT send pull request to `master` branch.
-Please send to `develop` branch instead.
-Any PR to `master` branch will NOT be merged.
--->
+| Q             | A
+| ------------- | ---
+| Bug fix?      | yes/no
+| New feature?  | yes/no <!-- don't forget to describe the change in the release notes -->
+
+<!--
+Write a short description of your feature/bugfix here (replace this comment block).
+
+Do NOT send a pull request to the `master` branch.
+Please send it to the `develop` branch instead.
+Any PR to the `master` branch will NOT be merged.
+-->

+ 1 - 1
README.RU.md

@@ -773,7 +773,7 @@ $zipFile->outputAsPsr7Response($response, $outputFilename, $mimeType);
 ```php
 $response = $zipFile->outputAsSymfonyResponse($outputFilename);
 ```
-Вы можете установить Mime-Type:
+Вы можете установить MIME-тип:
 ```php
 $mimeType = 'application/zip';
 $response = $zipFile->outputAsSymfonyResponse($outputFilename, $mimeType);

+ 88 - 88
README.md

@@ -1,6 +1,6 @@
 <h1 align="center"><img src="logo.svg" alt="PhpZip" width="250" height="51"></h1>
 
-`PhpZip` is a php-library for extended work with ZIP-archives.
+`PhpZip` is a PHP library for extended work with ZIP archives.
 
 [![Packagist Version](https://img.shields.io/packagist/v/nelexa/zip.svg)](https://packagist.org/packages/nelexa/zip)
 [![Packagist Downloads](https://img.shields.io/packagist/dt/nelexa/zip.svg?color=%23ff007f)](https://packagist.org/packages/nelexa/zip)
@@ -24,7 +24,7 @@ Table of contents
 - [Glossary](#glossary)
 - [Documentation](#documentation)
   + [Overview of methods of the class `\PhpZip\ZipFile`](#overview-of-methods-of-the-class-phpzipzipfile)
-  + [Creation/Opening of ZIP-archive](#creationopening-of-zip-archive)
+  + [Creation/Opening of ZIP archive](#creationopening-of-zip-archive)
   + [Reading entries from the archive](#reading-entries-from-the-archive)
   + [Iterating entries](#iterating-entries)
   + [Getting information about entries](#getting-information-about-entries)
@@ -43,14 +43,14 @@ Table of contents
 
 ### Features
 - Opening and unzipping zip files.
-- Creating ZIP-archives.
+- Creating ZIP archives.
 - Modifying ZIP archives.
-- Pure php (not require extension `php-zip` and class `\ZipArchive`).
+- Pure PHP (does not require the `php-zip` extension or the `\ZipArchive` class).
 - It supports saving the archive to a file, outputting the archive to the browser, or outputting it as a string without saving it to a file.
-- Archival comments and comments of individual entry are supported.
+- Archive comments and comments for individual entries are supported.
 - Get information about each entry in the archive.
 - Only the following compression methods are supported:
-  + No compressed (Stored).
+  + No compression (Stored).
   + Deflate compression.
   + BZIP2 compression with the extension `php-bz2`.
 - Support for `ZIP64` (file size is more than 4 GB or the number of entries in the archive is more than 65535).
@@ -58,11 +58,11 @@ Table of contents
   > **Attention!**
   >
   > For 32-bit systems, the `Traditional PKWARE Encryption (ZipCrypto)` encryption method is not currently supported. 
-  > Use the encryption method `WinZIP AES Encryption`, whenever possible.
+  > Use the `WinZIP AES Encryption` method whenever possible.
   + Set the password to read the archive for all entries or only for some.
   + Change the password for the archive, including for individual entries.
   + Delete the archive password for all or individual entries.
-  + Set the password and/or the encryption method, both for all, and for individual entries in the archive.
+  + Set the password and/or the encryption method for all entries or for individual entries in the archive.
   + Set different passwords and encryption methods for different entries.
   + Delete the password for all or some entries.
   + Support `Traditional PKWARE Encryption (ZipCrypto)` and `WinZIP AES Encryption` encryption methods.
@@ -70,8 +70,8 @@ Table of contents
 
 ### Requirements
 - `PHP` >= 7.4 or `PHP` >= 8.0 (preferably 64-bit).
-- Optional php-extension `bzip2` for BZIP2 compression.
-- Optional php-extension `openssl` for `WinZip Aes Encryption` support.
+- Optional PHP extension `bzip2` for BZIP2 compression.
+- Optional PHP extension `openssl` for `WinZip AES Encryption` support.
 
 ### Installation
 `composer require nelexa/zip`
@@ -84,8 +84,8 @@ Latest stable version: [![Latest Stable Version](https://poser.pugx.org/nelexa/z
 $zipFile = new \PhpZip\ZipFile();
 try{
     $zipFile
-        ->addFromString('zip/entry/filename', 'Is file content') // add an entry from the string
-        ->addFile('/path/to/file', 'data/tofile') // add an entry from the file
+        ->addFromString('zip/entry/filename', 'Is file content') // add an entry from a string
+        ->addFile('/path/to/file', 'data/tofile') // add an entry from a file
         ->addDir(__DIR__, 'to/path/') // add files from the directory
         ->saveAsFile($outputFilename) // save the archive to a file
         ->close(); // close archive
@@ -106,22 +106,22 @@ finally{
     $zipFile->close();
 }
 ```
-Other examples can be found in the `tests/` folder
+Other examples can be found in the `tests/` folder.
 
 ### Glossary
-**Zip Entry** - file or folder in a ZIP-archive. Each entry in the archive has certain properties, for example: file name, compression method, encryption method, file size before compression, file size after compression, CRC32 and others.
+**Zip Entry** - a file or folder in a ZIP archive. Each entry in the archive has certain properties, for example: file name, compression method, encryption method, file size before compression, file size after compression, CRC32 and others.
 
 ### Documentation:
 #### Overview of methods of the class `\PhpZip\ZipFile`
 - [ZipFile::__construct](#zipfile__construct) - initializes the ZIP archive.
 - [ZipFile::addAll](#zipfileaddall) - adds all entries from an array.
-- [ZipFile::addDir](#zipfileadddir) - adds files to the archive from the directory on the specified path without subdirectories.
-- [ZipFile::addDirRecursive](#zipfileadddirrecursive) - adds files to the archive from the directory on the specified path with subdirectories.
+- [ZipFile::addDir](#zipfileadddir) - adds files to the archive from the directory at the specified path without subdirectories.
+- [ZipFile::addDirRecursive](#zipfileadddirrecursive) - adds files to the archive from the directory at the specified path with subdirectories.
 - [ZipFile::addEmptyDir](#zipfileaddemptydir) - add a new directory.
 - [ZipFile::addFile](#zipfileaddfile) - adds a file to a ZIP archive from the given path.
 - [ZipFile::addSplFile](#zipfileaddsplfile) - adds a `\SplFileInfo` to a ZIP archive.
 - [ZipFile::addFromFinder](#zipfileaddfromfinder) - adds files from the `Symfony\Component\Finder\Finder` to a ZIP archive.
-- [ZipFile::addFilesFromIterator](#zipfileaddfilesfromiterator) - adds files from the iterator of directories.
+- [ZipFile::addFilesFromIterator](#zipfileaddfilesfromiterator) - adds files from a directory iterator.
 - [ZipFile::addFilesFromGlob](#zipfileaddfilesfromglob) - adds files from a directory by glob pattern without subdirectories.
 - [ZipFile::addFilesFromGlobRecursive](#zipfileaddfilesfromglobrecursive) - adds files from a directory by glob pattern with subdirectories.
 - [ZipFile::addFilesFromRegex](#zipfileaddfilesfromregex) - adds files from a directory by PCRE pattern without subdirectories.
@@ -131,63 +131,63 @@ Other examples can be found in the `tests/` folder
 - [ZipFile::close](#zipfileclose) - close the archive.
 - [ZipFile::count](#zipfilecount) - returns the number of entries in the archive.
 - [ZipFile::deleteFromName](#zipfiledeletefromname) - deletes an entry in the archive using its name.
-- [ZipFile::deleteFromGlob](#zipfiledeletefromglob) - deletes an entries in the archive using glob pattern.
-- [ZipFile::deleteFromRegex](#zipfiledeletefromregex) - deletes an entries in the archive using PCRE pattern.
+- [ZipFile::deleteFromGlob](#zipfiledeletefromglob) - deletes entries in the archive using a glob pattern.
+- [ZipFile::deleteFromRegex](#zipfiledeletefromregex) - deletes entries in the archive using a PCRE pattern.
 - [ZipFile::deleteAll](#zipfiledeleteall) - deletes all entries in the ZIP archive.
 - [ZipFile::disableEncryption](#zipfiledisableencryption) - disable encryption for all entries that are already in the archive.
-- [ZipFile::disableEncryptionEntry](#zipfiledisableencryptionentry) - disable encryption of an entry defined by its name.
+- [ZipFile::disableEncryptionEntry](#zipfiledisableencryptionentry) - disables encryption of an entry identified by its name.
 - [ZipFile::extractTo](#zipfileextractto) - extract the archive contents.
 - [ZipFile::getArchiveComment](#zipfilegetarchivecomment) - returns the Zip archive comment.
 - [ZipFile::getEntryComment](#zipfilegetentrycomment) - returns the comment of an entry using the entry name.
 - [ZipFile::getEntryContent](#zipfilegetentrycontent) - returns the entry contents using its name.
-- [ZipFile::getListFiles](#zipfilegetlistfiles) - returns list of archive files.
+- [ZipFile::getListFiles](#zipfilegetlistfiles) - returns the list of archive files.
 - [ZipFile::hasEntry](#zipfilehasentry) - checks if there is an entry in the archive.
 - [ZipFile::isDirectory](#zipfileisdirectory) - checks that the entry in the archive is a directory.
 - [ZipFile::matcher](#zipfilematcher) - selecting entries in the archive to perform operations on them.
-- [ZipFile::openFile](#zipfileopenfile) - opens a zip-archive from a file.
-- [ZipFile::openFromString](#zipfileopenfromstring) - opens a zip-archive from a string.
-- [ZipFile::openFromStream](#zipfileopenfromstream) - opens a zip-archive from the stream.
-- [ZipFile::outputAsAttachment](#zipfileoutputasattachment) - outputs a ZIP-archive to the browser.
-- [ZipFile::outputAsPsr7Response](#zipfileoutputaspsr7response) - outputs a ZIP-archive as PSR-7 Response.
-- [ZipFile::outputAsSymfonyResponse](#zipfileoutputaspsr7response) - outputs a ZIP-archive as Symfony Response.
-- [ZipFile::outputAsString](#zipfileoutputasstring) - outputs a ZIP-archive as string.
-- [ZipFile::rename](#zipfilerename) - renames an entry defined by its name.
+- [ZipFile::openFile](#zipfileopenfile) - opens a zip archive from a file.
+- [ZipFile::openFromString](#zipfileopenfromstring) - opens a zip archive from a string.
+- [ZipFile::openFromStream](#zipfileopenfromstream) - opens a zip archive from a stream.
+- [ZipFile::outputAsAttachment](#zipfileoutputasattachment) - outputs a ZIP archive to the browser.
+- [ZipFile::outputAsPsr7Response](#zipfileoutputaspsr7response) - outputs a ZIP archive as a PSR-7 Response.
+- [ZipFile::outputAsSymfonyResponse](#zipfileoutputassymfonyresponse) - outputs a ZIP archive as a Symfony Response.
+- [ZipFile::outputAsString](#zipfileoutputasstring) - outputs a ZIP archive as a string.
+- [ZipFile::rename](#zipfilerename) - renames an entry identified by its name.
 - [ZipFile::rewrite](#zipfilerewrite) - save changes and re-open the changed archive.
 - [ZipFile::saveAsFile](#zipfilesaveasfile) - saves the archive to a file.
-- [ZipFile::saveAsStream](#zipfilesaveasstream) - writes the archive to the stream.
+- [ZipFile::saveAsStream](#zipfilesaveasstream) - writes the archive to a stream.
 - [ZipFile::setArchiveComment](#zipfilesetarchivecomment) - set the comment of a ZIP archive.
 - [ZipFile::setCompressionLevel](#zipfilesetcompressionlevel) - set the compression level for all files in the archive.
 - [ZipFile::setCompressionLevelEntry](#zipfilesetcompressionlevelentry) - sets the compression level for the entry by its name.
 - [ZipFile::setCompressionMethodEntry](#zipfilesetcompressionmethodentry) - sets the compression method for the entry by its name.
-- [ZipFile::setEntryComment](#zipfilesetentrycomment) - set the comment of an entry defined by its name.
+- [ZipFile::setEntryComment](#zipfilesetentrycomment) - sets the comment of an entry identified by its name.
 - [ZipFile::setReadPassword](#zipfilesetreadpassword) - set the password for the open archive.
-- [ZipFile::setReadPasswordEntry](#zipfilesetreadpasswordentry) - sets a password for reading of an entry defined by its name.
+- [ZipFile::setReadPasswordEntry](#zipfilesetreadpasswordentry) - sets a password for reading an entry identified by its name.
 - [ZipFile::setPassword](#zipfilesetpassword) - sets a new password for all files in the archive.
-- [ZipFile::setPasswordEntry](#zipfilesetpasswordentry) - sets a new password of an entry defined by its name.
-- [ZipFile::unchangeAll](#zipfileunchangeall) - undo all changes done in the archive.
+- [ZipFile::setPasswordEntry](#zipfilesetpasswordentry) - sets a new password for an entry identified by its name.
+- [ZipFile::unchangeAll](#zipfileunchangeall) - undoes all changes made to the archive.
 - [ZipFile::unchangeArchiveComment](#zipfileunchangearchivecomment) - undo changes to the archive comment.
-- [ZipFile::unchangeEntry](#zipfileunchangeentry) - undo changes of an entry defined by its name.
+- [ZipFile::unchangeEntry](#zipfileunchangeentry) - undoes changes to an entry identified by its name.
 
-#### Creation/Opening of ZIP-archive
+#### Creation/Opening of ZIP archive
 ##### ZipFile::__construct**
 Initializes the ZIP archive
 ```php
 $zipFile = new \PhpZip\ZipFile();
 ```
 ##### ZipFile::openFile
-Opens a zip-archive from a file.
+Opens a zip archive from a file.
 ```php
 $zipFile = new \PhpZip\ZipFile();
 $zipFile->openFile('file.zip');
 ```
 ##### ZipFile::openFromString
-Opens a zip-archive from a string.
+Opens a zip archive from a string.
 ```php
 $zipFile = new \PhpZip\ZipFile();
 $zipFile->openFromString($stringContents);
 ```
 ##### ZipFile::openFromStream
-Opens a zip-archive from the stream.
+Opens a zip archive from a stream.
 ```php
 $stream = fopen('file.zip', 'rb');
 
@@ -267,7 +267,7 @@ $zipFile->extractTo($toDirectory, $extractOnlyFiles);
 ```
 #### Iterating entries
 `ZipFile` is an iterator.
-Can iterate all the entries in the `foreach` loop.
+You can iterate over all entries in a `foreach` loop.
 ```php
 foreach($zipFile as $entryName => $contents){
     echo "Filename: $entryName" . PHP_EOL;
@@ -275,9 +275,9 @@ foreach($zipFile as $entryName => $contents){
     echo '-----------------------------' . PHP_EOL;
 }
 ```
-Can iterate through the `Iterator`.
+You can iterate using the `Iterator` interface.
 ```php
-$iterator = new \ArrayIterator($zipFile);
+$iterator = new \ArrayIterator(iterator_to_array($zipFile));
 while ($iterator->valid())
 {
     $entryName = $iterator->key();
@@ -464,7 +464,7 @@ $zipFile->addFilesFromIterator($directoryIterator, $localPath, \PhpZip\Constants
 $zipFile->addFilesFromIterator($directoryIterator, $localPath, \PhpZip\Constants\ZipCompressionMethod::DEFLATED); // Deflate compression
 $zipFile->addFilesFromIterator($directoryIterator, $localPath, \PhpZip\Constants\ZipCompressionMethod::BZIP2); // BZIP2 compression
 ```
-Example with some files ignoring:
+Example that ignores some files:
 ```php
 $ignoreFiles = [
     'file_ignore.txt', 
@@ -486,7 +486,7 @@ $zipFile->addFilesFromIterator($ignoreIterator);
 ##### ZipFile::addFilesFromGlob
 Adds files from a directory by [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)) without subdirectories.
 ```php
-$globPattern = '**.{jpg,jpeg,png,gif}'; // example glob pattern -> add all .jpg, .jpeg, .png and .gif files
+$globPattern = '**.{jpg,jpeg,png,gif}'; // example glob pattern: adds all .jpg, .jpeg, .png and .gif files
 
 $zipFile = new \PhpZip\ZipFile();
 $zipFile->addFilesFromGlob($dir, $globPattern);
@@ -503,7 +503,7 @@ $zipFile->addFilesFromGlob($dir, $globPattern, $localPath, \PhpZip\Constants\Zip
 ##### ZipFile::addFilesFromGlobRecursive
 Adds files from a directory by [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)) with subdirectories.
 ```php
-$globPattern = '**.{jpg,jpeg,png,gif}'; // example glob pattern -> add all .jpg, .jpeg, .png and .gif files
+$globPattern = '**.{jpg,jpeg,png,gif}'; // example glob pattern: adds all .jpg, .jpeg, .png and .gif files
 
 $zipFile = new \PhpZip\ZipFile();
 $zipFile->addFilesFromGlobRecursive($dir, $globPattern);
@@ -520,7 +520,7 @@ $zipFile->addFilesFromGlobRecursive($dir, $globPattern, $localPath, \PhpZip\Cons
 ##### ZipFile::addFilesFromRegex
 Adds files from a directory by [PCRE pattern](https://en.wikipedia.org/wiki/Regular_expression) without subdirectories.
 ```php
-$regexPattern = '/\.(jpe?g|png|gif)$/si'; // example regex pattern -> add all .jpg, .jpeg, .png and .gif files
+$regexPattern = '/\.(jpe?g|png|gif)$/si'; // example regex pattern: adds all .jpg, .jpeg, .png and .gif files
 
 $zipFile = new \PhpZip\ZipFile();
 $zipFile->addFilesFromRegex($dir, $regexPattern);
@@ -537,7 +537,7 @@ $zipFile->addFilesFromRegex($dir, $regexPattern, $localPath, \PhpZip\Constants\Z
 ##### ZipFile::addFilesFromRegexRecursive
 Adds files from a directory by [PCRE pattern](https://en.wikipedia.org/wiki/Regular_expression) with subdirectories.
 ```php
-$regexPattern = '/\.(jpe?g|png|gif)$/si'; // example regex pattern -> add all .jpg, .jpeg, .png and .gif files
+$regexPattern = '/\.(jpe?g|png|gif)$/si'; // example regex pattern: adds all .jpg, .jpeg, .png and .gif files
 
 $zipFile->addFilesFromRegexRecursive($dir, $regexPattern);
 
@@ -558,17 +558,17 @@ $zipFile = new \PhpZip\ZipFile();
 $zipFile->deleteFromName($entryName);
 ```
 ##### ZipFile::deleteFromGlob
-Deletes a entries in the archive using [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)).
+Deletes entries in the archive using a [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)).
 ```php
-$globPattern = '**.{jpg,jpeg,png,gif}'; // example glob pattern -> delete all .jpg, .jpeg, .png and .gif files
+$globPattern = '**.{jpg,jpeg,png,gif}'; // example glob pattern: deletes all .jpg, .jpeg, .png and .gif files
 
 $zipFile = new \PhpZip\ZipFile();
 $zipFile->deleteFromGlob($globPattern);
 ```
 ##### ZipFile::deleteFromRegex
-Deletes a entries in the archive using [PCRE pattern](https://en.wikipedia.org/wiki/Regular_expression).
+Deletes entries in the archive using a [PCRE pattern](https://en.wikipedia.org/wiki/Regular_expression).
 ```php
-$regexPattern = '/\.(jpe?g|png|gif)$/si'; // example regex pattern -> delete all .jpg, .jpeg, .png and .gif files
+$regexPattern = '/\.(jpe?g|png|gif)$/si'; // example regex pattern: deletes all .jpg, .jpeg, .png and .gif files
 
 $zipFile = new \PhpZip\ZipFile();
 $zipFile->deleteFromRegex($regexPattern);
@@ -581,7 +581,7 @@ $zipFile->deleteAll();
 ```
 #### Working with entries and archive
 ##### ZipFile::rename
-Renames an entry defined by its name.
+Renames an entry identified by its name.
 ```php
 $zipFile = new \PhpZip\ZipFile();
 $zipFile->rename($oldName, $newName);
@@ -593,7 +593,7 @@ Set the compression level for all files in the archive.
 
 By default, the compression level is 5 (`\PhpZip\Constants\ZipCompressionLevel::NORMAL`) or the compression level specified in the archive for Deflate compression.
 
-The values range from 1 (`\PhpZip\Constants\ZipCompressionLevel::SUPER_FAST`) to 9 (`\PhpZip\Constants\ZipCompressionLevel::MAXIMUM`) are supported. The higher the number, the better and longer the compression.
+Supported values range from 1 (`\PhpZip\Constants\ZipCompressionLevel::SUPER_FAST`) to 9 (`\PhpZip\Constants\ZipCompressionLevel::MAXIMUM`). The higher the number, the better and longer the compression.
 ```php
 $zipFile = new \PhpZip\ZipFile();
 $zipFile->setCompressionLevel(\PhpZip\Constants\ZipCompressionLevel::MAXIMUM);
@@ -601,7 +601,7 @@ $zipFile->setCompressionLevel(\PhpZip\Constants\ZipCompressionLevel::MAXIMUM);
 ##### ZipFile::setCompressionLevelEntry
 Sets the compression level for the entry by its name.
 
-The values range from 1 (`\PhpZip\Constants\ZipCompressionLevel::SUPER_FAST`) to 9 (`\PhpZip\Constants\ZipCompressionLevel::MAXIMUM`) are supported. The higher the number, the better and longer the compression.
+Supported values range from 1 (`\PhpZip\Constants\ZipCompressionLevel::SUPER_FAST`) to 9 (`\PhpZip\Constants\ZipCompressionLevel::MAXIMUM`). The higher the number, the better and longer the compression.
 ```php
 $zipFile = new \PhpZip\ZipFile();
 $zipFile->setCompressionLevelEntry($entryName, \PhpZip\Constants\ZipCompressionLevel::FAST);
@@ -624,7 +624,7 @@ $zipFile = new \PhpZip\ZipFile();
 $zipFile->setArchiveComment($commentArchive);
 ```
 ##### ZipFile::setEntryComment
-Set the comment of an entry defined by its name.
+Sets the comment of an entry identified by its name.
 ```php
 $zipFile = new \PhpZip\ZipFile();
 $zipFile->setEntryComment($entryName, $comment);
@@ -641,7 +641,7 @@ $matcher
     ->add('entry name')
     ->add('another entry');
 ```
-Select multiple files in the archive:
+Selecting multiple files in the archive:
 ```php
 $matcher->add([
     'entry name',
@@ -653,7 +653,7 @@ Selecting files by regular expression:
 ```php
 $matcher->match('~\.jpe?g$~i');
 ```
-Select all files in the archive:
+Selecting all files in the archive:
 ```php
 $matcher->all();
 ```
@@ -668,7 +668,7 @@ getMatches() - returns a list of selected entries:
 $entries = $matcher->getMatches();
 // example array contents: ['entry name', 'another entry name'];
 ```
-invoke() - invoke a callable function on selected entries:
+invoke() - calls a callable function on the selected entries:
 ```php
 // example
 $matcher->invoke(static function($entryName) use($zipFile) {
@@ -676,17 +676,17 @@ $matcher->invoke(static function($entryName) use($zipFile) {
     $zipFile->rename($entryName, $newName);
 });
 ```
-Functions for working on the selected entries:
+Functions for working with the selected entries:
 ```php
-$matcher->delete(); // remove selected entries from a ZIP archive
+$matcher->delete(); // removes the selected entries from a ZIP archive
 $matcher->setPassword($password); // sets a new password for the selected entries
-$matcher->setPassword($password, $encryptionMethod); // sets a new password and encryption method to selected entries
-$matcher->setEncryptionMethod($encryptionMethod); // sets the encryption method to the selected entries
+$matcher->setPassword($password, $encryptionMethod); // sets a new password and encryption method for the selected entries
+$matcher->setEncryptionMethod($encryptionMethod); // sets the encryption method for the selected entries
 $matcher->disableEncryption(); // disables encryption for selected entries
 ```
 #### Working with passwords
 
-Implemented support for encryption methods:
+The following encryption methods are implemented:
 - `\PhpZip\Constants\ZipEncryptionMethod::PKWARE` - Traditional PKWARE encryption (legacy)
 - `\PhpZip\Constants\ZipEncryptionMethod::WINZIP_AES_256` - WinZip AES encryption 256 bit (recommended)
 - `\PhpZip\Constants\ZipEncryptionMethod::WINZIP_AES_192` - WinZip AES encryption 192 bit
@@ -695,12 +695,12 @@ Implemented support for encryption methods:
 ##### ZipFile::setReadPassword
 Set the password for the open archive.
 
-> _Setting a password is not required for adding new entries or deleting existing ones, but if you want to extract the content or change the method / compression level, the encryption method, or change the password, in this case the password must be specified._
+> _Setting a password is not required for adding new entries or deleting existing ones. However, to extract content, or to change the compression level, the encryption method or the password, the password must be specified._
 ```php
 $zipFile->setReadPassword($password);
 ```
 ##### ZipFile::setReadPasswordEntry
-Gets a password for reading of an entry defined by its name.
+Sets a password for reading an entry identified by its name.
 ```php
 $zipFile->setReadPasswordEntry($entryName, $password);
 ```
@@ -717,7 +717,7 @@ $encryptionMethod = \PhpZip\Constants\ZipEncryptionMethod::WINZIP_AES_256;
 $zipFile->setPassword($password, $encryptionMethod);
 ```
 ##### ZipFile::setPasswordEntry
-Sets a new password of an entry defined by its name.
+Sets a new password for an entry identified by its name.
 ```php
 $zipFile->setPasswordEntry($entryName, $password);
 ```
@@ -734,13 +734,13 @@ Disable encryption for all entries that are already in the archive.
 $zipFile->disableEncryption();
 ```
 ##### ZipFile::disableEncryptionEntry
-Disable encryption of an entry defined by its name.
+Disables encryption of an entry identified by its name.
 ```php
 $zipFile->disableEncryptionEntry($entryName);
 ```
 #### Undo changes
 ##### ZipFile::unchangeAll
-Undo all changes done in the archive.
+Undo all changes made to the archive.
 ```php
 $zipFile->unchangeAll();
 ```
@@ -750,7 +750,7 @@ Undo changes to the archive comment.
 $zipFile->unchangeArchiveComment();
 ```
 ##### ZipFile::unchangeEntry
-Undo changes of an entry defined by its name.
+Undo changes to an entry identified by its name.
 ```php
 $zipFile->unchangeEntry($entryName);
 ```
@@ -761,53 +761,53 @@ Saves the archive to a file.
 $zipFile->saveAsFile($filename);
 ```
 ##### ZipFile::saveAsStream
-Writes the archive to the stream.
+Writes the archive to a stream.
 ```php
 // $fp = fopen($filename, 'w+b');
 
 $zipFile->saveAsStream($fp);
 ```
 ##### ZipFile::outputAsString
-Outputs a ZIP-archive as string.
+Outputs a ZIP archive as a string.
 ```php
 $rawZipArchiveBytes = $zipFile->outputAsString();
 ```
 ##### ZipFile::outputAsAttachment
-Outputs a ZIP-archive to the browser.
+Outputs a ZIP archive to the browser.
 ```php
 $zipFile->outputAsAttachment($outputFilename);
 ```
-You can set the Mime-Type:
+You can set the MIME type:
 ```php
 $mimeType = 'application/zip';
 $zipFile->outputAsAttachment($outputFilename, $mimeType);
 ```
 ##### ZipFile::outputAsPsr7Response
-Outputs a ZIP-archive as [PSR-7 Response](http://www.php-fig.org/psr/psr-7/).
+Outputs a ZIP archive as a [PSR-7 Response](http://www.php-fig.org/psr/psr-7/).
 
-The output method can be used in any PSR-7 compatible framework. 
+The output method can be used in any PSR-7-compatible framework.
 ```php
 // $response = ....; // instance Psr\Http\Message\ResponseInterface
 $zipFile->outputAsPsr7Response($response, $outputFilename);
 ```
-You can set the Mime-Type:
+You can set the MIME type:
 ```php
 $mimeType = 'application/zip';
 $zipFile->outputAsPsr7Response($response, $outputFilename, $mimeType);
 ```
 ##### ZipFile::outputAsSymfonyResponse
-Outputs a ZIP-archive as [Symfony Response](https://symfony.com/doc/current/components/http_foundation.html#response).
+Outputs a ZIP archive as a [Symfony Response](https://symfony.com/doc/current/components/http_foundation.html#response).
 
-The output method can be used in Symfony framework. 
+The output method can be used in the Symfony framework.
 ```php
 $response = $zipFile->outputAsSymfonyResponse($outputFilename);
 ```
-You can set the Mime-Type:
+You can set the MIME type:
 ```php
 $mimeType = 'application/zip';
 $response = $zipFile->outputAsSymfonyResponse($outputFilename, $mimeType);
 ```
-Example use in Symfony Controller:
+Example of use in a Symfony controller:
 ```php
 <?php
 
@@ -835,7 +835,7 @@ class DownloadZipController
 }
 ```
 ##### ZipFile::rewrite
-Save changes and re-open the changed archive.
+Save changes and reopen the changed archive.
 ```php
 $zipFile->rewrite();
 ```
@@ -846,7 +846,7 @@ Close the archive.
 $zipFile->close();
 ```
 ### Running the tests
-Install the dependencies for the development:
+Install the development dependencies:
 ```bash
 composer install --dev
 ```
@@ -859,7 +859,7 @@ Changes are documented in the [releases page](https://github.com/Ne-Lexa/php-zip
 
 ### Upgrade
 #### Upgrade version 3 to version 4
-Update the major version in the file `composer.json` to `^4.0`.
+Update the major version in the `composer.json` file to `^4.0`.
 ```json
 {
     "require": {
@@ -874,10 +874,10 @@ composer update nelexa/zip
 Update your code to work with the new version:
 **BC**
 - removed deprecated classes and methods.
-- removed `zipalign` functional. This functionality will be placed in a separate package `nelexa/apkfile`.
+- removed the `zipalign` functionality. This functionality will be placed in a separate package `nelexa/apkfile`.
 
 #### Upgrade version 2 to version 3
-Update the major version in the file `composer.json` to `^3.0`.
+Update the major version in the `composer.json` file to `^3.0`.
 ```json
 {
     "require": {
@@ -890,15 +890,15 @@ Then install updates using `Composer`:
 composer update nelexa/zip
 ```
 Update your code to work with the new version:
-- Class `ZipOutputFile` merged to `ZipFile` and removed.
+- The `ZipOutputFile` class was merged into `ZipFile` and removed.
   + `new \PhpZip\ZipOutputFile()` to `new \PhpZip\ZipFile()`
-- Static initialization methods are now not static.
+- Static initialization methods are no longer static.
   + `\PhpZip\ZipFile::openFromFile($filename);` to `(new \PhpZip\ZipFile())->openFile($filename);`
   + `\PhpZip\ZipOutputFile::openFromFile($filename);` to `(new \PhpZip\ZipFile())->openFile($filename);`
   + `\PhpZip\ZipFile::openFromString($contents);` to `(new \PhpZip\ZipFile())->openFromString($contents);`
   + `\PhpZip\ZipFile::openFromStream($stream);` to `(new \PhpZip\ZipFile())->openFromStream($stream);`
   + `\PhpZip\ZipOutputFile::create()` to `new \PhpZip\ZipFile()`
-  + `\PhpZip\ZipOutputFile::openFromZipFile(\PhpZip\ZipFile $zipFile)` &gt; `(new \PhpZip\ZipFile())->openFile($filename);`
+  + `\PhpZip\ZipOutputFile::openFromZipFile(\PhpZip\ZipFile $zipFile)` to `(new \PhpZip\ZipFile())->openFile($filename);`
 - Rename methods:
   + `addFromFile` to `addFile`
   + `setLevel` to `setCompressionLevel`

+ 2 - 1
src/Constants/ZipPlatform.php

@@ -16,7 +16,7 @@ final class ZipPlatform
     /** @var int MS-DOS OS */
     public const OS_DOS = 0;
 
-    /** @var int Amica OS */
+    /** @var int Amiga OS */
     public const OS_AMIGA = 1;
 
     /** @var int OpenVMS */
@@ -51,6 +51,7 @@ final class ZipPlatform
 
     /** @var int VSE */
     public const OS_VSE = 12;
+
     public const OS_QDOS = 12;
 
     /** @var int Acorn RISC OS */

+ 1 - 1
src/Exception/ZipCryptoException.php

@@ -12,7 +12,7 @@ declare(strict_types=1);
 namespace PhpZip\Exception;
 
 /**
- * Thrown if there is an issue when reading or writing an encrypted ZIP file
+ * Thrown when reading or writing an encrypted ZIP file fails.
  * or entry.
  */
 class ZipCryptoException extends ZipException

+ 2 - 5
src/Exception/ZipEntryNotFoundException.php

@@ -14,19 +14,16 @@ namespace PhpZip\Exception;
 use PhpZip\Model\ZipEntry;
 
 /**
- * Thrown if entry not found.
+ * Thrown when an entry is not found.
  */
 class ZipEntryNotFoundException extends ZipException
 {
     private string $entryName;
 
-    /**
-     * @param ZipEntry|string $entryName
-     */
     public function __construct($entryName)
     {
         $entryName = $entryName instanceof ZipEntry ? $entryName->getName() : $entryName;
-        parent::__construct(sprintf(
+        parent::__construct(\sprintf(
             'Zip Entry "%s" was not found in the archive.',
             $entryName
         ));

+ 2 - 2
src/IO/Filter/Cipher/Pkware/PKCryptContext.php

@@ -26,7 +26,7 @@ class PKCryptContext
     public const STD_DEC_HDR_SIZE = 12;
 
     /**
-     * Crc table.
+     * CRC table.
      *
      * @var int[]|array
      */
@@ -361,7 +361,7 @@ class PKCryptContext
     }
 
     /**
-     * Update crc.
+     * Update the CRC.
      */
     private function crc32(int $oldCrc, int $charAt): int
     {

+ 2 - 1
src/IO/Filter/Cipher/Pkware/PKDecryptionStreamFilter.php

@@ -15,7 +15,7 @@ use PhpZip\Exception\ZipAuthenticationException;
 use PhpZip\Model\ZipEntry;
 
 /**
- * Decryption PKWARE Traditional Encryption.
+ * PKWARE traditional encryption decryption filter.
  */
 class PKDecryptionStreamFilter extends \php_user_filter
 {
@@ -78,6 +78,7 @@ class PKDecryptionStreamFilter extends \php_user_filter
      * Decryption filter.
      *
      * @todo USE FFI in php 7.4
+     *
      * @noinspection PhpDocSignatureInspection
      *
      * @param mixed $in

+ 1 - 1
src/IO/Filter/Cipher/Pkware/PKEncryptionStreamFilter.php

@@ -15,7 +15,7 @@ use PhpZip\Exception\RuntimeException;
 use PhpZip\Model\ZipEntry;
 
 /**
- * Encryption PKWARE Traditional Encryption.
+ * PKWARE traditional encryption filter.
  */
 class PKEncryptionStreamFilter extends \php_user_filter
 {

+ 1 - 1
src/IO/Stream/ResponseStream.php

@@ -14,7 +14,7 @@ namespace PhpZip\IO\Stream;
 use Psr\Http\Message\StreamInterface;
 
 /**
- * Implement PSR Message Stream.
+ * Implements a PSR-7 message stream.
  */
 class ResponseStream implements StreamInterface
 {

+ 16 - 16
src/IO/ZipReader.php

@@ -81,13 +81,13 @@ class ZipReader
                 || (isset($meta['uri']) && is_dir($meta['uri']))
             )
         ) {
-            throw new InvalidArgumentException('Directory stream not supported');
+            throw new InvalidArgumentException('Directory streams are not supported');
         }
 
         $seekable = $meta['seekable'];
 
         if (!$seekable) {
-            throw new InvalidArgumentException('Resource does not support seekable.');
+            throw new InvalidArgumentException('The resource is not seekable.');
         }
         $this->size = fstat($inStream)['size'];
         $this->inStream = $inStream;
@@ -194,7 +194,7 @@ class ZipReader
             && unpack('V', fread($this->inStream, 4))[1] === ZipConstants::ZIP64_END_CD_LOC
         ) {
             if (!$this->isZip64Support()) {
-                throw new ZipException('ZIP64 not supported this archive.');
+                throw new ZipException('ZIP64 is not supported for this archive.');
             }
 
             $positionECD = $this->findZip64ECDPosition();
@@ -297,9 +297,9 @@ class ZipReader
         }
 
         [
-//            'size' => $size,
-//            'versionMadeBy' => $versionMadeBy,
-//            'extractVersion' => $extractVersion,
+            //            'size' => $size,
+            //            'versionMadeBy' => $versionMadeBy,
+            //            'extractVersion' => $extractVersion,
             'diskNo' => $diskNo,
             'cdDiskNo' => $cdDiskNo,
             'cdEntriesDisk' => $cdEntriesDisk,
@@ -612,7 +612,7 @@ class ZipReader
         fseek($this->inStream, $offsetLocalHeader);
 
         if (unpack('V', fread($this->inStream, 4))[1] !== ZipConstants::LOCAL_FILE_HEADER) {
-            throw new ZipException(sprintf('%s (expected Local File Header)', $entry->getName()));
+            throw new ZipException(\sprintf('%s (expected Local File Header)', $entry->getName()));
         }
 
         fseek($this->inStream, $offsetLocalHeader + ZipConstants::LFH_FILENAME_LENGTH_POS);
@@ -647,7 +647,7 @@ class ZipReader
 
                 if ($extraField === null) {
                     throw new ZipException(
-                        sprintf(
+                        \sprintf(
                             'Extra field 0x%04x (WinZip-AES Encryption) expected for compression method %d',
                             WinZipAesExtraField::HEADER_ID,
                             $zipEntry->getCompressionMethod()
@@ -696,7 +696,7 @@ class ZipReader
     public function copyUncompressedDataToStream(ZipSourceFileData $zipFileData, $outStream): void
     {
         if (!\is_resource($outStream)) {
-            throw new InvalidArgumentException('outStream is not resource');
+            throw new InvalidArgumentException('outStream is not a resource');
         }
 
         $entry = $zipFileData->getSourceEntry();
@@ -706,7 +706,7 @@ class ZipReader
 //        }
 
         if ($entry->isStrongEncryption()) {
-            throw new ZipException('Not support encryption zip.');
+            throw new ZipException('Strong encryption is not supported.');
         }
 
         $compressionMethod = $entry->getCompressionMethod();
@@ -720,7 +720,7 @@ class ZipReader
 
         if ($isEncrypted) {
             if ($entry->getPassword() === null) {
-                throw new ZipException('Can not password from entry ' . $entry->getName());
+                throw new ZipException('Cannot get the password for entry ' . $entry->getName());
             }
 
             if (ZipEncryptionMethod::isWinZipAesMethod($entry->getEncryptionMethod())) {
@@ -729,7 +729,7 @@ class ZipReader
 
                 if ($winZipAesExtra === null) {
                     throw new ZipException(
-                        sprintf('WinZip AES must contain the extra field %s', WinZipAesExtraField::HEADER_ID)
+                        \sprintf('WinZip AES must contain the extra field %s', WinZipAesExtraField::HEADER_ID)
                     );
                 }
                 $compressionMethod = $winZipAesExtra->getCompressionMethod();
@@ -796,7 +796,7 @@ class ZipReader
 
             default:
                 throw new ZipException(
-                    sprintf(
+                    \sprintf(
                         '%s (compression method %d (%s) is not supported)',
                         $entry->getName(),
                         $compressionMethod,
@@ -818,7 +818,7 @@ class ZipReader
             set_error_handler(
                 static function (int $errorNumber, string $errorString) use ($entry): bool {
                     throw new ZipException(
-                        sprintf(
+                        \sprintf(
                             'Error reading the contents of entry "%s". %s',
                             $entry->getName(),
                             $errorString
@@ -835,7 +835,7 @@ class ZipReader
                     $buffer = fread($this->inStream, $length);
 
                     if ($buffer === false) {
-                        throw new ZipException(sprintf('Error reading the contents of entry "%s".', $entry->getName()));
+                        throw new ZipException(\sprintf('Error reading the contents of entry "%s".', $entry->getName()));
                     }
                     fwrite($outStream, $buffer);
                     $offset += $length;
@@ -848,7 +848,7 @@ class ZipReader
                     $buffer = fread($this->inStream, $length);
 
                     if ($buffer === false) {
-                        throw new ZipException(sprintf('Error reading the contents of entry "%s".', $entry->getName()));
+                        throw new ZipException(\sprintf('Error reading the contents of entry "%s".', $entry->getName()));
                     }
                     fwrite($outStream, $buffer);
                     hash_update($contextHash, $buffer);

+ 3 - 2
src/Model/Data/ZipNewData.php

@@ -16,7 +16,7 @@ use PhpZip\Model\ZipEntry;
 use PhpZip\ZipFile;
 
 /**
- * The class contains a streaming resource with new content added to the ZIP archive.
+ * Holds a stream resource with new content to be added to the ZIP archive.
  */
 class ZipNewData implements ZipData
 {
@@ -35,6 +35,7 @@ class ZipNewData implements ZipData
 
     /**
      * @param string|resource $data Raw string data or resource
+     *
      * @noinspection PhpMissingParamTypeInspection
      */
     public function __construct(ZipEntry $zipEntry, $data)
@@ -69,7 +70,7 @@ class ZipNewData implements ZipData
     public function getDataAsStream()
     {
         if (!\is_resource($this->stream)) {
-            throw new \LogicException(sprintf('Resource has been closed (entry=%s).', $this->zipEntry->getName()));
+            throw new \LogicException(\sprintf('Resource has been closed (entry=%s).', $this->zipEntry->getName()));
         }
 
         return $this->stream;

+ 2 - 2
src/Model/Extra/Fields/AbstractUnicodeExtraField.php

@@ -16,7 +16,7 @@ use PhpZip\Model\Extra\ZipExtraField;
 use PhpZip\Model\ZipEntry;
 
 /**
- * A common base class for Unicode extra information extra fields.
+ * A common base class for the Info-ZIP Unicode path and comment extra fields.
  */
 abstract class AbstractUnicodeExtraField implements ZipExtraField
 {
@@ -81,7 +81,7 @@ abstract class AbstractUnicodeExtraField implements ZipExtraField
         ] = unpack('Cversion/Vcrc32', $buffer);
 
         if ($version !== self::DEFAULT_VERSION) {
-            throw new ZipException(sprintf('Unsupported version [%d] for Unicode path extra data.', $version));
+            throw new ZipException(\sprintf('Unsupported version [%d] for Unicode path extra data.', $version));
         }
 
         $unicodeValue = substr($buffer, 5);

+ 2 - 6
src/Model/Extra/Fields/AsiExtraField.php

@@ -103,8 +103,6 @@ final class AsiExtraField implements ZipExtraField
      * @param ZipEntry|null $entry  optional zip entry
      *
      * @throws Crc32Exception
-     *
-     * @return AsiExtraField
      */
     public static function unpackLocalFileData(string $buffer, ?ZipEntry $entry = null): self
     {
@@ -113,7 +111,7 @@ final class AsiExtraField implements ZipExtraField
         $realChecksum = crc32($buffer);
 
         if ($givenChecksum !== $realChecksum) {
-            throw new Crc32Exception('Asi Unix Extra Filed Data', $givenChecksum, $realChecksum);
+            throw new Crc32Exception('Asi Unix Extra Field Data', $givenChecksum, $realChecksum);
         }
 
         [
@@ -138,8 +136,6 @@ final class AsiExtraField implements ZipExtraField
      * @param ZipEntry|null $entry  optional zip entry
      *
      * @throws Crc32Exception
-     *
-     * @return AsiExtraField
      */
     public static function unpackCentralDirData(string $buffer, ?ZipEntry $entry = null): self
     {
@@ -273,7 +269,7 @@ final class AsiExtraField implements ZipExtraField
 
     public function __toString(): string
     {
-        return sprintf(
+        return \sprintf(
             '0x%04x ASI: Mode=%o UID=%d GID=%d Link="%s',
             self::HEADER_ID,
             $this->mode,

+ 1 - 12
src/Model/Extra/Fields/ExtendedTimestampExtraField.php

@@ -119,13 +119,6 @@ final class ExtendedTimestampExtraField implements ZipExtraField
         $this->createTime = $createTime;
     }
 
-    /**
-     * @param ?int $modifyTime
-     * @param ?int $accessTime
-     * @param ?int $createTime
-     *
-     * @return ExtendedTimestampExtraField
-     */
     public static function create(?int $modifyTime, ?int $accessTime, ?int $createTime): self
     {
         $flags = 0;
@@ -160,8 +153,6 @@ final class ExtendedTimestampExtraField implements ZipExtraField
      *
      * @param string        $buffer the buffer to read data from
      * @param ZipEntry|null $entry  optional zip entry
-     *
-     * @return ExtendedTimestampExtraField
      */
     public static function unpackLocalFileData(string $buffer, ?ZipEntry $entry = null): self
     {
@@ -197,8 +188,6 @@ final class ExtendedTimestampExtraField implements ZipExtraField
      *
      * @param string        $buffer the buffer to read data from
      * @param ZipEntry|null $entry  optional zip entry
-     *
-     * @return ExtendedTimestampExtraField
      */
     public static function unpackCentralDirData(string $buffer, ?ZipEntry $entry = null): self
     {
@@ -331,7 +320,7 @@ final class ExtendedTimestampExtraField implements ZipExtraField
     }
 
     /**
-     * Returns the create time as a a \DateTimeInterface
+     * Returns the create time as a \DateTimeInterface
      * of this zip entry, or null if no such timestamp exists in the zip entry.
      * The milliseconds are always zeroed out, since the underlying data
      * offers only per-second precision.

+ 2 - 9
src/Model/Extra/Fields/NtfsExtraField.php

@@ -56,9 +56,6 @@ final class NtfsExtraField implements ZipExtraField
         $this->createNtfsTime = $createNtfsTime;
     }
 
-    /**
-     * @return NtfsExtraField
-     */
     public static function create(
         \DateTimeInterface $modifyDateTime,
         \DateTimeInterface $accessDateTime,
@@ -88,13 +85,11 @@ final class NtfsExtraField implements ZipExtraField
      * @param ZipEntry|null $entry  optional zip entry
      *
      * @throws ZipException
-     *
-     * @return NtfsExtraField
      */
     public static function unpackLocalFileData(string $buffer, ?ZipEntry $entry = null): self
     {
         if (\PHP_INT_SIZE === 4) {
-            throw new ZipException('not supported for php-32bit');
+            throw new ZipException('NTFS timestamps are not supported in 32-bit PHP.');
         }
 
         $buffer = substr($buffer, 4);
@@ -131,8 +126,6 @@ final class NtfsExtraField implements ZipExtraField
      * @param ZipEntry|null $entry  optional zip entry
      *
      * @throws ZipException
-     *
-     * @return NtfsExtraField
      */
     public static function unpackCentralDirData(string $buffer, ?ZipEntry $entry = null): self
     {
@@ -253,7 +246,7 @@ final class NtfsExtraField implements ZipExtraField
     public static function ntfsTimeToDateTime(int $ntfsTime): \DateTimeInterface
     {
         $timestamp = self::ntfsTimeToTimestamp($ntfsTime);
-        $dateTime = \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6f', $timestamp));
+        $dateTime = \DateTimeImmutable::createFromFormat('U.u', \sprintf('%.6f', $timestamp));
 
         if ($dateTime === false) {
             throw new InvalidArgumentException('Cannot create date/time object for timestamp ' . $timestamp);

+ 2 - 6
src/Model/Extra/Fields/UnrecognizedExtraField.php

@@ -51,12 +51,10 @@ final class UnrecognizedExtraField implements ZipExtraField
      *
      * @param string        $buffer the buffer to read data from
      * @param ZipEntry|null $entry  optional zip entry
-     *
-     * @return UnrecognizedExtraField
      */
     public static function unpackLocalFileData(string $buffer, ?ZipEntry $entry = null): self
     {
-        throw new RuntimeException('Unsupport parse');
+        throw new RuntimeException('Parsing is not supported for unrecognized extra fields.');
     }
 
     /**
@@ -64,12 +62,10 @@ final class UnrecognizedExtraField implements ZipExtraField
      *
      * @param string        $buffer the buffer to read data from
      * @param ZipEntry|null $entry  optional zip entry
-     *
-     * @return UnrecognizedExtraField
      */
     public static function unpackCentralDirData(string $buffer, ?ZipEntry $entry = null): self
     {
-        throw new RuntimeException('Unsupport parse');
+        throw new RuntimeException('Parsing is not supported for unrecognized extra fields.');
     }
 
     /**

+ 10 - 18
src/Model/Extra/Fields/WinZipAesExtraField.php

@@ -107,15 +107,13 @@ final class WinZipAesExtraField implements ZipExtraField
 
     /**
      * @throws ZipUnsupportMethodException
-     *
-     * @return WinZipAesExtraField
      */
     public static function create(ZipEntry $entry): self
     {
         $keyStrength = array_search($entry->getEncryptionMethod(), self::MAP_KEY_STRENGTH_METHODS, true);
 
         if ($keyStrength === false) {
-            throw new InvalidArgumentException('Not support encryption method ' . $entry->getEncryptionMethod());
+            throw new InvalidArgumentException('Unsupported encryption method ' . $entry->getEncryptionMethod());
         }
 
         // WinZip 11 will continue to use AE-2, with no CRC, for very small files
@@ -152,12 +150,9 @@ final class WinZipAesExtraField implements ZipExtraField
     /**
      * Populate data from this array as if it was in local file data.
      *
-     * @param string    $buffer the buffer to read data from
-     * @param ?ZipEntry $entry
+     * @param string $buffer the buffer to read data from
      *
      * @throws ZipException on error
-     *
-     * @return WinZipAesExtraField
      */
     public static function unpackLocalFileData(string $buffer, ?ZipEntry $entry = null): self
     {
@@ -165,7 +160,7 @@ final class WinZipAesExtraField implements ZipExtraField
 
         if ($size !== self::DATA_SIZE) {
             throw new ZipException(
-                sprintf(
+                \sprintf(
                     'WinZip AES Extra data invalid size: %d. Must be %d',
                     $size,
                     self::DATA_SIZE
@@ -182,7 +177,7 @@ final class WinZipAesExtraField implements ZipExtraField
 
         if ($vendorId !== self::VENDOR_ID) {
             throw new ZipException(
-                sprintf(
+                \sprintf(
                     'Vendor id invalid: %d. Must be %d',
                     $vendorId,
                     self::VENDOR_ID
@@ -196,12 +191,9 @@ final class WinZipAesExtraField implements ZipExtraField
     /**
      * Populate data from this array as if it was in central directory data.
      *
-     * @param string    $buffer the buffer to read data from
-     * @param ?ZipEntry $entry
+     * @param string $buffer the buffer to read data from
      *
      * @throws ZipException
-     *
-     * @return WinZipAesExtraField
      */
     public static function unpackCentralDirData(string $buffer, ?ZipEntry $entry = null): self
     {
@@ -259,8 +251,8 @@ final class WinZipAesExtraField implements ZipExtraField
     {
         if (!\in_array($vendorVersion, self::ALLOW_VENDOR_VERSIONS, true)) {
             throw new InvalidArgumentException(
-                sprintf(
-                    'Unsupport WinZip AES vendor version: %d',
+                \sprintf(
+                    'Unsupported WinZip AES vendor version: %d',
                     $vendorVersion
                 )
             );
@@ -288,8 +280,8 @@ final class WinZipAesExtraField implements ZipExtraField
     {
         if (!isset(self::ENCRYPTION_STRENGTHS[$keyStrength])) {
             throw new InvalidArgumentException(
-                sprintf(
-                    'Key strength %d not support value. Allow values: %s',
+                \sprintf(
+                    'Invalid key strength %d. Allowed values: %s',
                     $keyStrength,
                     implode(', ', array_keys(self::ENCRYPTION_STRENGTHS))
                 )
@@ -345,7 +337,7 @@ final class WinZipAesExtraField implements ZipExtraField
 
     public function __toString(): string
     {
-        return sprintf(
+        return \sprintf(
             '0x%04x WINZIP AES: VendorVersion=%d KeyStrength=0x%02x CompressionMethod=%s',
             __CLASS__,
             $this->vendorVersion,

+ 10 - 23
src/Model/ZipContainer.php

@@ -54,9 +54,6 @@ class ZipContainer extends ImmutableZipContainer
         $this->entries[$entry->getName()] = $entry;
     }
 
-    /**
-     * @param string|ZipEntry $entry
-     */
     public function deleteEntry($entry): bool
     {
         $entry = $entry instanceof ZipEntry ? $entry->getName() : (string) $entry;
@@ -71,8 +68,8 @@ class ZipContainer extends ImmutableZipContainer
     }
 
     /**
-     * @param string|ZipEntry $old
-     * @param string|ZipEntry $new
+     * @param mixed $old
+     * @param mixed $new
      *
      * @throws ZipException
      *
@@ -84,7 +81,7 @@ class ZipContainer extends ImmutableZipContainer
         $new = $new instanceof ZipEntry ? $new->getName() : (string) $new;
 
         if (isset($this->entries[$new])) {
-            throw new InvalidArgumentException('New entry name ' . $new . ' is exists.');
+            throw new InvalidArgumentException('New entry name "' . $new . '" already exists.');
         }
 
         $entry = $this->getEntry($old);
@@ -97,7 +94,7 @@ class ZipContainer extends ImmutableZipContainer
     }
 
     /**
-     * @param string|ZipEntry $entryName
+     * @param mixed $entryName
      *
      * @throws ZipEntryNotFoundException
      */
@@ -112,9 +109,6 @@ class ZipContainer extends ImmutableZipContainer
         throw new ZipEntryNotFoundException($entryName);
     }
 
-    /**
-     * @param string|ZipEntry $entryName
-     */
     public function getEntryOrNull($entryName): ?ZipEntry
     {
         $entryName = $entryName instanceof ZipEntry ? $entryName->getName() : (string) $entryName;
@@ -122,9 +116,6 @@ class ZipContainer extends ImmutableZipContainer
         return $this->entries[$entryName] ?? null;
     }
 
-    /**
-     * @param string|ZipEntry $entryName
-     */
     public function hasEntry($entryName): bool
     {
         $entryName = $entryName instanceof ZipEntry ? $entryName->getName() : (string) $entryName;
@@ -170,7 +161,7 @@ class ZipContainer extends ImmutableZipContainer
     }
 
     /**
-     * Undo all changes done in the archive.
+     * Undo all changes made to the archive.
      */
     public function unchangeAll(): void
     {
@@ -197,7 +188,7 @@ class ZipContainer extends ImmutableZipContainer
     }
 
     /**
-     * Revert all changes done to an entry with the given name.
+     * Revert all changes made to an entry with the given name.
      *
      * @param string|ZipEntry $entry Entry name or ZipEntry
      */
@@ -218,7 +209,7 @@ class ZipContainer extends ImmutableZipContainer
     }
 
     /**
-     * Entries sort by name.
+     * Sort entries by name using the given comparison function.
      *
      * Example:
      * ```php
@@ -233,7 +224,7 @@ class ZipContainer extends ImmutableZipContainer
     }
 
     /**
-     * Entries sort by entry.
+     * Sort entries using the given comparison function.
      *
      * Example:
      * ```php
@@ -253,7 +244,7 @@ class ZipContainer extends ImmutableZipContainer
             $length = \strlen($archiveComment);
 
             if ($length > 0xFFFF) {
-                throw new InvalidArgumentException('Length comment out of range');
+                throw new InvalidArgumentException('Comment length out of range');
             }
         }
         $this->archiveComment = $archiveComment;
@@ -266,8 +257,6 @@ class ZipContainer extends ImmutableZipContainer
 
     /**
      * Specify a password for extracting files.
-     *
-     * @param ?string $password
      */
     public function setReadPassword(?string $password): void
     {
@@ -296,8 +285,6 @@ class ZipContainer extends ImmutableZipContainer
     }
 
     /**
-     * @param ?string $writePassword
-     *
      * @throws ZipEntryNotFoundException
      */
     public function setWritePassword(?string $writePassword): void
@@ -316,7 +303,7 @@ class ZipContainer extends ImmutableZipContainer
     }
 
     /**
-     * @param string|ZipEntry $entryName
+     * @param mixed $entryName
      *
      * @throws ZipEntryNotFoundException
      */

+ 9 - 80
src/Model/ZipEntry.php

@@ -94,14 +94,14 @@ class ZipEntry
     private int $localHeaderOffset = 0;
 
     /**
-     * Collections of Extra Fields in Central Directory.
+     * Collections of extra fields in the central directory.
      * Keys from Header ID [int] and value Extra Field [ExtraField].
      */
     protected ExtraFieldsCollection $cdExtraFields;
 
     /**
-     * Collections of Extra Fields int local header.
-     * Keys from Header ID [int] and value Extra Field [ExtraField].
+     * Collections of extra fields in the local header.
+     * Keys are header IDs [int] and values are extra fields [ExtraField].
      */
     protected ExtraFieldsCollection $localExtraFields;
 
@@ -133,16 +133,11 @@ class ZipEntry
     }
 
     /**
-     * This method only internal use.
+     * This method is for internal use only.
      *
      * @internal
      *
      * @noinspection PhpTooManyParametersInspection
-     *
-     * @param ?string $comment
-     * @param ?string $charset
-     *
-     * @return ZipEntry
      */
     public static function create(
         string $name,
@@ -188,8 +183,6 @@ class ZipEntry
      *
      * @param string      $name    New entry name
      * @param string|null $charset Entry name charset
-     *
-     * @return ZipEntry
      */
     private function setName(string $name, ?string $charset = null): self
     {
@@ -228,10 +221,6 @@ class ZipEntry
 
     /**
      * @see DosCodePage::getCodePages()
-     *
-     * @param ?string $charset
-     *
-     * @return ZipEntry
      */
     public function setCharset(?string $charset = null): self
     {
@@ -293,8 +282,6 @@ class ZipEntry
 
     /**
      * Set platform.
-     *
-     * @return ZipEntry
      */
     public function setCreatedOS(int $platform): self
     {
@@ -313,8 +300,6 @@ class ZipEntry
 
     /**
      * Set extracted OS.
-     *
-     * @return ZipEntry
      */
     public function setExtractedOS(int $platform): self
     {
@@ -335,9 +320,6 @@ class ZipEntry
         return $this->softwareVersion;
     }
 
-    /**
-     * @return ZipEntry
-     */
     public function setSoftwareVersion(int $softwareVersion): self
     {
         $this->softwareVersion = $softwareVersion;
@@ -379,8 +361,6 @@ class ZipEntry
 
     /**
      * Set version needed to extract.
-     *
-     * @return ZipEntry
      */
     public function setExtractVersion(int $version): self
     {
@@ -402,8 +382,6 @@ class ZipEntry
      *
      * @param int $compressedSize the Compressed Size
      *
-     * @return ZipEntry
-     *
      * @internal
      */
     public function setCompressedSize(int $compressedSize): self
@@ -429,8 +407,6 @@ class ZipEntry
      *
      * @param int $uncompressedSize the (Uncompressed) Size
      *
-     * @return ZipEntry
-     *
      * @internal
      */
     public function setUncompressedSize(int $uncompressedSize): self
@@ -452,8 +428,6 @@ class ZipEntry
     }
 
     /**
-     * @return ZipEntry
-     *
      * @internal
      */
     public function setLocalHeaderOffset(int $localHeaderOffset): self
@@ -479,8 +453,6 @@ class ZipEntry
      *
      * @param int $gpbf general purpose bit flags
      *
-     * @return ZipEntry
-     *
      * @internal
      */
     public function setGeneralPurposeBitFlags(int $gpbf): self
@@ -512,9 +484,6 @@ class ZipEntry
         }
     }
 
-    /**
-     * @return ZipEntry
-     */
     private function setGeneralBitFlag(int $mask, bool $enable): self
     {
         if ($enable) {
@@ -570,8 +539,6 @@ class ZipEntry
     /**
      * Sets the encryption property to false and removes any other
      * encryption artifacts.
-     *
-     * @return ZipEntry
      */
     public function disableEncryption(): self
     {
@@ -586,8 +553,6 @@ class ZipEntry
 
     /**
      * Sets the encryption flag for this ZIP entry.
-     *
-     * @return ZipEntry
      */
     private function setEncrypted(bool $encrypted): self
     {
@@ -609,8 +574,6 @@ class ZipEntry
      *
      * @throws ZipUnsupportMethodException
      *
-     * @return ZipEntry
-     *
      * @see ZipCompressionMethod::STORED
      * @see ZipCompressionMethod::DEFLATED
      * @see ZipCompressionMethod::BZIP2
@@ -652,8 +615,6 @@ class ZipEntry
 
     /**
      * Set Dos Time.
-     *
-     * @return ZipEntry
      */
     public function setDosTime(int $dosTime): self
     {
@@ -670,8 +631,6 @@ class ZipEntry
 
     /**
      * Set time from unix timestamp.
-     *
-     * @return ZipEntry
      */
     public function setTime(int $unixTimestamp): self
     {
@@ -698,8 +657,6 @@ class ZipEntry
      * Sets the external file attributes.
      *
      * @param int $externalAttributes the external file attributes
-     *
-     * @return ZipEntry
      */
     public function setExternalAttributes(int $externalAttributes): self
     {
@@ -730,8 +687,6 @@ class ZipEntry
      * Sets the internal file attributes.
      *
      * @param int $internalAttributes the internal file attributes
-     *
-     * @return ZipEntry
      */
     public function setInternalAttributes(int $internalAttributes): self
     {
@@ -762,9 +717,6 @@ class ZipEntry
         return $this->cdExtraFields->get($headerId);
     }
 
-    /**
-     * @return ZipEntry
-     */
     public function setCdExtraFields(ExtraFieldsCollection $cdExtraFields): self
     {
         $this->cdExtraFields = $cdExtraFields;
@@ -782,9 +734,6 @@ class ZipEntry
         return $this->localExtraFields[$headerId];
     }
 
-    /**
-     * @return ZipEntry
-     */
     public function setLocalExtraFields(ExtraFieldsCollection $localExtraFields): self
     {
         $this->localExtraFields = $localExtraFields;
@@ -837,10 +786,6 @@ class ZipEntry
 
     /**
      * Set entry comment.
-     *
-     * @param ?string $comment
-     *
-     * @return ZipEntry
      */
     public function setComment(?string $comment): self
     {
@@ -866,7 +811,7 @@ class ZipEntry
     }
 
     /**
-     * Return crc32 content or 0 for WinZip AES v2.
+     * Returns the CRC32 of the content, or 0 for WinZip AES v2.
      */
     public function getCrc(): int
     {
@@ -876,8 +821,6 @@ class ZipEntry
     /**
      * Set crc32 content.
      *
-     * @return ZipEntry
-     *
      * @internal
      */
     public function setCrc(int $crc): self
@@ -894,11 +837,6 @@ class ZipEntry
 
     /**
      * Set password and encryption method from entry.
-     *
-     * @param ?string $password
-     * @param ?int    $encryptionMethod
-     *
-     * @return ZipEntry
      */
     public function setPassword(?string $password, ?int $encryptionMethod = null): self
     {
@@ -936,10 +874,6 @@ class ZipEntry
      * @see ZipEncryptionMethod::WINZIP_AES_256
      * @see ZipEncryptionMethod::WINZIP_AES_192
      * @see ZipEncryptionMethod::WINZIP_AES_128
-     *
-     * @param ?int $encryptionMethod
-     *
-     * @return ZipEntry
      */
     public function setEncryptionMethod(?int $encryptionMethod): self
     {
@@ -959,9 +893,6 @@ class ZipEntry
         return $this->compressionLevel;
     }
 
-    /**
-     * @return ZipEntry
-     */
     public function setCompressionLevel(int $compressionLevel): self
     {
         if ($compressionLevel === self::UNKNOWN) {
@@ -985,7 +916,7 @@ class ZipEntry
     }
 
     /**
-     * Update general purpose bit flogs.
+     * Update the general purpose bit flags.
      */
     private function updateGbpfCompLevel(): void
     {
@@ -1006,7 +937,7 @@ class ZipEntry
                     $bit1 = true;
                     $bit2 = true;
                     break;
-                // default is ZipCompressionLevel::NORMAL
+                    // default is ZipCompressionLevel::NORMAL
             }
 
             $this->generalPurposeBitFlags |= ($bit1 ? GeneralPurposeBitFlag::COMPRESSION_FLAG1 : 0);
@@ -1019,8 +950,6 @@ class ZipEntry
      * unzip command.
      *
      * @param int $mode mode an int value
-     *
-     * @return ZipEntry
      */
     public function setUnixMode(int $mode): self
     {
@@ -1037,7 +966,7 @@ class ZipEntry
     }
 
     /**
-     * Unix permission.
+     * Unix permissions.
      *
      * @return int the unix permissions
      */
@@ -1111,7 +1040,7 @@ class ZipEntry
         try {
             return new \DateTimeImmutable('@' . $timestamp);
         } catch (\Exception $e) {
-            throw new RuntimeException('Error create DateTime object with timestamp ' . $timestamp, 1, $e);
+            throw new RuntimeException('Cannot create a DateTime object for timestamp ' . $timestamp, 1, $e);
         }
     }
 

+ 2 - 15
src/Model/ZipEntryMatcher.php

@@ -26,8 +26,6 @@ class ZipEntryMatcher implements \Countable
 
     /**
      * @param string|ZipEntry|string[]|ZipEntry[] $entries
-     *
-     * @return ZipEntryMatcher
      */
     public function add($entries): self
     {
@@ -57,7 +55,6 @@ class ZipEntryMatcher implements \Countable
     }
 
     /**
-     * @return ZipEntryMatcher
      * @noinspection PhpUnusedParameterInspection
      */
     public function match(string $regexp): self
@@ -75,9 +72,6 @@ class ZipEntryMatcher implements \Countable
         return $this;
     }
 
-    /**
-     * @return ZipEntryMatcher
-     */
     public function all(): self
     {
         $this->matches = array_map(
@@ -89,17 +83,16 @@ class ZipEntryMatcher implements \Countable
     }
 
     /**
-     * Callable function for all select entries.
+     * Call a function for all selected entries.
      *
      * Callable function signature:
-     * function(string $entryName){}
+     * function (string $entryName): void
      */
     public function invoke(callable $callable): void
     {
         if (!empty($this->matches)) {
             array_walk(
                 $this->matches,
-                /** @param string $entryName */
                 static function (string $entryName) use ($callable): void {
                     $callable($entryName);
                 }
@@ -116,7 +109,6 @@ class ZipEntryMatcher implements \Countable
     {
         array_walk(
             $this->matches,
-            /** @param string $entryName */
             function (string $entryName): void {
                 $this->zipContainer->deleteEntry($entryName);
             }
@@ -125,16 +117,12 @@ class ZipEntryMatcher implements \Countable
     }
 
     /**
-     * @param ?string $password
-     * @param ?int    $encryptionMethod
-     *
      * @throws ZipEntryNotFoundException
      */
     public function setPassword(?string $password, ?int $encryptionMethod = null): void
     {
         array_walk(
             $this->matches,
-            /** @param string $entryName */
             function (string $entryName) use ($password, $encryptionMethod): void {
                 $entry = $this->zipContainer->getEntry($entryName);
 
@@ -152,7 +140,6 @@ class ZipEntryMatcher implements \Countable
     {
         array_walk(
             $this->matches,
-            /** @param string $entryName */
             function (string $entryName) use ($encryptionMethod): void {
                 $entry = $this->zipContainer->getEntry($entryName);
 

+ 1 - 1
src/Util/MathUtil.php

@@ -19,7 +19,7 @@ namespace PhpZip\Util;
 final class MathUtil
 {
     /**
-     * Cast to signed int 32-bit.
+     * Cast to a signed 32-bit integer.
      */
     public static function toSignedInt32(int $int): int
     {

+ 29 - 116
src/ZipFile.php

@@ -92,8 +92,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      * Open zip archive from file.
      *
      * @throws ZipException if can't open file
-     *
-     * @return ZipFile
      */
     public function openFile(string $filename, array $options = []): self
     {
@@ -117,8 +115,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      * Open zip archive from raw string data.
      *
      * @throws ZipException if can't open temp stream
-     *
-     * @return ZipFile
      */
     public function openFromString(string $data, array $options = []): self
     {
@@ -143,8 +139,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      * @param resource $handle
      *
      * @throws ZipException
-     *
-     * @return ZipFile
      */
     public function openFromStream($handle, array $options = []): self
     {
@@ -183,10 +177,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
 
     /**
      * Set archive comment.
-     *
-     * @param ?string $comment
-     *
-     * @return ZipFile
      */
     public function setArchiveComment(?string $comment = null): self
     {
@@ -239,12 +229,8 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
     /**
      * Set entry comment.
      *
-     * @param ?string $comment
-     *
      * @throws ZipEntryNotFoundException
      * @throws ZipException
-     *
-     * @return ZipFile
      */
     public function setEntryComment(string $entryName, ?string $comment = null): self
     {
@@ -264,7 +250,7 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
         $zipData = $this->zipContainer->getEntry($entryName)->getData();
 
         if ($zipData === null) {
-            throw new ZipException(sprintf('No data for zip entry %s', $entryName));
+            throw new ZipException(\sprintf('No data for zip entry %s', $entryName));
         }
 
         return $zipData->getDataAsString();
@@ -290,7 +276,7 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
     }
 
     /**
-     * Returns an array of zip records (ex. for modify time).
+     * Returns an array of zip entries (e.g. for inspecting modification times).
      *
      * @return ZipEntry[] array of raw zip entries
      */
@@ -312,8 +298,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      *                                     information about the extracted entries
      *
      * @throws ZipException
-     *
-     * @return ZipFile
      */
     public function extractTo(
         string $destDir,
@@ -322,15 +306,15 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
         ?array &$extractedEntries = []
     ): self {
         if (!file_exists($destDir)) {
-            throw new ZipException(sprintf('Destination %s not found', $destDir));
+            throw new ZipException(\sprintf('Destination %s not found', $destDir));
         }
 
         if (!is_dir($destDir)) {
-            throw new ZipException('Destination is not directory');
+            throw new ZipException('Destination is not a directory');
         }
 
         if (!is_writable($destDir)) {
-            throw new ZipException('Destination is not writable directory');
+            throw new ZipException('Destination is not a writable directory');
         }
 
         if ($extractedEntries === null) {
@@ -389,7 +373,7 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
 
                 if (!mkdir($dir, $dirMode, true) && !is_dir($dir)) {
                     // @codeCoverageIgnoreStart
-                    throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir));
+                    throw new \RuntimeException(\sprintf('Directory "%s" was not created', $dir));
                     // @codeCoverageIgnoreEnd
                 }
                 chmod($dir, $dirMode);
@@ -428,7 +412,7 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
             set_error_handler(
                 static function (int $errorNumber, string $errorString) use ($entry, $file): ?bool {
                     throw new ZipException(
-                        sprintf(
+                        \sprintf(
                             'Cannot extract zip entry %s. File %s cannot open for write. %s',
                             $entry->getName(),
                             $file,
@@ -508,8 +492,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      *                                    If null, then auto choosing method.
      *
      * @throws ZipException
-     *
-     * @return ZipFile
      */
     public function addFromString(string $entryName, string $contents, ?int $compressionMethod = null): self
     {
@@ -589,8 +571,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
     }
 
     /**
-     * @param ?string $entryName
-     *
      * @throws ZipException
      */
     public function addSplFile(\SplFileInfo $file, ?string $entryName = null, array $options = []): ZipEntry
@@ -606,7 +586,7 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
         $options += $defaultOptions;
 
         if (!$file->isReadable()) {
-            throw new InvalidArgumentException(sprintf('File %s is not readable', $file->getPathname()));
+            throw new InvalidArgumentException(\sprintf('File %s is not readable', $file->getPathname()));
         }
 
         if ($entryName === null) {
@@ -708,8 +688,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      *                                       If null, then auto choosing method.
      *
      * @throws ZipException
-     *
-     * @return ZipFile
      */
     public function addFile(string $filename, ?string $entryName = null, ?int $compressionMethod = null): self
     {
@@ -736,13 +714,11 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      *                                    If null, then auto choosing method.
      *
      * @throws ZipException
-     *
-     * @return ZipFile
      */
     public function addFromStream($stream, string $entryName, ?int $compressionMethod = null): self
     {
         if (!\is_resource($stream)) {
-            throw new InvalidArgumentException('Stream is not resource');
+            throw new InvalidArgumentException('Stream is not a resource');
         }
 
         $entryName = $this->normalizeEntryName($entryName);
@@ -791,8 +767,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      * Add an empty directory in the zip archive.
      *
      * @throws ZipException
-     *
-     * @return ZipFile
      */
     public function addEmptyDir(string $dirName): self
     {
@@ -815,7 +789,7 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
     }
 
     /**
-     * Add directory not recursively to the zip archive.
+     * Add a directory to the zip archive without recursion.
      *
      * @param string   $inputDir          Input directory
      * @param string   $localPath         add files to this directory, or the root
@@ -826,8 +800,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      *                                    If null, then auto choosing method.
      *
      * @throws ZipException
-     *
-     * @return ZipFile
      */
     public function addDir(string $inputDir, string $localPath = '/', ?int $compressionMethod = null): self
     {
@@ -836,7 +808,7 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
         }
 
         if (!is_dir($inputDir)) {
-            throw new InvalidArgumentException(sprintf('The "%s" directory does not exist.', $inputDir));
+            throw new InvalidArgumentException(\sprintf('The "%s" directory does not exist.', $inputDir));
         }
         $inputDir = rtrim($inputDir, '/\\') . \DIRECTORY_SEPARATOR;
 
@@ -846,7 +818,7 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
     }
 
     /**
-     * Add recursive directory to the zip archive.
+     * Add a directory recursively to the zip archive.
      *
      * @param string   $inputDir          Input directory
      * @param string   $localPath         add files to this directory, or the root
@@ -858,8 +830,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      *
      * @throws ZipException
      *
-     * @return ZipFile
-     *
      * @see ZipCompressionMethod::STORED
      * @see ZipCompressionMethod::DEFLATED
      * @see ZipCompressionMethod::BZIP2
@@ -871,7 +841,7 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
         }
 
         if (!is_dir($inputDir)) {
-            throw new InvalidArgumentException(sprintf('The "%s" directory does not exist.', $inputDir));
+            throw new InvalidArgumentException(\sprintf('The "%s" directory does not exist.', $inputDir));
         }
         $inputDir = rtrim($inputDir, '/\\') . \DIRECTORY_SEPARATOR;
 
@@ -893,8 +863,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      *
      * @throws ZipException
      *
-     * @return ZipFile
-     *
      * @see ZipCompressionMethod::STORED
      * @see ZipCompressionMethod::DEFLATED
      * @see ZipCompressionMethod::BZIP2
@@ -959,7 +927,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      *
      * @throws ZipException
      *
-     * @return ZipFile
      * @sse https://en.wikipedia.org/wiki/Glob_(programming) Glob pattern syntax
      */
     public function addFilesFromGlob(
@@ -986,8 +953,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      *
      * @throws ZipException
      *
-     * @return ZipFile
-     *
      * @sse https://en.wikipedia.org/wiki/Glob_(programming) Glob pattern syntax
      */
     private function addGlob(
@@ -1002,7 +967,7 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
         }
 
         if (!is_dir($inputDir)) {
-            throw new InvalidArgumentException(sprintf('The "%s" directory does not exist.', $inputDir));
+            throw new InvalidArgumentException(\sprintf('The "%s" directory does not exist.', $inputDir));
         }
 
         if (empty($globPattern)) {
@@ -1037,7 +1002,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      *
      * @throws ZipException
      *
-     * @return ZipFile
      * @sse https://en.wikipedia.org/wiki/Glob_(programming) Glob pattern syntax
      */
     public function addFilesFromGlobRecursive(
@@ -1063,8 +1027,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      *
      * @throws ZipException
      *
-     * @return ZipFile
-     *
      * @internal param bool $recursive Recursive search
      */
     public function addFilesFromRegex(
@@ -1090,8 +1052,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      *                                    If null, then auto choosing method.
      *
      * @throws ZipException
-     *
-     * @return ZipFile
      */
     private function addRegex(
         string $inputDir,
@@ -1109,7 +1069,7 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
         }
 
         if (!is_dir($inputDir)) {
-            throw new InvalidArgumentException(sprintf('The "%s" directory does not exist.', $inputDir));
+            throw new InvalidArgumentException(\sprintf('The "%s" directory does not exist.', $inputDir));
         }
         $inputDir = rtrim($inputDir, '/\\') . \DIRECTORY_SEPARATOR;
 
@@ -1125,8 +1085,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
     }
 
     /**
-     * @param ?int $compressionMethod
-     *
      * @throws ZipException
      */
     private function doAddFiles(
@@ -1172,8 +1130,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      *
      * @throws ZipException
      *
-     * @return ZipFile
-     *
      * @internal param bool $recursive Recursive search
      */
     public function addFilesFromRegexRecursive(
@@ -1186,9 +1142,9 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
     }
 
     /**
-     * Add array data to archive.
-     * Keys is local names.
-     * Values is contents.
+     * Add array data to the archive.
+     * Keys are local names.
+     * Values are contents.
      *
      * @param array $mapData associative array for added to zip
      */
@@ -1206,8 +1162,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      * @param string $newName new entry name
      *
      * @throws ZipException
-     *
-     * @return ZipFile
      */
     public function rename(string $oldName, string $newName): self
     {
@@ -1227,8 +1181,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      * @param string $entryName zip Entry name
      *
      * @throws ZipEntryNotFoundException if entry not found
-     *
-     * @return ZipFile
      */
     public function deleteFromName(string $entryName): self
     {
@@ -1246,7 +1198,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      *
      * @param string $globPattern Glob pattern
      *
-     * @return ZipFile
      * @sse https://en.wikipedia.org/wiki/Glob_(programming) Glob pattern syntax
      */
     public function deleteFromGlob(string $globPattern): self
@@ -1264,8 +1215,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      * Delete entries by regex pattern.
      *
      * @param string $regexPattern Regex pattern
-     *
-     * @return ZipFile
      */
     public function deleteFromRegex(string $regexPattern): self
     {
@@ -1279,8 +1228,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
 
     /**
      * Delete all entries.
-     *
-     * @return ZipFile
      */
     public function deleteAll(): self
     {
@@ -1292,8 +1239,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
     /**
      * Set compression level for new entries.
      *
-     * @return ZipFile
-     *
      * @see ZipCompressionLevel::NORMAL
      * @see ZipCompressionLevel::SUPER_FAST
      * @see ZipCompressionLevel::FAST
@@ -1311,8 +1256,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
     /**
      * @throws ZipException
      *
-     * @return ZipFile
-     *
      * @see ZipCompressionLevel::NORMAL
      * @see ZipCompressionLevel::SUPER_FAST
      * @see ZipCompressionLevel::FAST
@@ -1334,8 +1277,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      *
      * @throws ZipException
      *
-     * @return ZipFile
-     *
      * @see ZipCompressionMethod::STORED
      * @see ZipCompressionMethod::DEFLATED
      * @see ZipCompressionMethod::BZIP2
@@ -1351,11 +1292,9 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
     }
 
     /**
-     * Set password to all input encrypted entries.
+     * Set the password for reading all encrypted entries.
      *
      * @param string $password Password
-     *
-     * @return ZipFile
      */
     public function setReadPassword(string $password): self
     {
@@ -1365,13 +1304,11 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
     }
 
     /**
-     * Set password to concrete input entry.
+     * Set the password for reading a specific entry.
      *
      * @param string $password Password
      *
      * @throws ZipException
-     *
-     * @return ZipFile
      */
     public function setReadPasswordEntry(string $entryName, string $password): self
     {
@@ -1387,8 +1324,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      * @param int|null $encryptionMethod Encryption method
      *
      * @throws ZipEntryNotFoundException
-     *
-     * @return ZipFile
      */
     public function setPassword(string $password, ?int $encryptionMethod = ZipEncryptionMethod::WINZIP_AES_256): self
     {
@@ -1402,13 +1337,9 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
     }
 
     /**
-     * Sets a new password of an entry defined by its name.
-     *
-     * @param ?int $encryptionMethod
+     * Sets a new password for an entry identified by its name.
      *
      * @throws ZipException
-     *
-     * @return ZipFile
      */
     public function setPasswordEntry(string $entryName, string $password, ?int $encryptionMethod = null): self
     {
@@ -1421,8 +1352,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      * Disable encryption for all entries that are already in the archive.
      *
      * @throws ZipEntryNotFoundException
-     *
-     * @return ZipFile
      */
     public function disableEncryption(): self
     {
@@ -1435,8 +1364,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      * Disable encryption of an entry defined by its name.
      *
      * @throws ZipEntryNotFoundException
-     *
-     * @return ZipFile
      */
     public function disableEncryptionEntry(string $entryName): self
     {
@@ -1446,9 +1373,7 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
     }
 
     /**
-     * Undo all changes done in the archive.
-     *
-     * @return ZipFile
+     * Undo all changes made to the archive.
      */
     public function unchangeAll(): self
     {
@@ -1458,9 +1383,7 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
     }
 
     /**
-     * Undo change archive comment.
-     *
-     * @return ZipFile
+     * Undo changes to the archive comment.
      */
     public function unchangeArchiveComment(): self
     {
@@ -1470,11 +1393,9 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
     }
 
     /**
-     * Revert all changes done to an entry with the given name.
+     * Revert all changes made to an entry with the given name.
      *
      * @param string|ZipEntry $entry Entry name or ZipEntry
-     *
-     * @return ZipFile
      */
     public function unchangeEntry($entry): self
     {
@@ -1489,8 +1410,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      * @param string $filename Output filename
      *
      * @throws ZipException
-     *
-     * @return ZipFile
      */
     public function saveAsFile(string $filename): self
     {
@@ -1527,7 +1446,7 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
                 unlink($tempFilename);
             }
 
-            throw new ZipException(sprintf('Cannot move %s to %s', $tempFilename, $filename));
+            throw new ZipException(\sprintf('Cannot move %s to %s', $tempFilename, $filename));
         }
 
         if ($reopen) {
@@ -1543,13 +1462,11 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      * @param resource $handle Output stream resource
      *
      * @throws ZipException
-     *
-     * @return ZipFile
      */
     public function saveAsStream($handle): self
     {
         if (!\is_resource($handle)) {
-            throw new InvalidArgumentException('handle is not resource');
+            throw new InvalidArgumentException('handle is not a resource');
         }
 
         $this->writeZipToStream($handle);
@@ -1591,8 +1508,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
     }
 
     /**
-     * @param ?string $mimeType
-     *
      * @throws ZipException
      */
     private function getOutputData(string $outputFilename, ?string $mimeType = null, bool $attachment = true): array
@@ -1654,7 +1569,7 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
         bool $attachment = true
     ): ResponseInterface {
         @trigger_error(
-            sprintf(
+            \sprintf(
                 'Method %s is deprecated. Replace to %s::%s',
                 __METHOD__,
                 __CLASS__,
@@ -1773,7 +1688,7 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
     }
 
     /**
-     * Close zip archive and release input stream.
+     * Close the zip archive and release the input stream.
      */
     public function close(): void
     {
@@ -1789,8 +1704,6 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
      * Save and reopen zip archive.
      *
      * @throws ZipException
-     *
-     * @return ZipFile
      */
     public function rewrite(): self
     {
@@ -1932,7 +1845,7 @@ class ZipFile implements \Countable, \ArrayAccess, \Iterator
     }
 
     /**
-     * Whether a offset exists.
+     * Whether an offset exists.
      *
      * @see http://php.net/manual/en/arrayaccess.offsetexists.php
      *

+ 1 - 1
tests/Extra/Fields/AsiExtraFieldTest.php

@@ -92,7 +92,7 @@ final class AsiExtraFieldTest extends TestCase
     public function testInvalidParse(): void
     {
         $this->expectException(Crc32Exception::class);
-        $this->expectExceptionMessage('Asi Unix Extra Filed Data (expected CRC32 value');
+        $this->expectExceptionMessage('Asi Unix Extra Field Data (expected CRC32 value');
 
         AsiExtraField::unpackLocalFileData("\x01\x06\\\xF6\xEDA\x00\x00\x00\x00\xE8\x03\xE8\x03");
     }

+ 2 - 2
tests/Extra/Fields/UnrecognizedExtraFieldTest.php

@@ -47,7 +47,7 @@ final class UnrecognizedExtraFieldTest extends TestCase
     public function testUnpackLocalData(): void
     {
         $this->expectException(RuntimeException::class);
-        $this->expectExceptionMessage('Unsupport parse');
+        $this->expectExceptionMessage('Parsing is not supported for unrecognized extra fields.');
 
         UnrecognizedExtraField::unpackLocalFileData("\x01\x02");
     }
@@ -55,7 +55,7 @@ final class UnrecognizedExtraFieldTest extends TestCase
     public function testUnpackCentralDirData(): void
     {
         $this->expectException(RuntimeException::class);
-        $this->expectExceptionMessage('Unsupport parse');
+        $this->expectExceptionMessage('Parsing is not supported for unrecognized extra fields.');
 
         UnrecognizedExtraField::unpackCentralDirData("\x01\x02");
     }

+ 4 - 4
tests/Extra/Fields/WinZipAesExtraFieldTest.php

@@ -158,7 +158,7 @@ final class WinZipAesExtraFieldTest extends TestCase
     public function testConstructUnsupportVendorVersion(): void
     {
         $this->expectException(InvalidArgumentException::class);
-        $this->expectExceptionMessage('Unsupport WinZip AES vendor version: 3');
+        $this->expectExceptionMessage('Unsupported WinZip AES vendor version: 3');
 
         new WinZipAesExtraField(
             3,
@@ -170,7 +170,7 @@ final class WinZipAesExtraFieldTest extends TestCase
     public function testSetterUnsupportVendorVersion(): void
     {
         $this->expectException(InvalidArgumentException::class);
-        $this->expectExceptionMessage('Unsupport WinZip AES vendor version: 3');
+        $this->expectExceptionMessage('Unsupported WinZip AES vendor version: 3');
 
         $extraField = new WinZipAesExtraField(
             WinZipAesExtraField::VERSION_AE1,
@@ -211,7 +211,7 @@ final class WinZipAesExtraFieldTest extends TestCase
     public function testConstructUnsupportKeyStrength(): void
     {
         $this->expectException(InvalidArgumentException::class);
-        $this->expectExceptionMessage('Key strength 16 not support value. Allow values: 1, 2, 3');
+        $this->expectExceptionMessage('Invalid key strength 16. Allowed values: 1, 2, 3');
 
         new WinZipAesExtraField(
             WinZipAesExtraField::VERSION_AE1,
@@ -226,7 +226,7 @@ final class WinZipAesExtraFieldTest extends TestCase
     public function testSetterUnsupportKeyStrength(): void
     {
         $this->expectException(InvalidArgumentException::class);
-        $this->expectExceptionMessage('Key strength 16 not support value. Allow values: 1, 2, 3');
+        $this->expectExceptionMessage('Invalid key strength 16. Allowed values: 1, 2, 3');
 
         new WinZipAesExtraField(
             WinZipAesExtraField::VERSION_AE1,

+ 2 - 2
tests/Internal/DummyFileSystemStream.php

@@ -12,7 +12,7 @@ declare(strict_types=1);
 namespace PhpZip\Tests\Internal;
 
 /**
- * Try to load using dummy stream.
+ * A dummy stream wrapper for testing.
  *
  * @see https://www.php.net/streamwrapper
  */
@@ -24,7 +24,7 @@ class DummyFileSystemStream
      *
      * @var resource|null
      */
-    public $context = null;
+    public $context;
 
     /** @var resource */
     private $fp;

+ 7 - 8
tests/ZipFileTest.php

@@ -166,7 +166,7 @@ class ZipFileTest extends ZipTestCase
     public function testOpenFromStreamInvalidResourceType3(): void
     {
         $this->expectException(InvalidArgumentException::class);
-        $this->expectExceptionMessage('Directory stream not supported');
+        $this->expectExceptionMessage('Directory streams are not supported');
 
         $zipFile = new ZipFile();
         $zipFile->openFromStream(opendir(__DIR__));
@@ -174,6 +174,7 @@ class ZipFileTest extends ZipTestCase
 
     /**
      * @throws ZipException
+     *
      * @noinspection PhpUsageOfSilenceOperatorInspection
      * @noinspection NestedPositiveIfStatementsInspection
      */
@@ -481,7 +482,7 @@ class ZipFileTest extends ZipTestCase
     public function testRenameEntryToExistsNewEntry(): void
     {
         $this->expectException(InvalidArgumentException::class);
-        $this->expectExceptionMessage('is exists');
+        $this->expectExceptionMessage('already exists');
 
         $zipFile = new ZipFile();
         $zipFile['file'] = 'content';
@@ -1076,7 +1077,7 @@ class ZipFileTest extends ZipTestCase
     public function testExtractFail2(): void
     {
         $this->expectException(ZipException::class);
-        $this->expectExceptionMessage('Destination is not directory');
+        $this->expectExceptionMessage('Destination is not a directory');
 
         $zipFile = new ZipFile();
         $zipFile['file'] = 'content';
@@ -1093,7 +1094,7 @@ class ZipFileTest extends ZipTestCase
     public function testExtractFail3(): void
     {
         $this->expectException(ZipException::class);
-        $this->expectExceptionMessage('Destination is not writable directory');
+        $this->expectExceptionMessage('Destination is not a writable directory');
 
         static::skipTestForRootUser();
 
@@ -1194,7 +1195,7 @@ class ZipFileTest extends ZipTestCase
     public function testAddFromStreamInvalidResource(): void
     {
         $this->expectException(InvalidArgumentException::class);
-        $this->expectExceptionMessage('Stream is not resource');
+        $this->expectExceptionMessage('Stream is not a resource');
 
         $zipFile = new ZipFile();
         /** @noinspection PhpParamsInspection */
@@ -1504,7 +1505,7 @@ class ZipFileTest extends ZipTestCase
     public function testSaveAsStreamBadStream(): void
     {
         $this->expectException(InvalidArgumentException::class);
-        $this->expectExceptionMessage('handle is not resource');
+        $this->expectExceptionMessage('handle is not a resource');
 
         $zipFile = new ZipFile();
         /** @noinspection PhpParamsInspection */
@@ -2145,8 +2146,6 @@ class ZipFileTest extends ZipTestCase
      *
      * @dataProvider provideOutputAsAttachment
      *
-     * @param ?string $mimeType
-     *
      * @throws ZipException
      */
     public function testOutputAsAttachment(string $zipFilename, ?string $mimeType, string $expectedMimeType, bool $attachment, string $expectedAttachment): void

+ 1 - 3
tests/ZipStreamOpenTest.php

@@ -29,8 +29,6 @@ class ZipStreamOpenTest extends TestCase
      * @dataProvider provideStreams
      *
      * @param resource $resource
-     * @param ?string  $exceptionClass
-     * @param ?string  $exceptionMessage
      *
      * @throws ZipException
      */
@@ -60,7 +58,7 @@ class ZipStreamOpenTest extends TestCase
             [
                 @fopen(__DIR__, 'rb'),
                 InvalidArgumentException::class,
-                'Directory stream not supported',
+                'Directory streams are not supported',
             ],
             [$this->getTempResource('php://temp'), null, null],
             [$this->getTempResource('php://memory'), null, null],