@@ -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( |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | |
391 | 391 | if (!empty($entries)) { |
392 | 392 | if (\is_string($entries)) { |
393 | - $entries = (array) $entries; |
|
393 | + $entries = (array)$entries; |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | if (\is_array($entries)) { |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | * |
404 | 404 | * @return bool |
405 | 405 | */ |
406 | - static function ($entryName) use ($flipEntries) { |
|
406 | + static function($entryName) use ($flipEntries) { |
|
407 | 407 | return isset($flipEntries[$entryName]); |
408 | 408 | }, |
409 | 409 | \ARRAY_FILTER_USE_KEY |
@@ -556,12 +556,12 @@ discard block |
||
556 | 556 | throw new InvalidArgumentException('Contents is null'); |
557 | 557 | } |
558 | 558 | |
559 | - $entryName = ltrim((string) $entryName, '\\/'); |
|
559 | + $entryName = ltrim((string)$entryName, '\\/'); |
|
560 | 560 | |
561 | 561 | if ($entryName === '') { |
562 | 562 | throw new InvalidArgumentException('Empty entry name'); |
563 | 563 | } |
564 | - $contents = (string) $contents; |
|
564 | + $contents = (string)$contents; |
|
565 | 565 | $length = \strlen($contents); |
566 | 566 | |
567 | 567 | if ($compressionMethod === null || $compressionMethod === ZipEntry::UNKNOWN) { |
@@ -570,8 +570,7 @@ discard block |
||
570 | 570 | } else { |
571 | 571 | $mimeType = FilesUtil::getMimeTypeFromString($contents); |
572 | 572 | $compressionMethod = FilesUtil::isBadCompressionMimeType($mimeType) ? |
573 | - ZipCompressionMethod::STORED : |
|
574 | - ZipCompressionMethod::DEFLATED; |
|
573 | + ZipCompressionMethod::STORED : ZipCompressionMethod::DEFLATED; |
|
575 | 574 | } |
576 | 575 | } |
577 | 576 | |
@@ -654,7 +653,7 @@ discard block |
||
654 | 653 | } |
655 | 654 | } |
656 | 655 | |
657 | - $entryName = ltrim((string) $entryName, '\\/'); |
|
656 | + $entryName = ltrim((string)$entryName, '\\/'); |
|
658 | 657 | |
659 | 658 | if ($entryName === '') { |
660 | 659 | throw new InvalidArgumentException('Empty entry name'); |
@@ -672,8 +671,7 @@ discard block |
||
672 | 671 | $compressionMethod = ZipCompressionMethod::STORED; |
673 | 672 | } else { |
674 | 673 | $compressionMethod = FilesUtil::isBadCompressionFile($file->getPathname()) ? |
675 | - ZipCompressionMethod::STORED : |
|
676 | - ZipCompressionMethod::DEFLATED; |
|
674 | + ZipCompressionMethod::STORED : ZipCompressionMethod::DEFLATED; |
|
677 | 675 | } |
678 | 676 | |
679 | 677 | $zipEntry->setUncompressedSize($file->getSize()); |
@@ -709,7 +707,7 @@ discard block |
||
709 | 707 | if ($mtime instanceof \DateTimeInterface) { |
710 | 708 | $timestamp = $mtime->getTimestamp(); |
711 | 709 | } elseif (is_numeric($mtime)) { |
712 | - $timestamp = (int) $mtime; |
|
710 | + $timestamp = (int)$mtime; |
|
713 | 711 | } elseif (\is_string($mtime)) { |
714 | 712 | $timestamp = strtotime($mtime); |
715 | 713 | |
@@ -795,7 +793,7 @@ discard block |
||
795 | 793 | if ($entryName === null) { |
796 | 794 | throw new InvalidArgumentException('Entry name is null'); |
797 | 795 | } |
798 | - $entryName = ltrim((string) $entryName, '\\/'); |
|
796 | + $entryName = ltrim((string)$entryName, '\\/'); |
|
799 | 797 | |
800 | 798 | if ($entryName === '') { |
801 | 799 | throw new InvalidArgumentException('Empty entry name'); |
@@ -805,7 +803,7 @@ discard block |
||
805 | 803 | $zipEntry = new ZipEntry($entryName); |
806 | 804 | |
807 | 805 | if ($fstat !== false) { |
808 | - $unixMode = (int) sprintf('%o', $fstat['mode']); |
|
806 | + $unixMode = (int)sprintf('%o', $fstat['mode']); |
|
809 | 807 | $length = $fstat['size']; |
810 | 808 | |
811 | 809 | if ($compressionMethod === null || $compressionMethod === ZipEntry::UNKNOWN) { |
@@ -817,8 +815,7 @@ discard block |
||
817 | 815 | rewind($stream); |
818 | 816 | $mimeType = FilesUtil::getMimeTypeFromString($bufferContents); |
819 | 817 | $compressionMethod = FilesUtil::isBadCompressionMimeType($mimeType) ? |
820 | - ZipCompressionMethod::STORED : |
|
821 | - ZipCompressionMethod::DEFLATED; |
|
818 | + ZipCompressionMethod::STORED : ZipCompressionMethod::DEFLATED; |
|
822 | 819 | } |
823 | 820 | $zipEntry->setUncompressedSize($length); |
824 | 821 | } |
@@ -856,7 +853,7 @@ discard block |
||
856 | 853 | if ($dirName === null) { |
857 | 854 | throw new InvalidArgumentException('Dir name is null'); |
858 | 855 | } |
859 | - $dirName = ltrim((string) $dirName, '\\/'); |
|
856 | + $dirName = ltrim((string)$dirName, '\\/'); |
|
860 | 857 | |
861 | 858 | if ($dirName === '') { |
862 | 859 | throw new InvalidArgumentException('Empty dir name'); |
@@ -898,7 +895,7 @@ discard block |
||
898 | 895 | if ($inputDir === null) { |
899 | 896 | throw new InvalidArgumentException('Input dir is null'); |
900 | 897 | } |
901 | - $inputDir = (string) $inputDir; |
|
898 | + $inputDir = (string)$inputDir; |
|
902 | 899 | |
903 | 900 | if ($inputDir === '') { |
904 | 901 | throw new InvalidArgumentException('The input directory is not specified'); |
@@ -937,7 +934,7 @@ discard block |
||
937 | 934 | if ($inputDir === null) { |
938 | 935 | throw new InvalidArgumentException('Input dir is null'); |
939 | 936 | } |
940 | - $inputDir = (string) $inputDir; |
|
937 | + $inputDir = (string)$inputDir; |
|
941 | 938 | |
942 | 939 | if ($inputDir === '') { |
943 | 940 | throw new InvalidArgumentException('The input directory is not specified'); |
@@ -976,7 +973,7 @@ discard block |
||
976 | 973 | $localPath = '/', |
977 | 974 | $compressionMethod = null |
978 | 975 | ) { |
979 | - $localPath = (string) $localPath; |
|
976 | + $localPath = (string)$localPath; |
|
980 | 977 | |
981 | 978 | if ($localPath !== '') { |
982 | 979 | $localPath = trim($localPath, '\\/'); |
@@ -985,8 +982,7 @@ discard block |
||
985 | 982 | } |
986 | 983 | |
987 | 984 | $iterator = $iterator instanceof \RecursiveIterator ? |
988 | - new \RecursiveIteratorIterator($iterator) : |
|
989 | - new \IteratorIterator($iterator); |
|
985 | + new \RecursiveIteratorIterator($iterator) : new \IteratorIterator($iterator); |
|
990 | 986 | /** |
991 | 987 | * @var string[] $files |
992 | 988 | * @var string $path |
@@ -1067,7 +1063,7 @@ discard block |
||
1067 | 1063 | if ($inputDir === null) { |
1068 | 1064 | throw new InvalidArgumentException('Input dir is null'); |
1069 | 1065 | } |
1070 | - $inputDir = (string) $inputDir; |
|
1066 | + $inputDir = (string)$inputDir; |
|
1071 | 1067 | |
1072 | 1068 | if ($inputDir === '') { |
1073 | 1069 | throw new InvalidArgumentException('The input directory is not specified'); |
@@ -1076,7 +1072,7 @@ discard block |
||
1076 | 1072 | if (!is_dir($inputDir)) { |
1077 | 1073 | throw new InvalidArgumentException(sprintf('The "%s" directory does not exist.', $inputDir)); |
1078 | 1074 | } |
1079 | - $globPattern = (string) $globPattern; |
|
1075 | + $globPattern = (string)$globPattern; |
|
1080 | 1076 | |
1081 | 1077 | if (empty($globPattern)) { |
1082 | 1078 | throw new InvalidArgumentException('The glob pattern is not specified'); |
@@ -1163,12 +1159,12 @@ discard block |
||
1163 | 1159 | $recursive = true, |
1164 | 1160 | $compressionMethod = null |
1165 | 1161 | ) { |
1166 | - $regexPattern = (string) $regexPattern; |
|
1162 | + $regexPattern = (string)$regexPattern; |
|
1167 | 1163 | |
1168 | 1164 | if (empty($regexPattern)) { |
1169 | 1165 | throw new InvalidArgumentException('The regex pattern is not specified'); |
1170 | 1166 | } |
1171 | - $inputDir = (string) $inputDir; |
|
1167 | + $inputDir = (string)$inputDir; |
|
1172 | 1168 | |
1173 | 1169 | if ($inputDir === '') { |
1174 | 1170 | throw new InvalidArgumentException('The input directory is not specified'); |
@@ -1274,8 +1270,8 @@ discard block |
||
1274 | 1270 | if ($oldName === null || $newName === null) { |
1275 | 1271 | throw new InvalidArgumentException('name is null'); |
1276 | 1272 | } |
1277 | - $oldName = ltrim((string) $oldName, '\\/'); |
|
1278 | - $newName = ltrim((string) $newName, '\\/'); |
|
1273 | + $oldName = ltrim((string)$oldName, '\\/'); |
|
1274 | + $newName = ltrim((string)$newName, '\\/'); |
|
1279 | 1275 | |
1280 | 1276 | if ($oldName !== $newName) { |
1281 | 1277 | $this->zipContainer->renameEntry($oldName, $newName); |
@@ -1295,7 +1291,7 @@ discard block |
||
1295 | 1291 | */ |
1296 | 1292 | public function deleteFromName($entryName) |
1297 | 1293 | { |
1298 | - $entryName = ltrim((string) $entryName, '\\/'); |
|
1294 | + $entryName = ltrim((string)$entryName, '\\/'); |
|
1299 | 1295 | |
1300 | 1296 | if (!$this->zipContainer->deleteEntry($entryName)) { |
1301 | 1297 | throw new ZipEntryNotFoundException($entryName); |
@@ -1368,7 +1364,7 @@ discard block |
||
1368 | 1364 | { |
1369 | 1365 | $this->matcher()->all()->invoke( |
1370 | 1366 | /** @param string $entry */ |
1371 | - function ($entry) use ($compressionLevel) { |
|
1367 | + function($entry) use ($compressionLevel) { |
|
1372 | 1368 | $this->setCompressionLevelEntry($entry, $compressionLevel); |
1373 | 1369 | } |
1374 | 1370 | ); |
@@ -1391,7 +1387,7 @@ discard block |
||
1391 | 1387 | */ |
1392 | 1388 | public function setCompressionLevelEntry($entryName, $compressionLevel) |
1393 | 1389 | { |
1394 | - $compressionLevel = (int) $compressionLevel; |
|
1390 | + $compressionLevel = (int)$compressionLevel; |
|
1395 | 1391 | $this->getEntry($entryName)->setCompressionLevel($compressionLevel); |
1396 | 1392 | |
1397 | 1393 | return $this; |
@@ -1581,7 +1577,7 @@ discard block |
||
1581 | 1577 | */ |
1582 | 1578 | public function saveAsFile($filename) |
1583 | 1579 | { |
1584 | - $filename = (string) $filename; |
|
1580 | + $filename = (string)$filename; |
|
1585 | 1581 | |
1586 | 1582 | $tempFilename = $filename . '.temp' . uniqid('', true); |
1587 | 1583 | |
@@ -1634,7 +1630,7 @@ discard block |
||
1634 | 1630 | */ |
1635 | 1631 | public function outputAsAttachment($outputFilename, $mimeType = null, $attachment = true) |
1636 | 1632 | { |
1637 | - $outputFilename = (string) $outputFilename; |
|
1633 | + $outputFilename = (string)$outputFilename; |
|
1638 | 1634 | |
1639 | 1635 | if ($mimeType === null) { |
1640 | 1636 | $mimeType = $this->getMimeTypeByFilename($outputFilename); |
@@ -1674,7 +1670,7 @@ discard block |
||
1674 | 1670 | */ |
1675 | 1671 | protected function getMimeTypeByFilename($outputFilename) |
1676 | 1672 | { |
1677 | - $outputFilename = (string) $outputFilename; |
|
1673 | + $outputFilename = (string)$outputFilename; |
|
1678 | 1674 | $ext = strtolower(pathinfo($outputFilename, \PATHINFO_EXTENSION)); |
1679 | 1675 | |
1680 | 1676 | if (!empty($ext) && isset(self::$defaultMimeTypes[$ext])) { |
@@ -1698,7 +1694,7 @@ discard block |
||
1698 | 1694 | */ |
1699 | 1695 | public function outputAsResponse(ResponseInterface $response, $outputFilename, $mimeType = null, $attachment = true) |
1700 | 1696 | { |
1701 | - $outputFilename = (string) $outputFilename; |
|
1697 | + $outputFilename = (string)$outputFilename; |
|
1702 | 1698 | |
1703 | 1699 | if ($mimeType === null) { |
1704 | 1700 | $mimeType = $this->getMimeTypeByFilename($outputFilename); |
@@ -1722,7 +1718,7 @@ discard block |
||
1722 | 1718 | |
1723 | 1719 | if ($size !== null) { |
1724 | 1720 | /** @noinspection CallableParameterUseCaseInTypeContextInspection */ |
1725 | - $response = $response->withHeader('Content-Length', (string) $size); |
|
1721 | + $response = $response->withHeader('Content-Length', (string)$size); |
|
1726 | 1722 | } |
1727 | 1723 | |
1728 | 1724 | return $response |
@@ -1848,7 +1844,7 @@ discard block |
||
1848 | 1844 | if ($entryName === null) { |
1849 | 1845 | throw new InvalidArgumentException('Key must not be null, but must contain the name of the zip entry.'); |
1850 | 1846 | } |
1851 | - $entryName = ltrim((string) $entryName, '\\/'); |
|
1847 | + $entryName = ltrim((string)$entryName, '\\/'); |
|
1852 | 1848 | |
1853 | 1849 | if ($entryName === '') { |
1854 | 1850 | throw new InvalidArgumentException('Key is empty, but must contain the name of the zip entry.'); |
@@ -1863,7 +1859,7 @@ discard block |
||
1863 | 1859 | } elseif (\is_resource($contents)) { |
1864 | 1860 | $this->addFromStream($contents, $entryName); |
1865 | 1861 | } else { |
1866 | - $this->addFromString($entryName, (string) $contents); |
|
1862 | + $this->addFromString($entryName, (string)$contents); |
|
1867 | 1863 | } |
1868 | 1864 | } |
1869 | 1865 |
@@ -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 | } |