@@ -39,11 +39,10 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public static function getEncryptionMethodName($value) |
| 41 | 41 | { |
| 42 | - $value = (int) $value; |
|
| 42 | + $value = (int)$value; |
|
| 43 | 43 | |
| 44 | 44 | return isset(self::$ENCRYPTION_METHODS[$value]) ? |
| 45 | - self::$ENCRYPTION_METHODS[$value] : |
|
| 46 | - 'Unknown Encryption Method'; |
|
| 45 | + self::$ENCRYPTION_METHODS[$value] : 'Unknown Encryption Method'; |
|
| 47 | 46 | } |
| 48 | 47 | |
| 49 | 48 | /** |
@@ -64,7 +63,7 @@ discard block |
||
| 64 | 63 | public static function isWinZipAesMethod($encryptionMethod) |
| 65 | 64 | { |
| 66 | 65 | return \in_array( |
| 67 | - (int) $encryptionMethod, |
|
| 66 | + (int)$encryptionMethod, |
|
| 68 | 67 | [ |
| 69 | 68 | self::WINZIP_AES_256, |
| 70 | 69 | self::WINZIP_AES_192, |
@@ -81,7 +80,7 @@ discard block |
||
| 81 | 80 | */ |
| 82 | 81 | public static function checkSupport($encryptionMethod) |
| 83 | 82 | { |
| 84 | - $encryptionMethod = (int) $encryptionMethod; |
|
| 83 | + $encryptionMethod = (int)$encryptionMethod; |
|
| 85 | 84 | |
| 86 | 85 | if (!self::hasEncryptionMethod($encryptionMethod)) { |
| 87 | 86 | throw new InvalidArgumentException(sprintf( |
@@ -57,8 +57,7 @@ discard block |
||
| 57 | 57 | public static function getCompressionMethodName($value) |
| 58 | 58 | { |
| 59 | 59 | return isset(self::$ZIP_COMPRESSION_METHODS[$value]) ? |
| 60 | - self::$ZIP_COMPRESSION_METHODS[$value] : |
|
| 61 | - 'Unknown Method'; |
|
| 60 | + self::$ZIP_COMPRESSION_METHODS[$value] : 'Unknown Method'; |
|
| 62 | 61 | } |
| 63 | 62 | |
| 64 | 63 | /** |
@@ -89,7 +88,7 @@ discard block |
||
| 89 | 88 | */ |
| 90 | 89 | public static function checkSupport($compressionMethod) |
| 91 | 90 | { |
| 92 | - $compressionMethod = (int) $compressionMethod; |
|
| 91 | + $compressionMethod = (int)$compressionMethod; |
|
| 93 | 92 | |
| 94 | 93 | if (!\in_array($compressionMethod, self::getSupportMethods(), true)) { |
| 95 | 94 | throw new ZipUnsupportMethodException(sprintf( |
@@ -39,11 +39,11 @@ |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | return mktime( |
| 42 | - ($dosTime >> 11) & 0x1f, // hour |
|
| 43 | - ($dosTime >> 5) & 0x3f, // minute |
|
| 44 | - 2 * ($dosTime & 0x1f), // second |
|
| 45 | - ($dosTime >> 21) & 0x0f, // month |
|
| 46 | - ($dosTime >> 16) & 0x1f, // day |
|
| 42 | + ($dosTime >> 11) & 0x1f, // hour |
|
| 43 | + ($dosTime >> 5) & 0x3f, // minute |
|
| 44 | + 2 * ($dosTime & 0x1f), // second |
|
| 45 | + ($dosTime >> 21) & 0x0f, // month |
|
| 46 | + ($dosTime >> 16) & 0x1f, // day |
|
| 47 | 47 | 1980 + (($dosTime >> 25) & 0x7f) // year |
| 48 | 48 | ); |
| 49 | 49 | } |
@@ -189,8 +189,8 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | public static function globFileSearch($globPattern, $flags = 0, $recursive = true) |
| 191 | 191 | { |
| 192 | - $flags = (int) $flags; |
|
| 193 | - $recursive = (bool) $recursive; |
|
| 192 | + $flags = (int)$flags; |
|
| 193 | + $recursive = (bool)$recursive; |
|
| 194 | 194 | $files = glob($globPattern, $flags); |
| 195 | 195 | |
| 196 | 196 | if (!$recursive) { |
@@ -274,8 +274,8 @@ discard block |
||
| 274 | 274 | return implode( |
| 275 | 275 | '/', |
| 276 | 276 | array_filter( |
| 277 | - explode('/', (string) $path), |
|
| 278 | - static function ($part) { |
|
| 277 | + explode('/', (string)$path), |
|
| 278 | + static function($part) { |
|
| 279 | 279 | return $part !== '.' && $part !== '..'; |
| 280 | 280 | } |
| 281 | 281 | ) |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | */ |
| 454 | 454 | public static function getMimeTypeFromString($contents) |
| 455 | 455 | { |
| 456 | - $contents = (string) $contents; |
|
| 456 | + $contents = (string)$contents; |
|
| 457 | 457 | $finfo = new \finfo(\FILEINFO_MIME); |
| 458 | 458 | $mimeType = $finfo->buffer($contents); |
| 459 | 459 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public static function getDosMode($xattr) |
| 23 | 23 | { |
| 24 | - $xattr = (int) $xattr; |
|
| 24 | + $xattr = (int)$xattr; |
|
| 25 | 25 | |
| 26 | 26 | $mode = (($xattr & self::DOS_DIRECTORY) === self::DOS_DIRECTORY) ? 'd' : '-'; |
| 27 | 27 | $mode .= (($xattr & self::DOS_ARCHIVE) === self::DOS_ARCHIVE) ? 'a' : '-'; |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | public static function getUnixMode($permission) |
| 42 | 42 | { |
| 43 | 43 | $mode = ''; |
| 44 | - $permission = (int) $permission; |
|
| 44 | + $permission = (int)$permission; |
|
| 45 | 45 | switch ($permission & self::UNX_IFMT) { |
| 46 | 46 | case self::UNX_IFDIR: |
| 47 | 47 | $mode .= 'd'; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | if ($permission & self::UNX_IXUSR) { |
| 82 | 82 | $mode .= ($permission & self::UNX_ISUID) ? 's' : 'x'; |
| 83 | 83 | } else { |
| 84 | - $mode .= ($permission & self::UNX_ISUID) ? 'S' : '-'; // S==undefined |
|
| 84 | + $mode .= ($permission & self::UNX_ISUID) ? 'S' : '-'; // S==undefined |
|
| 85 | 85 | } |
| 86 | 86 | $mode .= ($permission & self::UNX_IRGRP) ? 'r' : '-'; |
| 87 | 87 | $mode .= ($permission & self::UNX_IWGRP) ? 'w' : '-'; |
@@ -49,6 +49,6 @@ |
||
| 49 | 49 | */ |
| 50 | 50 | public static function isASCII($name) |
| 51 | 51 | { |
| 52 | - return preg_match('~[^\x20-\x7e]~', (string) $name) === 0; |
|
| 52 | + return preg_match('~[^\x20-\x7e]~', (string)$name) === 0; |
|
| 53 | 53 | } |
| 54 | 54 | } |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | if (!empty($entries)) { |
| 393 | 393 | if (\is_string($entries)) { |
| 394 | - $entries = (array) $entries; |
|
| 394 | + $entries = (array)$entries; |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | if (\is_array($entries)) { |
@@ -545,12 +545,12 @@ discard block |
||
| 545 | 545 | throw new InvalidArgumentException('Contents is null'); |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | - $entryName = ltrim((string) $entryName, '\\/'); |
|
| 548 | + $entryName = ltrim((string)$entryName, '\\/'); |
|
| 549 | 549 | |
| 550 | 550 | if ($entryName === '') { |
| 551 | 551 | throw new InvalidArgumentException('Empty entry name'); |
| 552 | 552 | } |
| 553 | - $contents = (string) $contents; |
|
| 553 | + $contents = (string)$contents; |
|
| 554 | 554 | $length = \strlen($contents); |
| 555 | 555 | |
| 556 | 556 | if ($compressionMethod === null || $compressionMethod === ZipEntry::UNKNOWN) { |
@@ -559,8 +559,7 @@ discard block |
||
| 559 | 559 | } else { |
| 560 | 560 | $mimeType = FilesUtil::getMimeTypeFromString($contents); |
| 561 | 561 | $compressionMethod = FilesUtil::isBadCompressionMimeType($mimeType) ? |
| 562 | - ZipCompressionMethod::STORED : |
|
| 563 | - ZipCompressionMethod::DEFLATED; |
|
| 562 | + ZipCompressionMethod::STORED : ZipCompressionMethod::DEFLATED; |
|
| 564 | 563 | } |
| 565 | 564 | } |
| 566 | 565 | |
@@ -643,7 +642,7 @@ discard block |
||
| 643 | 642 | } |
| 644 | 643 | } |
| 645 | 644 | |
| 646 | - $entryName = ltrim((string) $entryName, '\\/'); |
|
| 645 | + $entryName = ltrim((string)$entryName, '\\/'); |
|
| 647 | 646 | |
| 648 | 647 | if ($entryName === '') { |
| 649 | 648 | throw new InvalidArgumentException('Empty entry name'); |
@@ -661,8 +660,7 @@ discard block |
||
| 661 | 660 | $compressionMethod = ZipCompressionMethod::STORED; |
| 662 | 661 | } else { |
| 663 | 662 | $compressionMethod = FilesUtil::isBadCompressionFile($file->getPathname()) ? |
| 664 | - ZipCompressionMethod::STORED : |
|
| 665 | - ZipCompressionMethod::DEFLATED; |
|
| 663 | + ZipCompressionMethod::STORED : ZipCompressionMethod::DEFLATED; |
|
| 666 | 664 | } |
| 667 | 665 | |
| 668 | 666 | $zipEntry->setUncompressedSize($file->getSize()); |
@@ -698,7 +696,7 @@ discard block |
||
| 698 | 696 | if ($mtime instanceof \DateTimeInterface) { |
| 699 | 697 | $timestamp = $mtime->getTimestamp(); |
| 700 | 698 | } elseif (is_numeric($mtime)) { |
| 701 | - $timestamp = (int) $mtime; |
|
| 699 | + $timestamp = (int)$mtime; |
|
| 702 | 700 | } elseif (\is_string($mtime)) { |
| 703 | 701 | $timestamp = strtotime($mtime); |
| 704 | 702 | |
@@ -784,7 +782,7 @@ discard block |
||
| 784 | 782 | if ($entryName === null) { |
| 785 | 783 | throw new InvalidArgumentException('Entry name is null'); |
| 786 | 784 | } |
| 787 | - $entryName = ltrim((string) $entryName, '\\/'); |
|
| 785 | + $entryName = ltrim((string)$entryName, '\\/'); |
|
| 788 | 786 | |
| 789 | 787 | if ($entryName === '') { |
| 790 | 788 | throw new InvalidArgumentException('Empty entry name'); |
@@ -794,7 +792,7 @@ discard block |
||
| 794 | 792 | $zipEntry = new ZipEntry($entryName); |
| 795 | 793 | |
| 796 | 794 | if ($fstat !== false) { |
| 797 | - $unixMode = (int) sprintf('%o', $fstat['mode']); |
|
| 795 | + $unixMode = (int)sprintf('%o', $fstat['mode']); |
|
| 798 | 796 | $length = $fstat['size']; |
| 799 | 797 | |
| 800 | 798 | if ($compressionMethod === null || $compressionMethod === ZipEntry::UNKNOWN) { |
@@ -806,8 +804,7 @@ discard block |
||
| 806 | 804 | rewind($stream); |
| 807 | 805 | $mimeType = FilesUtil::getMimeTypeFromString($bufferContents); |
| 808 | 806 | $compressionMethod = FilesUtil::isBadCompressionMimeType($mimeType) ? |
| 809 | - ZipCompressionMethod::STORED : |
|
| 810 | - ZipCompressionMethod::DEFLATED; |
|
| 807 | + ZipCompressionMethod::STORED : ZipCompressionMethod::DEFLATED; |
|
| 811 | 808 | } |
| 812 | 809 | $zipEntry->setUncompressedSize($length); |
| 813 | 810 | } |
@@ -845,7 +842,7 @@ discard block |
||
| 845 | 842 | if ($dirName === null) { |
| 846 | 843 | throw new InvalidArgumentException('Dir name is null'); |
| 847 | 844 | } |
| 848 | - $dirName = ltrim((string) $dirName, '\\/'); |
|
| 845 | + $dirName = ltrim((string)$dirName, '\\/'); |
|
| 849 | 846 | |
| 850 | 847 | if ($dirName === '') { |
| 851 | 848 | throw new InvalidArgumentException('Empty dir name'); |
@@ -887,7 +884,7 @@ discard block |
||
| 887 | 884 | if ($inputDir === null) { |
| 888 | 885 | throw new InvalidArgumentException('Input dir is null'); |
| 889 | 886 | } |
| 890 | - $inputDir = (string) $inputDir; |
|
| 887 | + $inputDir = (string)$inputDir; |
|
| 891 | 888 | |
| 892 | 889 | if ($inputDir === '') { |
| 893 | 890 | throw new InvalidArgumentException('The input directory is not specified'); |
@@ -926,7 +923,7 @@ discard block |
||
| 926 | 923 | if ($inputDir === null) { |
| 927 | 924 | throw new InvalidArgumentException('Input dir is null'); |
| 928 | 925 | } |
| 929 | - $inputDir = (string) $inputDir; |
|
| 926 | + $inputDir = (string)$inputDir; |
|
| 930 | 927 | |
| 931 | 928 | if ($inputDir === '') { |
| 932 | 929 | throw new InvalidArgumentException('The input directory is not specified'); |
@@ -965,7 +962,7 @@ discard block |
||
| 965 | 962 | $localPath = '/', |
| 966 | 963 | $compressionMethod = null |
| 967 | 964 | ) { |
| 968 | - $localPath = (string) $localPath; |
|
| 965 | + $localPath = (string)$localPath; |
|
| 969 | 966 | |
| 970 | 967 | if ($localPath !== '') { |
| 971 | 968 | $localPath = trim($localPath, '\\/'); |
@@ -974,8 +971,7 @@ discard block |
||
| 974 | 971 | } |
| 975 | 972 | |
| 976 | 973 | $iterator = $iterator instanceof \RecursiveIterator ? |
| 977 | - new \RecursiveIteratorIterator($iterator) : |
|
| 978 | - new \IteratorIterator($iterator); |
|
| 974 | + new \RecursiveIteratorIterator($iterator) : new \IteratorIterator($iterator); |
|
| 979 | 975 | /** |
| 980 | 976 | * @var string[] $files |
| 981 | 977 | * @var string $path |
@@ -1056,7 +1052,7 @@ discard block |
||
| 1056 | 1052 | if ($inputDir === null) { |
| 1057 | 1053 | throw new InvalidArgumentException('Input dir is null'); |
| 1058 | 1054 | } |
| 1059 | - $inputDir = (string) $inputDir; |
|
| 1055 | + $inputDir = (string)$inputDir; |
|
| 1060 | 1056 | |
| 1061 | 1057 | if ($inputDir === '') { |
| 1062 | 1058 | throw new InvalidArgumentException('The input directory is not specified'); |
@@ -1065,7 +1061,7 @@ discard block |
||
| 1065 | 1061 | if (!is_dir($inputDir)) { |
| 1066 | 1062 | throw new InvalidArgumentException(sprintf('The "%s" directory does not exist.', $inputDir)); |
| 1067 | 1063 | } |
| 1068 | - $globPattern = (string) $globPattern; |
|
| 1064 | + $globPattern = (string)$globPattern; |
|
| 1069 | 1065 | |
| 1070 | 1066 | if (empty($globPattern)) { |
| 1071 | 1067 | throw new InvalidArgumentException('The glob pattern is not specified'); |
@@ -1152,12 +1148,12 @@ discard block |
||
| 1152 | 1148 | $recursive = true, |
| 1153 | 1149 | $compressionMethod = null |
| 1154 | 1150 | ) { |
| 1155 | - $regexPattern = (string) $regexPattern; |
|
| 1151 | + $regexPattern = (string)$regexPattern; |
|
| 1156 | 1152 | |
| 1157 | 1153 | if (empty($regexPattern)) { |
| 1158 | 1154 | throw new InvalidArgumentException('The regex pattern is not specified'); |
| 1159 | 1155 | } |
| 1160 | - $inputDir = (string) $inputDir; |
|
| 1156 | + $inputDir = (string)$inputDir; |
|
| 1161 | 1157 | |
| 1162 | 1158 | if ($inputDir === '') { |
| 1163 | 1159 | throw new InvalidArgumentException('The input directory is not specified'); |
@@ -1263,8 +1259,8 @@ discard block |
||
| 1263 | 1259 | if ($oldName === null || $newName === null) { |
| 1264 | 1260 | throw new InvalidArgumentException('name is null'); |
| 1265 | 1261 | } |
| 1266 | - $oldName = ltrim((string) $oldName, '\\/'); |
|
| 1267 | - $newName = ltrim((string) $newName, '\\/'); |
|
| 1262 | + $oldName = ltrim((string)$oldName, '\\/'); |
|
| 1263 | + $newName = ltrim((string)$newName, '\\/'); |
|
| 1268 | 1264 | |
| 1269 | 1265 | if ($oldName !== $newName) { |
| 1270 | 1266 | $this->zipContainer->renameEntry($oldName, $newName); |
@@ -1284,7 +1280,7 @@ discard block |
||
| 1284 | 1280 | */ |
| 1285 | 1281 | public function deleteFromName($entryName) |
| 1286 | 1282 | { |
| 1287 | - $entryName = ltrim((string) $entryName, '\\/'); |
|
| 1283 | + $entryName = ltrim((string)$entryName, '\\/'); |
|
| 1288 | 1284 | |
| 1289 | 1285 | if (!$this->zipContainer->deleteEntry($entryName)) { |
| 1290 | 1286 | throw new ZipEntryNotFoundException($entryName); |
@@ -1357,7 +1353,7 @@ discard block |
||
| 1357 | 1353 | { |
| 1358 | 1354 | $this->matcher()->all()->invoke( |
| 1359 | 1355 | /** @param string $entry */ |
| 1360 | - function ($entry) use ($compressionLevel) { |
|
| 1356 | + function($entry) use ($compressionLevel) { |
|
| 1361 | 1357 | $this->setCompressionLevelEntry($entry, $compressionLevel); |
| 1362 | 1358 | } |
| 1363 | 1359 | ); |
@@ -1380,7 +1376,7 @@ discard block |
||
| 1380 | 1376 | */ |
| 1381 | 1377 | public function setCompressionLevelEntry($entryName, $compressionLevel) |
| 1382 | 1378 | { |
| 1383 | - $compressionLevel = (int) $compressionLevel; |
|
| 1379 | + $compressionLevel = (int)$compressionLevel; |
|
| 1384 | 1380 | $this->getEntry($entryName)->setCompressionLevel($compressionLevel); |
| 1385 | 1381 | |
| 1386 | 1382 | return $this; |
@@ -1570,7 +1566,7 @@ discard block |
||
| 1570 | 1566 | */ |
| 1571 | 1567 | public function saveAsFile($filename) |
| 1572 | 1568 | { |
| 1573 | - $filename = (string) $filename; |
|
| 1569 | + $filename = (string)$filename; |
|
| 1574 | 1570 | |
| 1575 | 1571 | $tempFilename = $filename . '.temp' . uniqid('', true); |
| 1576 | 1572 | |
@@ -1623,7 +1619,7 @@ discard block |
||
| 1623 | 1619 | */ |
| 1624 | 1620 | public function outputAsAttachment($outputFilename, $mimeType = null, $attachment = true) |
| 1625 | 1621 | { |
| 1626 | - $outputFilename = (string) $outputFilename; |
|
| 1622 | + $outputFilename = (string)$outputFilename; |
|
| 1627 | 1623 | |
| 1628 | 1624 | if ($mimeType === null) { |
| 1629 | 1625 | $mimeType = $this->getMimeTypeByFilename($outputFilename); |
@@ -1663,7 +1659,7 @@ discard block |
||
| 1663 | 1659 | */ |
| 1664 | 1660 | protected function getMimeTypeByFilename($outputFilename) |
| 1665 | 1661 | { |
| 1666 | - $outputFilename = (string) $outputFilename; |
|
| 1662 | + $outputFilename = (string)$outputFilename; |
|
| 1667 | 1663 | $ext = strtolower(pathinfo($outputFilename, \PATHINFO_EXTENSION)); |
| 1668 | 1664 | |
| 1669 | 1665 | if (!empty($ext) && isset(self::$defaultMimeTypes[$ext])) { |
@@ -1687,7 +1683,7 @@ discard block |
||
| 1687 | 1683 | */ |
| 1688 | 1684 | public function outputAsResponse(ResponseInterface $response, $outputFilename, $mimeType = null, $attachment = true) |
| 1689 | 1685 | { |
| 1690 | - $outputFilename = (string) $outputFilename; |
|
| 1686 | + $outputFilename = (string)$outputFilename; |
|
| 1691 | 1687 | |
| 1692 | 1688 | if ($mimeType === null) { |
| 1693 | 1689 | $mimeType = $this->getMimeTypeByFilename($outputFilename); |
@@ -1711,7 +1707,7 @@ discard block |
||
| 1711 | 1707 | |
| 1712 | 1708 | if ($size !== null) { |
| 1713 | 1709 | /** @noinspection CallableParameterUseCaseInTypeContextInspection */ |
| 1714 | - $response = $response->withHeader('Content-Length', (string) $size); |
|
| 1710 | + $response = $response->withHeader('Content-Length', (string)$size); |
|
| 1715 | 1711 | } |
| 1716 | 1712 | |
| 1717 | 1713 | return $response |
@@ -1837,7 +1833,7 @@ discard block |
||
| 1837 | 1833 | if ($entryName === null) { |
| 1838 | 1834 | throw new InvalidArgumentException('Key must not be null, but must contain the name of the zip entry.'); |
| 1839 | 1835 | } |
| 1840 | - $entryName = ltrim((string) $entryName, '\\/'); |
|
| 1836 | + $entryName = ltrim((string)$entryName, '\\/'); |
|
| 1841 | 1837 | |
| 1842 | 1838 | if ($entryName === '') { |
| 1843 | 1839 | throw new InvalidArgumentException('Key is empty, but must contain the name of the zip entry.'); |
@@ -1852,7 +1848,7 @@ discard block |
||
| 1852 | 1848 | } elseif (\is_resource($contents)) { |
| 1853 | 1849 | $this->addFromStream($contents, $entryName); |
| 1854 | 1850 | } else { |
| 1855 | - $this->addFromString($entryName, (string) $contents); |
|
| 1851 | + $this->addFromString($entryName, (string)$contents); |
|
| 1856 | 1852 | } |
| 1857 | 1853 | } |
| 1858 | 1854 | |