@@ -184,8 +184,7 @@ |
||
184 | 184 | public function encrypt($data) |
185 | 185 | { |
186 | 186 | $crc = $this->entry->isDataDescriptorRequired() ? |
187 | - ($this->entry->getDosTime() & 0x0000ffff) << 16 : |
|
188 | - $this->entry->getCrc(); |
|
187 | + ($this->entry->getDosTime() & 0x0000ffff) << 16 : $this->entry->getCrc(); |
|
189 | 188 | $headerBytes = CryptoUtil::randomBytes(self::STD_DEC_HDR_SIZE); |
190 | 189 | |
191 | 190 | // Initialize again since the generated bytes were encrypted. |
@@ -161,8 +161,7 @@ discard block |
||
161 | 161 | } |
162 | 162 | $data = substr($str, $i * 16, 16); |
163 | 163 | $ctrStr .= $encrypted ? |
164 | - self::encryptCtr($data, $key, $iv) : |
|
165 | - self::decryptCtr($data, $key, $iv); |
|
164 | + self::encryptCtr($data, $key, $iv) : self::decryptCtr($data, $key, $iv); |
|
166 | 165 | } |
167 | 166 | return $ctrStr; |
168 | 167 | } |
@@ -225,7 +224,7 @@ discard block |
||
225 | 224 | // Init key strength. |
226 | 225 | $password = $this->entry->getPassword(); |
227 | 226 | if ($password === null) { |
228 | - throw new ZipException('No password was set for the entry "'.$this->entry->getName().'"'); |
|
227 | + throw new ZipException('No password was set for the entry "' . $this->entry->getName() . '"'); |
|
229 | 228 | } |
230 | 229 | |
231 | 230 | // WinZip 99-character limit |
@@ -384,7 +384,7 @@ |
||
384 | 384 | $pos = $entry->getOffset(); |
385 | 385 | $pos = PHP_INT_SIZE === 4 |
386 | 386 | ? sprintf('%u', $pos) // PHP 32-Bit |
387 | - : $pos; // PHP 64-Bit |
|
387 | + : $pos; // PHP 64-Bit |
|
388 | 388 | |
389 | 389 | $startPos = $pos = $this->mapper->map($pos); |
390 | 390 | fseek($this->in, $startPos); |
@@ -253,8 +253,7 @@ |
||
253 | 253 | |
254 | 254 | case ZipFileInterface::METHOD_BZIP2: |
255 | 255 | $compressionLevel = $entry->getCompressionLevel() === ZipFileInterface::LEVEL_DEFAULT_COMPRESSION ? |
256 | - ZipEntry::LEVEL_DEFAULT_BZIP2_COMPRESSION : |
|
257 | - $entry->getCompressionLevel(); |
|
256 | + ZipEntry::LEVEL_DEFAULT_BZIP2_COMPRESSION : $entry->getCompressionLevel(); |
|
258 | 257 | /** @noinspection PhpComposerExtensionStubsInspection */ |
259 | 258 | $entryContent = bzcompress($entryContent, $compressionLevel); |
260 | 259 | if (is_int($entryContent)) { |
@@ -57,12 +57,9 @@ |
||
57 | 57 | public function getVersionNeededToExtract() |
58 | 58 | { |
59 | 59 | $method = $this->getMethod(); |
60 | - return self::METHOD_WINZIP_AES === $method ? 51 : |
|
61 | - ( |
|
62 | - ZipFileInterface::METHOD_BZIP2 === $method ? 46 : |
|
63 | - ( |
|
64 | - $this->isZip64ExtensionsRequired() ? 45 : |
|
65 | - (ZipFileInterface::METHOD_DEFLATED === $method || $this->isDirectory() ? 20 : 10) |
|
60 | + return self::METHOD_WINZIP_AES === $method ? 51 : ( |
|
61 | + ZipFileInterface::METHOD_BZIP2 === $method ? 46 : ( |
|
62 | + $this->isZip64ExtensionsRequired() ? 45 : (ZipFileInterface::METHOD_DEFLATED === $method || $this->isDirectory() ? 20 : 10) |
|
66 | 63 | ) |
67 | 64 | ); |
68 | 65 | } |
@@ -430,8 +430,7 @@ |
||
430 | 430 | { |
431 | 431 | $isInit = $this->isInit(self::BIT_METHOD); |
432 | 432 | return $isInit ? |
433 | - $this->method & 0xffff : |
|
434 | - self::UNKNOWN; |
|
433 | + $this->method & 0xffff : self::UNKNOWN; |
|
435 | 434 | } |
436 | 435 | |
437 | 436 | /** |
@@ -38,30 +38,30 @@ discard block |
||
38 | 38 | const MADE_BY_OS_X = 19; |
39 | 39 | const MADE_BY_UNKNOWN = 20; |
40 | 40 | |
41 | - const UNX_IFMT = 0170000; /* Unix file type mask */ |
|
42 | - const UNX_IFREG = 0100000; /* Unix regular file */ |
|
43 | - const UNX_IFSOCK = 0140000; /* Unix socket (BSD, not SysV or Amiga) */ |
|
44 | - const UNX_IFLNK = 0120000; /* Unix symbolic link (not SysV, Amiga) */ |
|
45 | - const UNX_IFBLK = 0060000; /* Unix block special (not Amiga) */ |
|
46 | - const UNX_IFDIR = 0040000; /* Unix directory */ |
|
47 | - const UNX_IFCHR = 0020000; /* Unix character special (not Amiga) */ |
|
48 | - const UNX_IFIFO = 0010000; /* Unix fifo (BCC, not MSC or Amiga) */ |
|
49 | - const UNX_ISUID = 04000; /* Unix set user id on execution */ |
|
50 | - const UNX_ISGID = 02000; /* Unix set group id on execution */ |
|
51 | - const UNX_ISVTX = 01000; /* Unix directory permissions control */ |
|
52 | - const UNX_ENFMT = self::UNX_ISGID; /* Unix record locking enforcement flag */ |
|
53 | - const UNX_IRWXU = 00700; /* Unix read, write, execute: owner */ |
|
54 | - const UNX_IRUSR = 00400; /* Unix read permission: owner */ |
|
55 | - const UNX_IWUSR = 00200; /* Unix write permission: owner */ |
|
56 | - const UNX_IXUSR = 00100; /* Unix execute permission: owner */ |
|
57 | - const UNX_IRWXG = 00070; /* Unix read, write, execute: group */ |
|
58 | - const UNX_IRGRP = 00040; /* Unix read permission: group */ |
|
59 | - const UNX_IWGRP = 00020; /* Unix write permission: group */ |
|
60 | - const UNX_IXGRP = 00010; /* Unix execute permission: group */ |
|
61 | - const UNX_IRWXO = 00007; /* Unix read, write, execute: other */ |
|
62 | - const UNX_IROTH = 00004; /* Unix read permission: other */ |
|
63 | - const UNX_IWOTH = 00002; /* Unix write permission: other */ |
|
64 | - const UNX_IXOTH = 00001; /* Unix execute permission: other */ |
|
41 | + const UNX_IFMT = 0170000; /* Unix file type mask */ |
|
42 | + const UNX_IFREG = 0100000; /* Unix regular file */ |
|
43 | + const UNX_IFSOCK = 0140000; /* Unix socket (BSD, not SysV or Amiga) */ |
|
44 | + const UNX_IFLNK = 0120000; /* Unix symbolic link (not SysV, Amiga) */ |
|
45 | + const UNX_IFBLK = 0060000; /* Unix block special (not Amiga) */ |
|
46 | + const UNX_IFDIR = 0040000; /* Unix directory */ |
|
47 | + const UNX_IFCHR = 0020000; /* Unix character special (not Amiga) */ |
|
48 | + const UNX_IFIFO = 0010000; /* Unix fifo (BCC, not MSC or Amiga) */ |
|
49 | + const UNX_ISUID = 04000; /* Unix set user id on execution */ |
|
50 | + const UNX_ISGID = 02000; /* Unix set group id on execution */ |
|
51 | + const UNX_ISVTX = 01000; /* Unix directory permissions control */ |
|
52 | + const UNX_ENFMT = self::UNX_ISGID; /* Unix record locking enforcement flag */ |
|
53 | + const UNX_IRWXU = 00700; /* Unix read, write, execute: owner */ |
|
54 | + const UNX_IRUSR = 00400; /* Unix read permission: owner */ |
|
55 | + const UNX_IWUSR = 00200; /* Unix write permission: owner */ |
|
56 | + const UNX_IXUSR = 00100; /* Unix execute permission: owner */ |
|
57 | + const UNX_IRWXG = 00070; /* Unix read, write, execute: group */ |
|
58 | + const UNX_IRGRP = 00040; /* Unix read permission: group */ |
|
59 | + const UNX_IWGRP = 00020; /* Unix write permission: group */ |
|
60 | + const UNX_IXGRP = 00010; /* Unix execute permission: group */ |
|
61 | + const UNX_IRWXO = 00007; /* Unix read, write, execute: other */ |
|
62 | + const UNX_IROTH = 00004; /* Unix read permission: other */ |
|
63 | + const UNX_IWOTH = 00002; /* Unix write permission: other */ |
|
64 | + const UNX_IXOTH = 00001; /* Unix execute permission: other */ |
|
65 | 65 | |
66 | 66 | private static $valuesMadeBy = [ |
67 | 67 | self::MADE_BY_MS_DOS => 'FAT', |
@@ -207,11 +207,9 @@ discard block |
||
207 | 207 | $this->name = $entry->getName(); |
208 | 208 | $this->folder = $entry->isDirectory(); |
209 | 209 | $this->size = PHP_INT_SIZE === 4 ? |
210 | - sprintf('%u', $entry->getSize()) : |
|
211 | - $entry->getSize(); |
|
210 | + sprintf('%u', $entry->getSize()) : $entry->getSize(); |
|
212 | 211 | $this->compressedSize = PHP_INT_SIZE === 4 ? |
213 | - sprintf('%u', $entry->getCompressedSize()) : |
|
214 | - $entry->getCompressedSize(); |
|
212 | + sprintf('%u', $entry->getCompressedSize()) : $entry->getCompressedSize(); |
|
215 | 213 | $this->mtime = $mtime; |
216 | 214 | $this->ctime = $ctime; |
217 | 215 | $this->atime = $atime; |
@@ -228,8 +226,7 @@ discard block |
||
228 | 226 | $attributes = str_repeat(" ", 12); |
229 | 227 | $externalAttributes = $entry->getExternalAttributes(); |
230 | 228 | $externalAttributes = PHP_INT_SIZE === 4 ? |
231 | - sprintf('%u', $externalAttributes) : |
|
232 | - $externalAttributes; |
|
229 | + sprintf('%u', $externalAttributes) : $externalAttributes; |
|
233 | 230 | $xattr = (($externalAttributes >> 16) & 0xFFFF); |
234 | 231 | switch ($entry->getPlatform()) { |
235 | 232 | case self::MADE_BY_MS_DOS: |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | public function add($entries) |
35 | 35 | { |
36 | 36 | $entries = (array)$entries; |
37 | - $entries = array_map(function ($entry) { |
|
37 | + $entries = array_map(function($entry) { |
|
38 | 38 | return $entry instanceof ZipEntry ? $entry->getName() : $entry; |
39 | 39 | }, $entries); |
40 | 40 | $this->matches = array_unique( |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function match($regexp) |
59 | 59 | { |
60 | - array_walk($this->zipModel->getEntries(), function ( |
|
60 | + array_walk($this->zipModel->getEntries(), function( |
|
61 | 61 | /** @noinspection PhpUnusedParameterInspection */ |
62 | 62 | $entry, |
63 | 63 | $entryName |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | public function invoke(callable $callable) |
91 | 91 | { |
92 | 92 | if (!empty($this->matches)) { |
93 | - array_walk($this->matches, function ($entryName) use ($callable) { |
|
93 | + array_walk($this->matches, function($entryName) use ($callable) { |
|
94 | 94 | call_user_func($callable, $entryName); |
95 | 95 | }); |
96 | 96 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | public function delete() |
108 | 108 | { |
109 | - array_walk($this->matches, function ($entry) { |
|
109 | + array_walk($this->matches, function($entry) { |
|
110 | 110 | $this->zipModel->deleteEntry($entry); |
111 | 111 | }); |
112 | 112 | $this->matches = []; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function setPassword($password, $encryptionMethod = null) |
120 | 120 | { |
121 | - array_walk($this->matches, function ($entry) use ($password, $encryptionMethod) { |
|
121 | + array_walk($this->matches, function($entry) use ($password, $encryptionMethod) { |
|
122 | 122 | $entry = $this->zipModel->getEntry($entry); |
123 | 123 | if (!$entry->isDirectory()) { |
124 | 124 | $this->zipModel->getEntryForChanges($entry)->setPassword($password, $encryptionMethod); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public function setEncryptionMethod($encryptionMethod) |
133 | 133 | { |
134 | - array_walk($this->matches, function ($entry) use ($encryptionMethod) { |
|
134 | + array_walk($this->matches, function($entry) use ($encryptionMethod) { |
|
135 | 135 | $entry = $this->zipModel->getEntry($entry); |
136 | 136 | if (!$entry->isDirectory()) { |
137 | 137 | $this->zipModel->getEntryForChanges($entry)->setEncryptionMethod($encryptionMethod); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | public function disableEncryption() |
143 | 143 | { |
144 | - array_walk($this->matches, function ($entry) { |
|
144 | + array_walk($this->matches, function($entry) { |
|
145 | 145 | $entry = $this->zipModel->getEntry($entry); |
146 | 146 | if (!$entry->isDirectory()) { |
147 | 147 | $entry = $this->zipModel->getEntryForChanges($entry); |
@@ -139,18 +139,15 @@ |
||
139 | 139 | public static function fileSearchWithIgnore($inputDir, $recursive = true, array $ignoreFiles = []) |
140 | 140 | { |
141 | 141 | $directoryIterator = $recursive ? |
142 | - new \RecursiveDirectoryIterator($inputDir) : |
|
143 | - new \DirectoryIterator($inputDir); |
|
142 | + new \RecursiveDirectoryIterator($inputDir) : new \DirectoryIterator($inputDir); |
|
144 | 143 | |
145 | 144 | if (!empty($ignoreFiles)) { |
146 | 145 | $directoryIterator = $recursive ? |
147 | - new IgnoreFilesRecursiveFilterIterator($directoryIterator, $ignoreFiles) : |
|
148 | - new IgnoreFilesFilterIterator($directoryIterator, $ignoreFiles); |
|
146 | + new IgnoreFilesRecursiveFilterIterator($directoryIterator, $ignoreFiles) : new IgnoreFilesFilterIterator($directoryIterator, $ignoreFiles); |
|
149 | 147 | } |
150 | 148 | |
151 | 149 | $iterator = $recursive ? |
152 | - new \RecursiveIteratorIterator($directoryIterator) : |
|
153 | - new \IteratorIterator($directoryIterator); |
|
150 | + new \RecursiveIteratorIterator($directoryIterator) : new \IteratorIterator($directoryIterator); |
|
154 | 151 | |
155 | 152 | $fileList = []; |
156 | 153 | foreach ($iterator as $file) { |