Parcourir la source

style: run php-cs-fixer, pin rules to PHP 7.4 support

Ran the configured fixer over the codebase. The kept output consists of
safe mechanical changes: native function call prefixing (\sprintf),
docblock cleanups and added @param annotations.

Disabled three rules that generate syntax newer than the supported
runtime range: octal_notation (0o literals, PHP 8.1+),
phpdoc_to_param_type and phpdoc_to_return_type (native mixed and union
type declarations, PHP 8.0+). The octal literals, mixed parameter hints
and union declarations produced by this run were reverted.
Ne-Lexa il y a 3 semaines
Parent
commit
539049ddd4
33 fichiers modifiés avec 49 ajouts et 93 suppressions
  1. 9 3
      .php-cs-fixer.php
  2. 1 1
      src/Constants/ZipCompressionMethod.php
  3. 1 1
      src/Constants/ZipEncryptionMethod.php
  4. 1 1
      src/Exception/Crc32Exception.php
  5. 1 1
      src/IO/Stream/ZipEntryStreamWrapper.php
  6. 4 4
      src/IO/ZipWriter.php
  7. 2 2
      src/Model/Data/ZipFileData.php
  8. 1 4
      src/Model/Extra/ExtraFieldsCollection.php
  9. 1 5
      src/Model/Extra/Fields/ApkAlignmentExtraField.php
  10. 1 5
      src/Model/Extra/Fields/JarMarkerExtraField.php
  11. 3 7
      src/Model/Extra/Fields/NewUnixExtraField.php
  12. 0 4
      src/Model/Extra/Fields/OldUnixExtraField.php
  13. 1 1
      src/Model/Extra/Fields/UnicodeCommentExtraField.php
  14. 1 1
      src/Model/Extra/Fields/UnicodePathExtraField.php
  15. 2 8
      src/Model/Extra/Fields/Zip64ExtraField.php
  16. 2 1
      src/Model/Extra/ZipExtraDriver.php
  17. 0 1
      src/Model/ImmutableZipContainer.php
  18. 2 0
      src/Util/CryptoUtil.php
  19. 1 0
      src/Util/DateTimeConverter.php
  20. 2 2
      src/Util/FilesUtil.php
  21. 1 1
      src/Util/Iterator/IgnoreFilesRecursiveFilterIterator.php
  22. 0 2
      tests/Extra/Fields/AbstractUnicodeExtraFieldTest.php
  23. 0 4
      tests/Extra/Fields/ExtendedTimestampExtraFieldTest.php
  24. 0 5
      tests/Extra/Fields/OldUnixExtraFieldTest.php
  25. 0 7
      tests/Extra/Fields/Zip64ExtraFieldTest.php
  26. 1 1
      tests/Internal/Epub/EpubInfo.php
  27. 1 0
      tests/PhpZipExtResourceTest.php
  28. 1 1
      tests/SlowTests/Zip64Test.php
  29. 2 12
      tests/ZipEntryTest.php
  30. 3 3
      tests/ZipFileSetTestCase.php
  31. 1 0
      tests/ZipPasswordTest.php
  32. 1 1
      tests/ZipRemoteFileTest.php
  33. 2 4
      tests/ZipTestCase.php

+ 9 - 3
.php-cs-fixer.php

