Kaynağa Gözat

fixed for php 32-bit

Ne-Lexa 6 yıl önce
ebeveyn
işleme
e2c058840c

+ 1 - 1
.php_cs

@@ -1028,7 +1028,7 @@ $rules = [
      * Adds a default `@coversNothing` annotation to PHPUnit test
      * classes that have no `@covers*` annotation.
      */
-    'php_unit_test_class_requires_covers' => true,
+    'php_unit_test_class_requires_covers' => false,
 
     // PHPDoc should contain `@param` for all params.
     'phpdoc_add_missing_param_annotation' => [

+ 6 - 1
composer.json

@@ -25,8 +25,13 @@
         "ext-zlib": "*",
         "psr/http-message": "^1.0"
     },
+    "config": {
+        "platform": {
+            "php": "5.5"
+        }
+    },
     "require-dev": {
-        "phpunit/phpunit": "~4.8|~5.7",
+        "phpunit/phpunit": "^4.8|^5.7",
         "zendframework/zend-diactoros": "^1.4"
     },
     "autoload": {

+ 10 - 1
src/PhpZip/Crypto/TraditionalPkwareEncryptionEngine.php

@@ -2,6 +2,7 @@
 
 namespace PhpZip\Crypto;
 
+use PhpZip\Exception\RuntimeException;
 use PhpZip\Exception\ZipAuthenticationException;
 use PhpZip\Exception\ZipCryptoException;
 use PhpZip\Model\ZipEntry;
@@ -324,7 +325,7 @@ class TraditionalPkwareEncryptionEngine implements ZipEncryptionEngine
     /**
      * Update keys.
      *
-     * @param string $charAt
+     * @param int $charAt
      */
     private function updateKeys($charAt)
     {
@@ -356,6 +357,10 @@ class TraditionalPkwareEncryptionEngine implements ZipEncryptionEngine
      */
     public function decrypt($content)
     {
+        if (\PHP_INT_SIZE === 4) {
+            throw new RuntimeException('Traditional PKWARE Encryption is not supported in 32-bit PHP.');
+        }
+
         $password = $this->entry->getPassword();
         $this->initKeys($password);
 
@@ -418,6 +423,10 @@ class TraditionalPkwareEncryptionEngine implements ZipEncryptionEngine
      */
     public function encrypt($data)
     {
+        if (\PHP_INT_SIZE === 4) {
+            throw new RuntimeException('Traditional PKWARE Encryption is not supported in 32-bit PHP.');
+        }
+
         $crc = $this->entry->isDataDescriptorRequired() ?
             ($this->entry->getDosTime() & 0x0000ffff) << 16 :
             $this->entry->getCrc();

+ 5 - 3
src/PhpZip/Crypto/WinZipAesEngine.php

@@ -49,9 +49,9 @@ class WinZipAesEngine implements ZipEncryptionEngine
      *
      * @param string $content Input stream buffer
      *
-     * @throws ZipAuthenticationException
      * @throws ZipCryptoException
      * @throws ZipException
+     * @throws ZipAuthenticationException
      *
      * @return string
      */
@@ -100,8 +100,10 @@ class WinZipAesEngine implements ZipEncryptionEngine
         }
 
         $password = $this->entry->getPassword();
-        \assert($password !== null);
-        \assert($keyStrengthBits >= self::AES_BLOCK_SIZE_BITS);
+
+        if ($password === null) {
+            throw new ZipException(sprintf('Password not set for entry %s', $this->entry->getName()));
+        }
 
         /**
          * WinZip 99-character limit.

+ 6 - 12
src/PhpZip/Extra/Fields/Zip64ExtraField.php

@@ -102,27 +102,21 @@ class Zip64ExtraField implements ExtraField
             throw new RuntimeException('entry is null');
         }
         $off = 0;
-        // Read in Uncompressed Size.
-        $size = $this->entry->getSize();
 
-        if ($size >= 0xffffffff) {
-            \assert($size === 0xffffffff);
+        // Read in Uncompressed Size.
+        if ($this->entry->getSize() === 0xffffffff) {
             $this->entry->setSize(PackUtil::unpackLongLE(substr($data, $off, 8)));
             $off += 8;
         }
-        // Read in Compressed Size.
-        $compressedSize = $this->entry->getCompressedSize();
 
-        if ($compressedSize >= 0xffffffff) {
-            \assert($compressedSize === 0xffffffff);
+        // Read in Compressed Size.
+        if ($this->entry->getCompressedSize() === 0xffffffff) {
             $this->entry->setCompressedSize(PackUtil::unpackLongLE(substr($data, $off, 8)));
             $off += 8;
         }
-        // Read in Relative Header Offset.
-        $offset = $this->entry->getOffset();
 
-        if ($offset >= 0xffffffff) {
-            \assert(0xffffffff, $offset);
+        // Read in Relative Header Offset.
+        if ($this->entry->getOffset() === 0xffffffff) {
             $this->entry->setOffset(PackUtil::unpackLongLE(substr($data, $off, 8)));
         }
     }

+ 18 - 66
src/PhpZip/Model/Entry/ZipAbstractEntry.php

@@ -22,29 +22,26 @@ use PhpZip\ZipFileInterface;
  */
 abstract class ZipAbstractEntry implements ZipEntry
 {
-    /** @var int bit flags for init state */
-    private $init;
-
     /** @var string Entry name (filename in archive) */
     private $name;
 
     /** @var int Made by platform */
-    private $platform;
+    private $platform = self::UNKNOWN;
 
     /** @var int */
     private $versionNeededToExtract = 20;
 
     /** @var int Compression method */
-    private $method;
+    private $method = self::UNKNOWN;
 
     /** @var int */
-    private $general;
+    private $general = 0;
 
     /** @var int Dos time */
-    private $dosTime;
+    private $dosTime = self::UNKNOWN;
 
     /** @var int Crc32 */
-    private $crc;
+    private $crc = self::UNKNOWN;
 
     /** @var int Compressed size */
     private $compressedSize = self::UNKNOWN;
@@ -53,7 +50,7 @@ abstract class ZipAbstractEntry implements ZipEntry
     private $size = self::UNKNOWN;
 
     /** @var int External attributes */
-    private $externalAttributes;
+    private $externalAttributes = 0;
 
     /** @var int relative Offset Of Local File Header */
     private $offset = self::UNKNOWN;
@@ -67,7 +64,7 @@ abstract class ZipAbstractEntry implements ZipEntry
      */
     private $extraFieldsCollection;
 
-    /** @var string comment field */
+    /** @var string|null comment field */
     private $comment;
 
     /** @var string entry password for read or write encryption data */
@@ -150,6 +147,7 @@ abstract class ZipAbstractEntry implements ZipEntry
         }
         $this->setGeneralPurposeBitFlag(self::GPBF_UTF8, true);
         $this->name = $name;
+        $this->externalAttributes = $this->isDirectory() ? 0x10 : 0;
 
         return $this;
     }
@@ -174,11 +172,11 @@ abstract class ZipAbstractEntry implements ZipEntry
     }
 
     /**
-     * @return int Get platform
+     * @return int platform
      */
     public function getPlatform()
     {
-        return $this->isInit(self::BIT_PLATFORM) ? $this->platform & 0xffff : self::UNKNOWN;
+        return $this->platform;
     }
 
     /**
@@ -192,44 +190,18 @@ abstract class ZipAbstractEntry implements ZipEntry
      */
     public function setPlatform($platform)
     {
-        $known = $platform !== self::UNKNOWN;
-
-        if ($known) {
+        if ($platform !== self::UNKNOWN) {
             if ($platform < 0x00 || $platform > 0xff) {
                 throw new ZipException('Platform out of range');
             }
             $this->platform = $platform;
         } else {
-            $this->platform = 0;
+            $this->platform = 0; // ms-dos
         }
-        $this->setInit(self::BIT_PLATFORM, $known);
 
         return $this;
     }
 
-    /**
-     * @param int $mask
-     *
-     * @return bool
-     */
-    protected function isInit($mask)
-    {
-        return ($this->init & $mask) !== 0;
-    }
-
-    /**
-     * @param int  $mask
-     * @param bool $init
-     */
-    protected function setInit($mask, $init)
-    {
-        if ($init) {
-            $this->init |= $mask;
-        } else {
-            $this->init &= ~$mask;
-        }
-    }
-
     /**
      * Version needed to extract.
      *
@@ -450,11 +422,7 @@ abstract class ZipAbstractEntry implements ZipEntry
      */
     public function getMethod()
     {
-        $isInit = $this->isInit(self::BIT_METHOD);
-
-        return $isInit ?
-            $this->method & 0xffff :
-            self::UNKNOWN;
+        return $this->method;
     }
 
     /**
@@ -470,7 +438,6 @@ abstract class ZipAbstractEntry implements ZipEntry
     {
         if ($method === self::UNKNOWN) {
             $this->method = $method;
-            $this->setInit(self::BIT_METHOD, false);
 
             return $this;
         }
@@ -484,7 +451,6 @@ abstract class ZipAbstractEntry implements ZipEntry
             case ZipFileInterface::METHOD_DEFLATED:
             case ZipFileInterface::METHOD_BZIP2:
                 $this->method = $method;
-                $this->setInit(self::BIT_METHOD, true);
                 break;
 
             default:
@@ -501,7 +467,7 @@ abstract class ZipAbstractEntry implements ZipEntry
      */
     public function getTime()
     {
-        if (!$this->isInit(self::BIT_DATE_TIME)) {
+        if ($this->getDosTime() === self::UNKNOWN) {
             return self::UNKNOWN;
         }
 
@@ -533,7 +499,6 @@ abstract class ZipAbstractEntry implements ZipEntry
             throw new ZipException('DosTime out of range');
         }
         $this->dosTime = $dosTime;
-        $this->setInit(self::BIT_DATE_TIME, true);
     }
 
     /**
@@ -554,7 +519,6 @@ abstract class ZipAbstractEntry implements ZipEntry
         } else {
             $this->dosTime = 0;
         }
-        $this->setInit(self::BIT_DATE_TIME, $known);
 
         return $this;
     }
@@ -566,10 +530,6 @@ abstract class ZipAbstractEntry implements ZipEntry
      */
     public function getExternalAttributes()
     {
-        if (!$this->isInit(self::BIT_EXTERNAL_ATTR)) {
-            return $this->isDirectory() ? 0x10 : 0;
-        }
-
         return $this->externalAttributes;
     }
 
@@ -582,14 +542,7 @@ abstract class ZipAbstractEntry implements ZipEntry
      */
     public function setExternalAttributes($externalAttributes)
     {
-        $known = $externalAttributes !== self::UNKNOWN;
-
-        if ($known) {
-            $this->externalAttributes = $externalAttributes;
-        } else {
-            $this->externalAttributes = 0;
-        }
-        $this->setInit(self::BIT_EXTERNAL_ATTR, $known);
+        $this->externalAttributes = $externalAttributes;
 
         return $this;
     }
@@ -655,7 +608,7 @@ abstract class ZipAbstractEntry implements ZipEntry
     /**
      * Set entry comment.
      *
-     * @param $comment
+     * @param string|null $comment
      *
      * @throws ZipException
      *
@@ -669,8 +622,8 @@ abstract class ZipAbstractEntry implements ZipEntry
             if ($commentLength < 0x0000 || $commentLength > 0xffff) {
                 throw new ZipException('Comment too long');
             }
+            $this->setGeneralPurposeBitFlag(self::GPBF_UTF8, true);
         }
-        $this->setGeneralPurposeBitFlag(self::GPBF_UTF8, true);
         $this->comment = $comment;
 
         return $this;
@@ -703,8 +656,7 @@ abstract class ZipAbstractEntry implements ZipEntry
      */
     public function setCrc($crc)
     {
-        $this->crc = $crc;
-        $this->setInit(self::BIT_CRC, true);
+        $this->crc = (int) $crc;
 
         return $this;
     }

+ 6 - 15
src/PhpZip/Model/ZipEntry.php

@@ -17,14 +17,6 @@ use PhpZip\ZipFileInterface;
 interface ZipEntry
 {
     // Bit masks for initialized fields.
-    const BIT_PLATFORM = 1;
-
-    const BIT_METHOD = 2;
-
-    const BIT_CRC = 4;
-
-    const BIT_DATE_TIME = 64;
-
     const BIT_EXTERNAL_ATTR = 128;
 
     /** The unknown value for numeric properties. */
@@ -48,13 +40,12 @@ interface ZipEntry
     /** General Purpose Bit Flag mask for encrypted data. */
     const GPBF_ENCRYPTED = 1;
 
-    // 1 << 0
-//    (For Methods 8 and 9 - Deflating)
-//    Bit 2  Bit 1
-//    0      0    Normal compression
-//    0      1    Maximum compression
-//    1      0    Fast compression
-//    1      1    Super Fast compression
+    //    (For Methods 8 and 9 - Deflating)
+    //    Bit 2  Bit 1
+    //    0      0    Normal compression
+    //    0      1    Maximum compression
+    //    1      0    Fast compression
+    //    1      1    Super Fast compression
     const GPBF_COMPRESSION_FLAG1 = 2; // 1 << 1
 
     const GPBF_COMPRESSION_FLAG2 = 4; // 1 << 2

+ 15 - 23
src/PhpZip/Model/ZipInfo.php

@@ -234,12 +234,8 @@ class ZipInfo
 
         $this->name = $entry->getName();
         $this->folder = $entry->isDirectory();
-        $this->size = \PHP_INT_SIZE === 4 ?
-            sprintf('%u', $entry->getSize()) :
-            $entry->getSize();
-        $this->compressedSize = \PHP_INT_SIZE === 4 ?
-            sprintf('%u', $entry->getCompressedSize()) :
-            $entry->getCompressedSize();
+        $this->size = $entry->getSize();
+        $this->compressedSize = $entry->getCompressedSize();
         $this->mtime = $mtime;
         $this->ctime = $ctime;
         $this->atime = $atime;
@@ -255,16 +251,13 @@ class ZipInfo
 
         $attributes = str_repeat(' ', 12);
         $externalAttributes = $entry->getExternalAttributes();
-        $externalAttributes = \PHP_INT_SIZE === 4 ?
-            sprintf('%u', $externalAttributes) :
-            $externalAttributes;
         $xattr = (($externalAttributes >> 16) & 0xFFFF);
         switch ($entry->getPlatform()) {
             case self::MADE_BY_MS_DOS:
             case self::MADE_BY_WINDOWS_NTFS:
                 if ($entry->getPlatform() !== self::MADE_BY_MS_DOS ||
-                    ($xattr & 0700) !==
-                    (0400 |
+                    ($xattr & self::UNX_IRWXU) !==
+                    (self::UNX_IRUSR |
                         (!($externalAttributes & 1) << 7) |
                         (($externalAttributes & 0x10) << 2))
                 ) {
@@ -392,30 +385,29 @@ class ZipInfo
     {
         $return = '';
 
+        $compressionMethod = $entry->getMethod();
+
         if ($entry->isEncrypted()) {
             if ($entry->getMethod() === ZipEntry::METHOD_WINZIP_AES) {
-                $return = ucfirst(self::$valuesCompressionMethod[$entry->getMethod()]);
+                $return .= ucfirst(self::$valuesCompressionMethod[$entry->getMethod()]);
                 /** @var WinZipAesEntryExtraField|null $field */
                 $field = $entry->getExtraFieldsCollection()->get(WinZipAesEntryExtraField::getHeaderId());
 
                 if ($field !== null) {
                     $return .= '-' . $field->getKeyStrength();
-
-                    if (isset(self::$valuesCompressionMethod[$field->getMethod()])) {
-                        $return .= ' ' . ucfirst(self::$valuesCompressionMethod[$field->getMethod()]);
-                    }
+                    $compressionMethod = $field->getMethod();
                 }
             } else {
                 $return .= 'ZipCrypto';
-
-                if (isset(self::$valuesCompressionMethod[$entry->getMethod()])) {
-                    $return .= ' ' . ucfirst(self::$valuesCompressionMethod[$entry->getMethod()]);
-                }
             }
-        } elseif (isset(self::$valuesCompressionMethod[$entry->getMethod()])) {
-            $return = ucfirst(self::$valuesCompressionMethod[$entry->getMethod()]);
+
+            $return .= ' ';
+        }
+
+        if (isset(self::$valuesCompressionMethod[$compressionMethod])) {
+            $return .= ucfirst(self::$valuesCompressionMethod[$compressionMethod]);
         } else {
-            $return = 'unknown';
+            $return .= 'unknown';
         }
 
         return $return;

+ 8 - 9
src/PhpZip/Stream/ZipInputStream.php

@@ -277,7 +277,6 @@ class ZipInputStream implements ZipInputStreamInterface
             // Extra Field may have been parsed, map it to the real
             // offset and conditionally update the preamble size from it.
             $lfhOff = $this->mapper->map($entry->getOffset());
-            $lfhOff = \PHP_INT_SIZE === 4 ? sprintf('%u', $lfhOff) : $lfhOff;
 
             if ($lfhOff < $this->preamble) {
                 $this->preamble = $lfhOff;
@@ -412,9 +411,6 @@ class ZipInputStream implements ZipInputStreamInterface
         }
 
         $pos = $entry->getOffset();
-        $pos = \PHP_INT_SIZE === 4
-            ? sprintf('%u', $pos) // PHP 32-Bit
-            : $pos;                      // PHP 64-Bit
 
         $startPos = $pos = $this->mapper->map($pos);
         fseek($this->in, $startPos);
@@ -429,7 +425,9 @@ class ZipInputStream implements ZipInputStreamInterface
         $data = unpack('vfileLength/vextraLength', fread($this->in, 4));
         $pos += ZipEntry::LOCAL_FILE_HEADER_MIN_LEN + $data['fileLength'] + $data['extraLength'];
 
-        \assert($entry->getCrc() !== ZipEntry::UNKNOWN);
+        if ($entry->getCrc() === ZipEntry::UNKNOWN) {
+            throw new ZipException(sprintf('Missing crc for entry %s', $entry->getName()));
+        }
 
         $method = $entry->getMethod();
 
@@ -437,7 +435,6 @@ class ZipInputStream implements ZipInputStreamInterface
 
         // Get raw entry content
         $compressedSize = $entry->getCompressedSize();
-        $compressedSize = \PHP_INT_SIZE === 4 ? sprintf('%u', $compressedSize) : $compressedSize;
         $content = '';
 
         if ($compressedSize > 0) {
@@ -587,8 +584,11 @@ class ZipInputStream implements ZipInputStreamInterface
     public function copyEntry(ZipEntry $entry, ZipOutputStreamInterface $out)
     {
         $pos = $entry->getOffset();
-        \assert($pos !== ZipEntry::UNKNOWN);
-        $pos = \PHP_INT_SIZE === 4 ? sprintf('%u', $pos) : $pos;
+
+        if ($pos === ZipEntry::UNKNOWN) {
+            throw new ZipException(sprintf('Missing local header offset for entry %s', $entry->getName()));
+        }
+
         $pos = $this->mapper->map($pos);
 
         $nameLength = \strlen($entry->getName());
@@ -688,7 +688,6 @@ class ZipInputStream implements ZipInputStreamInterface
     public function copyEntryData(ZipEntry $entry, ZipOutputStreamInterface $out)
     {
         $offset = $entry->getOffset();
-        $offset = \PHP_INT_SIZE === 4 ? sprintf('%u', $offset) : $offset;
         $offset = $this->mapper->map($offset);
         $nameLength = \strlen($entry->getName());
 

+ 12 - 3
src/PhpZip/Stream/ZipOutputStream.php

@@ -179,8 +179,17 @@ class ZipOutputStream implements ZipOutputStreamInterface
             fwrite($this->out, $entryContent);
         }
 
-        \assert($entry->getCrc() !== ZipEntry::UNKNOWN);
-        \assert($entry->getSize() !== ZipEntry::UNKNOWN);
+        if ($entry->getCrc() === ZipEntry::UNKNOWN) {
+            throw new ZipException(sprintf('No crc for entry %s', $entry->getName()));
+        }
+
+        if ($entry->getSize() === ZipEntry::UNKNOWN) {
+            throw new ZipException(sprintf('No uncompressed size for entry %s', $entry->getName()));
+        }
+
+        if ($entry->getCompressedSize() === ZipEntry::UNKNOWN) {
+            throw new ZipException(sprintf('No compressed size for entry %s', $entry->getName()));
+        }
 
         if ($entry->getGeneralPurposeBitFlag(ZipEntry::GPBF_DATA_DESCRIPTOR)) {
             // data descriptor signature       4 bytes  (0x08074b50)
@@ -226,7 +235,7 @@ class ZipOutputStream implements ZipOutputStreamInterface
         $utf8 = true;
 
         if ($encrypted && $entry->getPassword() === null) {
-            throw new ZipException('Can not password from entry ' . $entry->getName());
+            throw new ZipException(sprintf('Password not set for entry %s', $entry->getName()));
         }
 
         // Compose General Purpose Bit Flag.

+ 0 - 1
tests/PhpZip/Issue24Test.php

@@ -9,7 +9,6 @@ use PhpZip\Util\CryptoUtil;
  * @internal
  *
  * @small
- * @covers
  */
 class Issue24Test extends ZipTestCase
 {

+ 9 - 2
tests/PhpZip/PhpZipExtResourceTest.php

@@ -3,6 +3,7 @@
 namespace PhpZip;
 
 use PhpZip\Exception\Crc32Exception;
+use PhpZip\Exception\RuntimeException;
 use PhpZip\Exception\ZipAuthenticationException;
 use PhpZip\Exception\ZipException;
 
@@ -12,7 +13,6 @@ use PhpZip\Exception\ZipException;
  * @internal
  *
  * @small
- * @covers
  */
 class PhpZipExtResourceTest extends ZipTestCase
 {
@@ -126,7 +126,14 @@ class PhpZipExtResourceTest extends ZipTestCase
      */
     public function testBug70752()
     {
-        $this->setExpectedException(ZipAuthenticationException::class, 'nvalid password for zip entry "bug70752.txt"');
+        if (\PHP_INT_SIZE === 4) { // php 32 bit
+            $this->setExpectedException(RuntimeException::class, 'Traditional PKWARE Encryption is not supported in 32-bit PHP.');
+        } else { // php 64 bit
+            $this->setExpectedException(
+                ZipAuthenticationException::class,
+                'nvalid password for zip entry "bug70752.txt"'
+            );
+        }
 
         $filename = __DIR__ . '/php-zip-ext-test-resources/bug70752.zip';
 

+ 0 - 1
tests/PhpZip/Zip64Test.php

@@ -8,7 +8,6 @@ use PhpZip\Exception\ZipException;
  * @internal
  *
  * @large
- * @covers
  */
 class Zip64Test extends ZipTestCase
 {

+ 0 - 1
tests/PhpZip/ZipAlignTest.php

@@ -11,7 +11,6 @@ use PhpZip\Util\CryptoUtil;
  * @internal
  *
  * @small
- * @covers
  */
 class ZipAlignTest extends ZipTestCase
 {

+ 0 - 1
tests/PhpZip/ZipEventTest.php

@@ -8,7 +8,6 @@ use PhpZip\Exception\ZipException;
  * @internal
  *
  * @small
- * @covers
  */
 class ZipEventTest extends ZipTestCase
 {

+ 0 - 1
tests/PhpZip/ZipFileAddDirTest.php

@@ -12,7 +12,6 @@ use PhpZip\Util\Iterator\IgnoreFilesRecursiveFilterIterator;
  * @internal
  *
  * @small
- * @covers
  */
 class ZipFileAddDirTest extends ZipTestCase
 {

+ 12 - 1
tests/PhpZip/ZipFileTest.php

@@ -19,7 +19,6 @@ use Zend\Diactoros\Response;
  * @internal
  *
  * @small
- * @covers
  */
 class ZipFileTest extends ZipTestCase
 {
@@ -44,6 +43,8 @@ class ZipFileTest extends ZipTestCase
         /** @noinspection PhpComposerExtensionStubsInspection */
         if (posix_getuid() === 0) {
             static::markTestSkipped('Skip the test for a user with root privileges');
+
+            return;
         }
 
         static::assertNotFalse(file_put_contents($this->outputFilename, 'content'));
@@ -170,6 +171,8 @@ class ZipFileTest extends ZipTestCase
 
         if (!\extension_loaded('gd')) {
             static::markTestSkipped('not extension gd');
+
+            return;
         }
         /** @noinspection PhpComposerExtensionStubsInspection */
         $zipFile->openFromStream(imagecreate(1, 1));
@@ -425,6 +428,8 @@ class ZipFileTest extends ZipTestCase
     {
         if (!\function_exists('mime_content_type')) {
             static::markTestSkipped('Function mime_content_type not exists');
+
+            return;
         }
         $outputFilename = $this->outputFilename;
         $this->outputFilename .= '.gif';
@@ -1117,6 +1122,8 @@ class ZipFileTest extends ZipTestCase
         /** @noinspection PhpComposerExtensionStubsInspection */
         if (posix_getuid() === 0) {
             static::markTestSkipped('Skip the test for a user with root privileges');
+
+            return;
         }
 
         $zipFile = new ZipFile();
@@ -1341,6 +1348,8 @@ class ZipFileTest extends ZipTestCase
         /** @noinspection PhpComposerExtensionStubsInspection */
         if (posix_getuid() === 0) {
             static::markTestSkipped('Skip the test for a user with root privileges');
+
+            return;
         }
 
         static::assertNotFalse(file_put_contents($this->outputFilename, ''));
@@ -1658,6 +1667,8 @@ class ZipFileTest extends ZipTestCase
         /** @noinspection PhpComposerExtensionStubsInspection */
         if (posix_getuid() === 0) {
             static::markTestSkipped('Skip the test for a user with root privileges');
+
+            return;
         }
 
         static::assertTrue(mkdir($this->outputDirname, 0444, true));

+ 0 - 1
tests/PhpZip/ZipMatcherTest.php

@@ -11,7 +11,6 @@ use PhpZip\Util\CryptoUtil;
  * @internal
  *
  * @small
- * @covers
  */
 class ZipMatcherTest extends TestCase
 {

+ 9 - 9
tests/PhpZip/ZipPasswordTest.php

@@ -2,6 +2,7 @@
 
 namespace PhpZip;
 
+use PhpZip\Exception\RuntimeException;
 use PhpZip\Exception\ZipAuthenticationException;
 use PhpZip\Exception\ZipEntryNotFoundException;
 use PhpZip\Exception\ZipException;
@@ -14,7 +15,6 @@ use PhpZip\Util\CryptoUtil;
  * @internal
  *
  * @small
- * @covers
  */
 class ZipPasswordTest extends ZipFileAddDirTest
 {
@@ -25,8 +25,8 @@ class ZipPasswordTest extends ZipFileAddDirTest
      */
     public function testSetPassword()
     {
-        if (\PHP_INT_SIZE === 4) {
-            static::markTestSkipped('Skip test for 32-bit system. Not support Traditional PKWARE Encryption.');
+        if (\PHP_INT_SIZE === 4) { // php 32 bit
+            $this->setExpectedException(RuntimeException::class, 'Traditional PKWARE Encryption is not supported in 32-bit PHP.');
         }
 
         $password = base64_encode(CryptoUtil::randomBytes(100));
@@ -120,8 +120,8 @@ class ZipPasswordTest extends ZipFileAddDirTest
      */
     public function testTraditionalEncryption()
     {
-        if (\PHP_INT_SIZE === 4) {
-            static::markTestSkipped('Skip test for 32-bit system. Not support Traditional PKWARE Encryption.');
+        if (\PHP_INT_SIZE === 4) { // php 32 bit
+            $this->setExpectedException(RuntimeException::class, 'Traditional PKWARE Encryption is not supported in 32-bit PHP.');
         }
 
         $password = base64_encode(CryptoUtil::randomBytes(50));
@@ -200,8 +200,8 @@ class ZipPasswordTest extends ZipFileAddDirTest
      */
     public function testEncryptionEntries()
     {
-        if (\PHP_INT_SIZE === 4) {
-            static::markTestSkipped('Skip test for 32-bit system. Not support Traditional PKWARE Encryption.');
+        if (\PHP_INT_SIZE === 4) { // php 32 bit
+            $this->setExpectedException(RuntimeException::class, 'Traditional PKWARE Encryption is not supported in 32-bit PHP.');
         }
 
         $password1 = '353442434235424234';
@@ -247,8 +247,8 @@ class ZipPasswordTest extends ZipFileAddDirTest
      */
     public function testEncryptionEntriesWithDefaultPassword()
     {
-        if (\PHP_INT_SIZE === 4) {
-            static::markTestSkipped('Skip test for 32-bit system. Not support Traditional PKWARE Encryption.');
+        if (\PHP_INT_SIZE === 4) { // php 32 bit
+            $this->setExpectedException(RuntimeException::class, 'Traditional PKWARE Encryption is not supported in 32-bit PHP.');
         }
 
         $password1 = '353442434235424234';

+ 0 - 1
tests/PhpZip/ZipRemoteFileTest.php

@@ -10,7 +10,6 @@ use PhpZip\Exception\ZipException;
  * @internal
  *
  * @small
- * @covers
  */
 class ZipRemoteFileTest extends ZipTestCase
 {

+ 0 - 1
tests/PhpZip/ZipSlipVulnerabilityTest.php

@@ -11,7 +11,6 @@ namespace PhpZip;
  * @internal
  *
  * @small
- * @covers
  */
 class ZipSlipVulnerabilityTest extends ZipTestCase
 {