@@ -135,7 +135,7 @@ |
||
135 | 135 | * Returns the stat of a file in the zip archive |
136 | 136 | * (name, index, crc, mtime, compression size, compression method, filesize). |
137 | 137 | * |
138 | - * @param $key |
|
138 | + * @param string $key |
|
139 | 139 | * |
140 | 140 | * @return array|bool |
141 | 141 | */ |
@@ -166,46 +166,46 @@ |
||
166 | 166 | |
167 | 167 | if (true !== ($resultCode = $this->zipArchive->open($this->zipFile, ZipArchive::CREATE))) { |
168 | 168 | switch ($resultCode) { |
169 | - case ZipArchive::ER_EXISTS: |
|
170 | - $errMsg = 'File already exists.'; |
|
169 | + case ZipArchive::ER_EXISTS: |
|
170 | + $errMsg = 'File already exists.'; |
|
171 | 171 | |
172 | - break; |
|
173 | - case ZipArchive::ER_INCONS: |
|
174 | - $errMsg = 'Zip archive inconsistent.'; |
|
172 | + break; |
|
173 | + case ZipArchive::ER_INCONS: |
|
174 | + $errMsg = 'Zip archive inconsistent.'; |
|
175 | 175 | |
176 | - break; |
|
177 | - case ZipArchive::ER_INVAL: |
|
178 | - $errMsg = 'Invalid argument.'; |
|
176 | + break; |
|
177 | + case ZipArchive::ER_INVAL: |
|
178 | + $errMsg = 'Invalid argument.'; |
|
179 | 179 | |
180 | - break; |
|
181 | - case ZipArchive::ER_MEMORY: |
|
182 | - $errMsg = 'Malloc failure.'; |
|
180 | + break; |
|
181 | + case ZipArchive::ER_MEMORY: |
|
182 | + $errMsg = 'Malloc failure.'; |
|
183 | 183 | |
184 | - break; |
|
185 | - case ZipArchive::ER_NOENT: |
|
186 | - $errMsg = 'Invalid argument.'; |
|
184 | + break; |
|
185 | + case ZipArchive::ER_NOENT: |
|
186 | + $errMsg = 'Invalid argument.'; |
|
187 | 187 | |
188 | - break; |
|
189 | - case ZipArchive::ER_NOZIP: |
|
190 | - $errMsg = 'Not a zip archive.'; |
|
188 | + break; |
|
189 | + case ZipArchive::ER_NOZIP: |
|
190 | + $errMsg = 'Not a zip archive.'; |
|
191 | 191 | |
192 | - break; |
|
193 | - case ZipArchive::ER_OPEN: |
|
194 | - $errMsg = 'Can\'t open file.'; |
|
192 | + break; |
|
193 | + case ZipArchive::ER_OPEN: |
|
194 | + $errMsg = 'Can\'t open file.'; |
|
195 | 195 | |
196 | - break; |
|
197 | - case ZipArchive::ER_READ: |
|
198 | - $errMsg = 'Read error.'; |
|
196 | + break; |
|
197 | + case ZipArchive::ER_READ: |
|
198 | + $errMsg = 'Read error.'; |
|
199 | 199 | |
200 | - break; |
|
201 | - case ZipArchive::ER_SEEK: |
|
202 | - $errMsg = 'Seek error.'; |
|
200 | + break; |
|
201 | + case ZipArchive::ER_SEEK: |
|
202 | + $errMsg = 'Seek error.'; |
|
203 | 203 | |
204 | - break; |
|
205 | - default: |
|
206 | - $errMsg = 'Unknown error.'; |
|
204 | + break; |
|
205 | + default: |
|
206 | + $errMsg = 'Unknown error.'; |
|
207 | 207 | |
208 | - break; |
|
208 | + break; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | throw new \RuntimeException(sprintf('%s', $errMsg)); |
@@ -213,7 +213,7 @@ |
||
213 | 213 | /** |
214 | 214 | * @param string $path |
215 | 215 | * |
216 | - * @return mixed |
|
216 | + * @return boolean |
|
217 | 217 | */ |
218 | 218 | public function unlink($path) |
219 | 219 | { |
@@ -257,11 +257,11 @@ |
||
257 | 257 | $key = substr($parts['path'], 1); |
258 | 258 | |
259 | 259 | if (null !== $parts['query']) { |
260 | - $key .= '?' . $parts['query']; |
|
260 | + $key .= '?'.$parts['query']; |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | if (null !== $parts['fragment']) { |
264 | - $key .= '#' . $parts['fragment']; |
|
264 | + $key .= '#'.$parts['fragment']; |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | if (empty($domain) || empty($key)) { |
@@ -287,6 +287,9 @@ |
||
287 | 287 | return true; |
288 | 288 | } |
289 | 289 | |
290 | + /** |
|
291 | + * @param string $key |
|
292 | + */ |
|
290 | 293 | protected function getOptions($key, array $options = []) |
291 | 294 | { |
292 | 295 | $options['ACL'] = $this->options['acl']; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $this->ensureBucketExists(); |
140 | 140 | $options = $this->getOptions( |
141 | 141 | $targetKey, |
142 | - ['CopySource' => $this->bucket . '/' . $this->computePath($sourceKey)] |
|
142 | + ['CopySource' => $this->bucket.'/'.$this->computePath($sourceKey)] |
|
143 | 143 | ); |
144 | 144 | |
145 | 145 | try { |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | { |
269 | 269 | $result = $this->service->listObjects([ |
270 | 270 | 'Bucket' => $this->bucket, |
271 | - 'Prefix' => rtrim($this->computePath($key), '/') . '/', |
|
271 | + 'Prefix' => rtrim($this->computePath($key), '/').'/', |
|
272 | 272 | 'MaxKeys' => 1, |
273 | 273 | ]); |
274 | 274 | if (isset($result['Contents'])) { |
@@ -186,6 +186,9 @@ |
||
186 | 186 | return $this->users; |
187 | 187 | } |
188 | 188 | |
189 | + /** |
|
190 | + * @param string $key |
|
191 | + */ |
|
189 | 192 | private function updateAcl($key) |
190 | 193 | { |
191 | 194 | $response = $this->s3->set_object_acl($this->bucketName, $key, $this->getAcl()); |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use AmazonS3 as AmazonClient; |
6 | 6 | use Gaufrette\Adapter; |
7 | 7 | |
8 | -@trigger_error('The ' . __NAMESPACE__ . '\AclAwareAmazonS3 adapter is deprecated since version 0.4 and will be removed in 1.0. Use the AwsS3 adapter instead.', E_USER_DEPRECATED); |
|
8 | +@trigger_error('The '.__NAMESPACE__.'\AclAwareAmazonS3 adapter is deprecated since version 0.4 and will be removed in 1.0. Use the AwsS3 adapter instead.', E_USER_DEPRECATED); |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Makes the AmazonS3 adapter ACL aware. Uses the AWS SDK for PHP v1.x. |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | public function setAclConstant($constant) |
39 | 39 | { |
40 | - if (!defined($constant = 'AmazonS3::ACL_' . strtoupper($constant))) { |
|
40 | + if (!defined($constant = 'AmazonS3::ACL_'.strtoupper($constant))) { |
|
41 | 41 | throw new \InvalidArgumentException(sprintf('The ACL constant "%s" does not exist on AmazonS3.', $constant)); |
42 | 42 | } |
43 | 43 | |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | throw new \InvalidArgumentException(sprintf('setUsers() expects an array where each item contains a "permission" key, but got %s.', json_encode($user))); |
54 | 54 | } |
55 | 55 | |
56 | - if (!defined($constant = 'AmazonS3::GRANT_' . strtoupper($user['permission']))) { |
|
56 | + if (!defined($constant = 'AmazonS3::GRANT_'.strtoupper($user['permission']))) { |
|
57 | 57 | throw new \InvalidArgumentException('The permission must be the suffix for one of the AmazonS3::GRANT_ constants.'); |
58 | 58 | } |
59 | 59 | $user['permission'] = constant($constant); |
60 | 60 | |
61 | 61 | if (isset($user['group'])) { |
62 | - if (!defined($constant = 'AmazonS3::USERS_' . strtoupper($user['group']))) { |
|
62 | + if (!defined($constant = 'AmazonS3::USERS_'.strtoupper($user['group']))) { |
|
63 | 63 | throw new \InvalidArgumentException('The group must be the suffix for one of the AmazonS3::USERS_ constants.'); |
64 | 64 | } |
65 | 65 | $user['id'] = constant($constant); |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | { |
192 | 192 | $response = $this->s3->set_object_acl($this->bucketName, $key, $this->getAcl()); |
193 | 193 | if (200 != $response->status) { |
194 | - throw new \RuntimeException('S3-ACL change failed: ' . print_r($response, true)); |
|
194 | + throw new \RuntimeException('S3-ACL change failed: '.print_r($response, true)); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | } |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | } |
467 | 467 | |
468 | 468 | /** |
469 | - * @param string|resource $content |
|
469 | + * @param string $content |
|
470 | 470 | * |
471 | 471 | * @return string |
472 | 472 | */ |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | /** |
485 | 485 | * @param string $key |
486 | 486 | * |
487 | - * @return array |
|
487 | + * @return string[] |
|
488 | 488 | * @throws \InvalidArgumentException |
489 | 489 | */ |
490 | 490 | private function tokenizeKey($key) |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | |
509 | 509 | /** |
510 | 510 | * @param string $containerName |
511 | - * @param null $prefix |
|
511 | + * @param string $prefix |
|
512 | 512 | * |
513 | 513 | * @return array |
514 | 514 | */ |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | $containersList = $this->blobProxy->listContainers(); |
274 | 274 | |
275 | 275 | return call_user_func_array('array_merge', array_map( |
276 | - function (Container $container) { |
|
276 | + function(Container $container) { |
|
277 | 277 | $containerName = $container->getName(); |
278 | 278 | |
279 | 279 | return $this->fetchBlobs($containerName, $containerName); |
@@ -567,10 +567,10 @@ discard block |
||
567 | 567 | $blobList = $this->blobProxy->listBlobs($containerName); |
568 | 568 | |
569 | 569 | return array_map( |
570 | - function (Blob $blob) use ($prefix) { |
|
570 | + function(Blob $blob) use ($prefix) { |
|
571 | 571 | $name = $blob->getName(); |
572 | 572 | if (null !== $prefix) { |
573 | - $name = $prefix . '/' . $name; |
|
573 | + $name = $prefix.'/'.$name; |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | return $name; |
@@ -241,6 +241,7 @@ |
||
241 | 241 | |
242 | 242 | /** |
243 | 243 | * {@inheritdoc} |
244 | + * @param string $key |
|
244 | 245 | */ |
245 | 246 | public function createFile($key) |
246 | 247 | { |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | |
201 | 201 | protected function computePath($key) |
202 | 202 | { |
203 | - return $this->directory . '/' . ltrim($key, '/'); |
|
203 | + return $this->directory.'/'.ltrim($key, '/'); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | protected function fetchKeys($directory = '', $onlyKeys = true) |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | continue; |
219 | 219 | } |
220 | 220 | |
221 | - $path = ltrim($directory . '/' . $filename, '/'); |
|
221 | + $path = ltrim($directory.'/'.$filename, '/'); |
|
222 | 222 | if (isset($stat['type']) && $stat['type'] === NET_SFTP_TYPE_DIRECTORY) { |
223 | 223 | $keys['dirs'][] = $path; |
224 | 224 | } else { |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | if (isset($this->metadata[$key])) { |
172 | 172 | return $this->metadata[$key]; |
173 | 173 | } |
174 | - $meta = $this->bucket->findOne(['filename' => $key], ['projection' => ['metadata' => 1,'_id' => 0]]); |
|
174 | + $meta = $this->bucket->findOne(['filename' => $key], ['projection' => ['metadata' => 1, '_id' => 0]]); |
|
175 | 175 | |
176 | 176 | if ($meta === null || !isset($meta['metadata'])) { |
177 | 177 | return []; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | if (!$this->exists($key)) { |
216 | 216 | return false; |
217 | 217 | } |
218 | - $size = $this->bucket->findOne(['filename' => $key], ['projection' => ['length' => 1,'_id' => 0]]); |
|
218 | + $size = $this->bucket->findOne(['filename' => $key], ['projection' => ['length' => 1, '_id' => 0]]); |
|
219 | 219 | if (!isset($size['length'])) { |
220 | 220 | return false; |
221 | 221 | } |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | $this->ensureDirectoryExists($this->directory, $this->create); |
126 | 126 | |
127 | 127 | $file = $this->computePath($key); |
128 | - $lines = ftp_rawlist($this->getConnection(), '-al ' . \Gaufrette\Util\Path::dirname($file)); |
|
128 | + $lines = ftp_rawlist($this->getConnection(), '-al '.\Gaufrette\Util\Path::dirname($file)); |
|
129 | 129 | |
130 | 130 | if (false === $lines) { |
131 | 131 | return false; |
132 | 132 | } |
133 | 133 | |
134 | - $pattern = '{(?<!->) ' . preg_quote(basename($file)) . '( -> |$)}m'; |
|
134 | + $pattern = '{(?<!->) '.preg_quote(basename($file)).'( -> |$)}m'; |
|
135 | 135 | foreach ($lines as $line) { |
136 | 136 | if (preg_match($pattern, $line)) { |
137 | 137 | return true; |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | $directory = preg_replace('/^[\/]*([^\/].*)$/', '/$1', $directory); |
239 | 239 | |
240 | 240 | $items = $this->parseRawlist( |
241 | - ftp_rawlist($this->getConnection(), '-al ' . $this->directory . $directory) ?: [] |
|
241 | + ftp_rawlist($this->getConnection(), '-al '.$this->directory.$directory) ?: [] |
|
242 | 242 | ); |
243 | 243 | |
244 | 244 | $fileData = $dirs = []; |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | |
250 | 250 | $item = [ |
251 | 251 | 'name' => $itemData['name'], |
252 | - 'path' => trim(($directory ? $directory . '/' : '') . $itemData['name'], '/'), |
|
252 | + 'path' => trim(($directory ? $directory.'/' : '').$itemData['name'], '/'), |
|
253 | 253 | 'time' => $itemData['time'], |
254 | 254 | 'size' => $itemData['size'], |
255 | 255 | ]; |
@@ -381,13 +381,13 @@ discard block |
||
381 | 381 | { |
382 | 382 | $directory = preg_replace('/^[\/]*([^\/].*)$/', '/$1', $directory); |
383 | 383 | |
384 | - $lines = ftp_rawlist($this->getConnection(), '-alR ' . $this->directory . $directory); |
|
384 | + $lines = ftp_rawlist($this->getConnection(), '-alR '.$this->directory.$directory); |
|
385 | 385 | |
386 | 386 | if (false === $lines) { |
387 | 387 | return ['keys' => [], 'dirs' => []]; |
388 | 388 | } |
389 | 389 | |
390 | - $regexDir = '/' . preg_quote($this->directory . $directory, '/') . '\/?(.+):$/u'; |
|
390 | + $regexDir = '/'.preg_quote($this->directory.$directory, '/').'\/?(.+):$/u'; |
|
391 | 391 | $regexItem = '/^(?:([d\-\d])\S+)\s+\S+(?:(?:\s+\S+){5})?\s+(\S+)\s+(.+?)$/'; |
392 | 392 | |
393 | 393 | $prevLine = null; |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | continue; |
412 | 412 | } |
413 | 413 | |
414 | - $path = ltrim($directory . '/' . $name, '/'); |
|
414 | + $path = ltrim($directory.'/'.$name, '/'); |
|
415 | 415 | |
416 | 416 | if ('d' === $tokens[1] || '<dir>' === $tokens[2]) { |
417 | 417 | $keys['dirs'][] = $path; |
@@ -451,13 +451,13 @@ discard block |
||
451 | 451 | $infos = preg_split("/[\s]+/", $line, 9); |
452 | 452 | |
453 | 453 | if ($this->isLinuxListing($infos)) { |
454 | - $infos[7] = (strrpos($infos[7], ':') != 2) ? ($infos[7] . ' 00:00') : (date('Y') . ' ' . $infos[7]); |
|
454 | + $infos[7] = (strrpos($infos[7], ':') != 2) ? ($infos[7].' 00:00') : (date('Y').' '.$infos[7]); |
|
455 | 455 | if ('total' !== $infos[0]) { |
456 | 456 | $parsed[] = [ |
457 | 457 | 'perms' => $infos[0], |
458 | 458 | 'num' => $infos[1], |
459 | 459 | 'size' => $infos[4], |
460 | - 'time' => strtotime($infos[5] . ' ' . $infos[6] . '. ' . $infos[7]), |
|
460 | + 'time' => strtotime($infos[5].' '.$infos[6].'. '.$infos[7]), |
|
461 | 461 | 'name' => $infos[8], |
462 | 462 | ]; |
463 | 463 | } |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | 'perms' => $isDir ? 'd' : '-', |
468 | 468 | 'num' => '', |
469 | 469 | 'size' => $isDir ? '' : $infos[2], |
470 | - 'time' => strtotime($infos[0] . ' ' . $infos[1]), |
|
470 | + 'time' => strtotime($infos[0].' '.$infos[1]), |
|
471 | 471 | 'name' => $infos[3], |
472 | 472 | ]; |
473 | 473 | } |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | */ |
484 | 484 | private function computePath($key) |
485 | 485 | { |
486 | - return rtrim($this->directory, '/') . '/' . $key; |
|
486 | + return rtrim($this->directory, '/').'/'.$key; |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -264,8 +264,8 @@ |
||
264 | 264 | $this->fileData = array_merge($fileData, $this->fileData); |
265 | 265 | |
266 | 266 | return [ |
267 | - 'keys' => array_keys($fileData), |
|
268 | - 'dirs' => $dirs, |
|
267 | + 'keys' => array_keys($fileData), |
|
268 | + 'dirs' => $dirs, |
|
269 | 269 | ]; |
270 | 270 | } |
271 | 271 |