@@ -959,7 +959,9 @@ $rules = [
     'object_operator_without_whitespace' => true,
 
     // Literal octal must be in `0o` notation.
-    'octal_notation' => true,
+    // Disabled: the `0o` notation requires PHP 8.1+, but the library
+    // still supports PHP 7.4 and 8.0 at runtime.
+    'octal_notation' => false,
 
     /*
      * Operators - when multiline - must always be at the beginning or
@@ -1296,7 +1298,9 @@ $rules = [
      * docblock, inheritdocs) will not be fixed. [3] Manual actions are
      * required if inherited signatures are not properly documented.
      */
-    'phpdoc_to_param_type' => true,
+    // Disabled: the generated parameter types may include `mixed`
+    // (PHP 8.0+), but the library still supports PHP 7.4 at runtime.
+    'phpdoc_to_param_type' => false,
 
     /*
      * EXPERIMENTAL: Takes `@var` annotation of non-mixed types and
@@ -1322,7 +1326,9 @@ $rules = [
      * docblock, inheritdocs) will not be fixed. [3] Manual actions are
      * required if inherited signatures are not properly documented.
      */
-    'phpdoc_to_return_type' => true,
+    // Disabled: the generated return types may include `mixed`, `static`
+    // or `never` (PHP 8.0+), but the library still supports PHP 7.4.
+    'phpdoc_to_return_type' => false,
 
     /*
      * PHPDoc should start and end with content, excluding the very

+ 1 - 1
src/Constants/ZipCompressionMethod.php

@@ -87,7 +87,7 @@ final class ZipCompressionMethod
     public static function checkSupport(int $compressionMethod): void
     {
         if (!\in_array($compressionMethod, self::getSupportMethods(), true)) {
-            throw new ZipUnsupportMethodException(sprintf(
+            throw new ZipUnsupportMethodException(\sprintf(
                 'Compression method %d (%s) is not supported.',
                 $compressionMethod,
                 self::getCompressionMethodName($compressionMethod)

+ 1 - 1
src/Constants/ZipEncryptionMethod.php

@@ -67,7 +67,7 @@ final class ZipEncryptionMethod
     public static function checkSupport(int $encryptionMethod): void
     {
         if (!self::hasEncryptionMethod($encryptionMethod)) {
-            throw new InvalidArgumentException(sprintf(
+            throw new InvalidArgumentException(\sprintf(
                 'Encryption method %d is not supported.',
                 $encryptionMethod
             ));

+ 1 - 1
src/Exception/Crc32Exception.php

@@ -29,7 +29,7 @@ class Crc32Exception extends ZipException
     public function __construct(string $name, int $expected, int $actual)
     {
         parent::__construct(
-            sprintf(
+            \sprintf(
                 '%s (expected CRC32 value 0x%x, but is actually 0x%x)',
                 $name,
                 $expected,

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

@@ -119,7 +119,7 @@ final class ZipEntryStreamWrapper
         $zipData = $zipEntry->getData();
 
         if ($zipData === null) {
-            throw new ZipException(sprintf('No data for zip entry "%s"', $zipEntry->getName()));
+            throw new ZipException(\sprintf('No data for zip entry "%s"', $zipEntry->getName()));
         }
         $this->fp = $zipData->getDataAsStream();
 

+ 4 - 4
src/IO/ZipWriter.php

@@ -145,7 +145,7 @@ class ZipWriter
 
         if ($size > 0xFFFF) {
             throw new ZipException(
-                sprintf(
+                \sprintf(
                     '%s (the total size of %s bytes for the name, extra fields and comment exceeds the maximum size of %d bytes)',
                     $entry->getName(),
                     $size,
@@ -223,7 +223,7 @@ class ZipWriter
 
         if ($size > 0xFFFF) {
             throw new ZipException(
-                sprintf(
+                \sprintf(
                     'Size extra out of range: %d. Extra data: %s',
                     $size,
                     $extraData
@@ -248,7 +248,7 @@ class ZipWriter
                 return;
             }
 
-            throw new ZipException(sprintf('No zip data for entry "%s"', $entry->getName()));
+            throw new ZipException(\sprintf('No zip data for entry "%s"', $entry->getName()));
         }
 
         // data write variants:
@@ -436,7 +436,7 @@ class ZipWriter
 
             default:
                 throw new ZipUnsupportMethodException(
-                    sprintf(
+                    \sprintf(
                         '%s (compression method %d (%s) is not supported)',
                         $entry->getName(),
                         $entry->getCompressionMethod(),

+ 2 - 2
src/Model/Data/ZipFileData.php

@@ -44,7 +44,7 @@ class ZipFileData implements ZipData
     public function getDataAsStream()
     {
         if (!$this->file->isReadable()) {
-            throw new ZipException(sprintf('The %s file is no longer readable.', $this->file->getPathname()));
+            throw new ZipException(\sprintf('The %s file is no longer readable.', $this->file->getPathname()));
         }
 
         return fopen($this->file->getPathname(), 'rb');
@@ -58,7 +58,7 @@ class ZipFileData implements ZipData
     public function getDataAsString(): string
     {
         if (!$this->file->isReadable()) {
-            throw new ZipException(sprintf('The %s file is no longer readable.', $this->file->getPathname()));
+            throw new ZipException(\sprintf('The %s file is no longer readable.', $this->file->getPathname()));
         }
 
         return file_get_contents($this->file->getPathname());

+ 1 - 4
src/Model/Extra/ExtraFieldsCollection.php

@@ -86,9 +86,6 @@ class ExtraFieldsCollection implements \ArrayAccess, \Countable, \Iterator
         }
     }
 
-    /**
-     * @param ExtraFieldsCollection $collection
-     */
     public function addCollection(self $collection): void
     {
         $this->addAll($collection->collection);
@@ -135,7 +132,7 @@ class ExtraFieldsCollection implements \ArrayAccess, \Countable, \Iterator
     }
 
     /**
-     * Whether a offset exists.
+     * Whether an offset exists.
      *
      * @see http://php.net/manual/en/arrayaccess.offsetexists.php
      *

+ 1 - 5
src/Model/Extra/Fields/ApkAlignmentExtraField.php

@@ -84,8 +84,6 @@ final class ApkAlignmentExtraField implements ZipExtraField
      * @param ZipEntry|null $entry  optional zip entry
      *
      * @throws ZipException
-     *
-     * @return ApkAlignmentExtraField
      */
     public static function unpackLocalFileData(string $buffer, ?ZipEntry $entry = null): self
     {
@@ -114,8 +112,6 @@ final class ApkAlignmentExtraField implements ZipExtraField
      * @param ZipEntry|null $entry  optional zip entry
      *
      * @throws ZipException on error
-     *
-     * @return ApkAlignmentExtraField
      */
     public static function unpackCentralDirData(string $buffer, ?ZipEntry $entry = null): self
     {
@@ -146,7 +142,7 @@ final class ApkAlignmentExtraField implements ZipExtraField
 
     public function __toString(): string
     {
-        return sprintf(
+        return \sprintf(
             '0x%04x APK Alignment: Multiple=%d Padding=%d',
             self::HEADER_ID,
             $this->multiple,

+ 1 - 5
src/Model/Extra/Fields/JarMarkerExtraField.php

@@ -83,8 +83,6 @@ final class JarMarkerExtraField implements ZipExtraField
      * @param ZipEntry|null $entry  optional zip entry
      *
      * @throws ZipException on error
-     *
-     * @return JarMarkerExtraField
      */
     public static function unpackLocalFileData(string $buffer, ?ZipEntry $entry = null): self
     {
@@ -102,8 +100,6 @@ final class JarMarkerExtraField implements ZipExtraField
      * @param ZipEntry|null $entry  optional zip entry
      *
      * @throws ZipException on error
-     *
-     * @return JarMarkerExtraField
      */
     public static function unpackCentralDirData(string $buffer, ?ZipEntry $entry = null): self
     {
@@ -112,6 +108,6 @@ final class JarMarkerExtraField implements ZipExtraField
 
     public function __toString(): string
     {
-        return sprintf('0x%04x Jar Marker', self::HEADER_ID);
+        return \sprintf('0x%04x Jar Marker', self::HEADER_ID);
     }
 }

+ 3 - 7
src/Model/Extra/Fields/NewUnixExtraField.php

@@ -92,15 +92,13 @@ final class NewUnixExtraField implements ZipExtraField
      * @param ZipEntry|null $entry  optional zip entry
      *
      * @throws ZipException
-     *
-     * @return NewUnixExtraField
      */
     public static function unpackLocalFileData(string $buffer, ?ZipEntry $entry = null): self
     {
         $length = \strlen($buffer);
 
         if ($length < 3) {
-            throw new ZipException(sprintf('X7875_NewUnix length is too short, only %s bytes', $length));
+            throw new ZipException(\sprintf('X7875_NewUnix length is too short, only %s bytes', $length));
         }
         $offset = 0;
         [
@@ -124,8 +122,6 @@ final class NewUnixExtraField implements ZipExtraField
      * @param ZipEntry|null $entry  optional zip entry
      *
      * @throws ZipException
-     *
-     * @return NewUnixExtraField
      */
     public static function unpackCentralDirData(string $buffer, ?ZipEntry $entry = null): self
     {
@@ -173,7 +169,7 @@ final class NewUnixExtraField implements ZipExtraField
         ];
 
         if (!isset($format[$size])) {
-            throw new ZipException(sprintf('Invalid size bytes: %d', $size));
+            throw new ZipException(\sprintf('Invalid size bytes: %d', $size));
         }
 
         return unpack($format[$size], $data)[1];
@@ -206,7 +202,7 @@ final class NewUnixExtraField implements ZipExtraField
 
     public function __toString(): string
     {
-        return sprintf(
+        return \sprintf(
             '0x%04x NewUnix: UID=%d GID=%d',
             self::HEADER_ID,
             $this->uid,

+ 0 - 4
src/Model/Extra/Fields/OldUnixExtraField.php

@@ -102,8 +102,6 @@ final class OldUnixExtraField implements ZipExtraField
      *
      * @param string        $buffer the buffer to read data from
      * @param ZipEntry|null $entry  optional zip entry
-     *
-     * @return OldUnixExtraField
      */
     public static function unpackLocalFileData(string $buffer, ?ZipEntry $entry = null): self
     {
@@ -135,8 +133,6 @@ final class OldUnixExtraField implements ZipExtraField
      *
      * @param string        $buffer the buffer to read data from
      * @param ZipEntry|null $entry  optional zip entry
-     *
-     * @return OldUnixExtraField
      */
     public static function unpackCentralDirData(string $buffer, ?ZipEntry $entry = null): self
     {

+ 1 - 1
src/Model/Extra/Fields/UnicodeCommentExtraField.php

@@ -71,7 +71,7 @@ final class UnicodeCommentExtraField extends AbstractUnicodeExtraField
 
     public function __toString(): string
     {
-        return sprintf(
+        return \sprintf(
             '0x%04x UnicodeComment: "%s"',
             self::HEADER_ID,
             $this->getUnicodeValue()

+ 1 - 1
src/Model/Extra/Fields/UnicodePathExtraField.php

@@ -72,7 +72,7 @@ final class UnicodePathExtraField extends AbstractUnicodeExtraField
 
     public function __toString(): string
     {
-        return sprintf(
+        return \sprintf(
             '0x%04x UnicodePath: "%s"',
             self::HEADER_ID,
             $this->getUnicodeValue()

+ 2 - 8
src/Model/Extra/Fields/Zip64ExtraField.php

@@ -60,12 +60,9 @@ final class Zip64ExtraField 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 Zip64ExtraField
      */
     public static function unpackLocalFileData(string $buffer, ?ZipEntry $entry = null): self
     {
@@ -96,12 +93,9 @@ final class Zip64ExtraField 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 Zip64ExtraField
      */
     public static function unpackCentralDirData(string $buffer, ?ZipEntry $entry = null): self
     {

+ 2 - 1
src/Model/Extra/ZipExtraDriver.php

@@ -31,6 +31,7 @@ final class ZipExtraDriver
 {
     /**
      * @var array<int, string>
+     *
      * @psalm-var array<int, class-string<ZipExtraField>>
      */
     private static array $implementations = [
@@ -58,7 +59,7 @@ final class ZipExtraDriver
     {
         if (!is_a($extraField, ZipExtraField::class, true)) {
             throw new InvalidArgumentException(
-                sprintf(
+                \sprintf(
                     '$extraField "%s" is not implements interface %s',
                     (string) $extraField,
                     ZipExtraField::class

+ 0 - 1
src/Model/ImmutableZipContainer.php

@@ -21,7 +21,6 @@ class ImmutableZipContainer implements \Countable
 
     /**
      * @param ZipEntry[] $entries
-     * @param ?string    $archiveComment
      */
     public function __construct(array $entries, ?string $archiveComment = null)
     {

+ 2 - 0
src/Util/CryptoUtil.php

@@ -33,6 +33,7 @@ final class CryptoUtil
     {
         if (\extension_loaded('openssl')) {
             $numBits = \strlen($key) * 8;
+
             /** @noinspection PhpComposerExtensionStubsInspection */
             return openssl_decrypt($data, 'AES-' . $numBits . '-CTR', $key, \OPENSSL_RAW_DATA, $iv);
         }
@@ -53,6 +54,7 @@ final class CryptoUtil
     {
         if (\extension_loaded('openssl')) {
             $numBits = \strlen($key) * 8;
+
             /** @noinspection PhpComposerExtensionStubsInspection */
             return openssl_encrypt($data, 'AES-' . $numBits . '-CTR', $key, \OPENSSL_RAW_DATA, $iv);
         }

+ 1 - 0
src/Util/DateTimeConverter.php

@@ -63,6 +63,7 @@ class DateTimeConverter
         } elseif ($dosTime > self::MAX_DOS_TIME) {
             $dosTime = self::MAX_DOS_TIME;
         }
+
 //        date_default_timezone_set('UTC');
         return mktime(
             (($dosTime >> 11) & 0x1F),         // hours

+ 2 - 2
src/Util/FilesUtil.php

@@ -263,14 +263,14 @@ final class FilesUtil
     public static function normalizeZipPath(string $path): string
     {
         if (strpos($path, "\0") !== false) {
-            throw new ZipException(sprintf('Invalid zip entry name "%s": contains NUL byte', $path));
+            throw new ZipException(\sprintf('Invalid zip entry name "%s": contains NUL byte', $path));
         }
 
         // A Windows drive-relative name ("C:evil.txt", "C:\dir\file.txt"),
         // a UNC path ("\\server\share\file") or a stream-wrapper-like name
         // would bypass the extraction directory when joined with it.
         if (preg_match('#^([A-Za-z]:|\\\\\\\\|[A-Za-z0-9+.-]+://)#', $path) === 1) {
-            throw new ZipException(sprintf('Invalid zip entry name "%s": absolute or unsafe path', $path));
+            throw new ZipException(\sprintf('Invalid zip entry name "%s": absolute or unsafe path', $path));
         }
 
         $parts = preg_split('#[/\\\\]#', $path);

+ 1 - 1
src/Util/Iterator/IgnoreFilesRecursiveFilterIterator.php

@@ -61,8 +61,8 @@ class IgnoreFilesRecursiveFilterIterator extends \RecursiveFilterIterator
     }
 
     /**
-     * @return IgnoreFilesRecursiveFilterIterator
      * @psalm-suppress UndefinedInterfaceMethod
+     *
      * @noinspection PhpPossiblePolymorphicInvocationInspection
      */
     public function getChildren(): self

+ 0 - 2
tests/Extra/Fields/AbstractUnicodeExtraFieldTest.php

@@ -18,8 +18,6 @@ use PhpZip\Model\Extra\Fields\AbstractUnicodeExtraField;
 abstract class AbstractUnicodeExtraFieldTest extends TestCase
 {
     /**
-     * @return string|AbstractUnicodeExtraField
-     *
      * @psalm-var class-string<AbstractUnicodeExtraField>
      */
     abstract protected function getUnicodeExtraFieldClassName();

+ 0 - 4
tests/Extra/Fields/ExtendedTimestampExtraFieldTest.php

@@ -27,10 +27,6 @@ final class ExtendedTimestampExtraFieldTest extends TestCase
      * @dataProvider provideExtraField
      *
      * @noinspection PhpTooManyParametersInspection
-     *
-     * @param ?int $modifyTime
-     * @param ?int $accessTime
-     * @param ?int $createTime
      */
     public function testExtraField(
         int $flags,

+ 0 - 5
tests/Extra/Fields/OldUnixExtraFieldTest.php

@@ -28,11 +28,6 @@ final class OldUnixExtraFieldTest extends TestCase
      *
      * @noinspection PhpTooManyParametersInspection
      *
-     * @param ?int $accessTime
-     * @param ?int $modifyTime
-     * @param ?int $uid
-     * @param ?int $gid
-     *
      * @throws \Exception
      */
     public function testExtraField(

+ 0 - 7
tests/Extra/Fields/Zip64ExtraFieldTest.php

@@ -36,13 +36,6 @@ final class Zip64ExtraFieldTest extends TestCase
      *
      * @noinspection PhpTooManyParametersInspection
      *
-     * @param ?int    $uncompressedSize
-     * @param ?int    $compressedSize
-     * @param ?int    $localHeaderOffset
-     * @param ?int    $diskStart
-     * @param ?string $localBinaryData
-     * @param ?string $cdBinaryData
-     *
      * @throws ZipException
      */
     public function testExtraField(

+ 1 - 1
tests/Internal/Epub/EpubInfo.php

@@ -39,7 +39,7 @@ class EpubInfo
     /**
      * EpubInfo constructor.
      *
-     * @param $xmlContents
+     * @param mixed $xmlContents
      *
      * @throws ZipException
      */

+ 1 - 0
tests/PhpZipExtResourceTest.php

@@ -81,6 +81,7 @@ final class PhpZipExtResourceTest extends ZipTestCase
      *
      * @see https://github.com/php/php-src/blob/master/ext/zip/tests/bug40228.phpt
      * @see https://github.com/php/php-src/blob/master/ext/zip/tests/bug40228-mb.phpt
+     *
      * @dataProvider provideBug40228
      *
      * @throws ZipException

+ 1 - 1
tests/SlowTests/Zip64Test.php

@@ -46,7 +46,7 @@ class Zip64Test extends ZipTestCase
 
         if ($needFreeSpace > $diskFreeSpace) {
             static::markTestIncomplete(
-                sprintf(
+                \sprintf(
                     'Not enough disk space for the test. Need to free %s',
                     FilesUtil::humanSize($needFreeSpace - $diskFreeSpace)
                 )

+ 2 - 12
tests/ZipEntryTest.php

@@ -744,7 +744,7 @@ class ZipEntryTest extends TestCase
     {
         $this->expectException(InvalidArgumentException::class);
         $this->expectExceptionMessage(
-            sprintf(
+            \sprintf(
                 'Invalid compression level. Minimum level %s. Maximum level %s',
                 ZipCompressionLevel::LEVEL_MIN,
                 ZipCompressionLevel::LEVEL_MAX
@@ -827,8 +827,6 @@ class ZipEntryTest extends TestCase
      * @dataProvider provideExternalAttributes
      *
      * @noinspection PhpTooManyParametersInspection
-     *
-     * @param ?int $externalAttr
      */
     public function testExternalAttributes(
         string $entryName,
@@ -1103,9 +1101,6 @@ class ZipEntryTest extends TestCase
 
     /**
      * @dataProvider provideEncryption
-     *
-     * @param ?string $password
-     * @param ?int    $encryptionMethod
      */
     public function testEncryption(?string $password, ?int $encryptionMethod, bool $encrypted, int $expectedEncryptionMethod): void
     {
@@ -1145,8 +1140,6 @@ class ZipEntryTest extends TestCase
 
     /**
      * @dataProvider provideEncryptionMethod
-     *
-     * @param ?int $encryptionMethod
      */
     public function testEncryptionMethod(
         ?int $encryptionMethod,
@@ -1209,7 +1202,7 @@ class ZipEntryTest extends TestCase
     public function testInvalidEncryptionMethod(int $encryptionMethod): void
     {
         $this->expectException(InvalidArgumentException::class);
-        $this->expectExceptionMessage(sprintf('Encryption method %d is not supported.', $encryptionMethod));
+        $this->expectExceptionMessage(\sprintf('Encryption method %d is not supported.', $encryptionMethod));
 
         $zipEntry = new ZipEntry('entry');
         $zipEntry->setEncryptionMethod($encryptionMethod);
@@ -1326,9 +1319,6 @@ class ZipEntryTest extends TestCase
 
     /**
      * @dataProvider provideExtraTime
-     *
-     * @param ?\DateTimeInterface $atime
-     * @param ?\DateTimeInterface $ctime
      */
     public function testMTimeATimeCTime(ExtraFieldsCollection $extraFieldsCollection, \DateTimeInterface $mtime, ?\DateTimeInterface $atime, ?\DateTimeInterface $ctime): void
     {

+ 3 - 3
tests/ZipFileSetTestCase.php

@@ -52,13 +52,13 @@ abstract class ZipFileSetTestCase extends ZipTestCase
 
             if (StringUtil::endsWith($name, '/')) {
                 if (!is_dir($fullName) && !mkdir($fullName, 0755, true) && !is_dir($fullName)) {
-                    throw new \RuntimeException(sprintf('Directory "%s" was not created', $fullName));
+                    throw new \RuntimeException(\sprintf('Directory "%s" was not created', $fullName));
                 }
             } else {
                 $dirname = \dirname($fullName);
 
                 if (!is_dir($dirname) && !mkdir($dirname, 0755, true) && !is_dir($dirname)) {
-                    throw new \RuntimeException(sprintf('Directory "%s" was not created', $dirname));
+                    throw new \RuntimeException(\sprintf('Directory "%s" was not created', $dirname));
                 }
                 file_put_contents($fullName, $content);
             }
@@ -83,7 +83,7 @@ abstract class ZipFileSetTestCase extends ZipTestCase
                 static::assertSame(
                     $zipFile[$zipEntryName],
                     $content,
-                    sprintf('The content of the entry "%s" is not as expected.', $zipEntryName)
+                    \sprintf('The content of the entry "%s" is not as expected.', $zipEntryName)
                 );
                 unset($actualResultFiles[$file]);
             } else {

+ 1 - 0
tests/ZipPasswordTest.php

@@ -35,6 +35,7 @@ class ZipPasswordTest extends ZipFileSetTestCase
      *
      * @throws ZipException
      * @throws \Exception
+     *
      * @noinspection PhpRedundantCatchClauseInspection
      */
     public function testSetPassword(): void

+ 1 - 1
tests/ZipRemoteFileTest.php

@@ -47,7 +47,7 @@ class ZipRemoteFileTest extends ZipTestCase
 
         if ($fp === false) {
             static::markTestSkipped(
-                sprintf(
+                \sprintf(
                     'Could not fetch remote file: %s',
                     $fileUrl
                 )

+ 2 - 4
tests/ZipTestCase.php

@@ -33,7 +33,7 @@ abstract class ZipTestCase extends TestCase
         $tempDir = sys_get_temp_dir() . \DIRECTORY_SEPARATOR . 'phpunit-phpzip';
 
         if (!is_dir($tempDir) && !mkdir($tempDir, 0755, true) && !is_dir($tempDir)) {
-            throw new \RuntimeException(sprintf('Directory "%s" was not created', $tempDir));
+            throw new \RuntimeException(\sprintf('Directory "%s" was not created', $tempDir));
         }
         $this->outputFilename = $tempDir . \DIRECTORY_SEPARATOR . $id . '.zip';
         $this->outputDirname = $tempDir . \DIRECTORY_SEPARATOR . $id;
@@ -57,8 +57,6 @@ abstract class ZipTestCase extends TestCase
 
     /**
      * Assert correct zip archive.
-     *
-     * @param ?string $password
      */
     public static function assertCorrectZipArchive(string $filename, ?string $password = null): void
     {
@@ -138,7 +136,7 @@ abstract class ZipTestCase extends TestCase
     /**
      * Assert correct empty zip archive.
      *
-     * @param $filename
+     * @param mixed $filename
      */
     public static function assertCorrectEmptyZip($filename): void
     {