@@ -9,7 +9,7 @@ |
||
| 9 | 9 | $client = new \TusPhp\Tus\Client('http://tus-php-server', 'redis'); |
| 10 | 10 | |
| 11 | 11 | // Alert: Sanitize all inputs properly in production code |
| 12 | -if (! empty($_FILES)) { |
|
| 12 | +if ( ! empty($_FILES)) { |
|
| 13 | 13 | $fileMeta = $_FILES['tus_file']; |
| 14 | 14 | $uploadKey = hash_file('md5', $fileMeta['tmp_name']); |
| 15 | 15 | |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | $client = new \TusPhp\Tus\Client('http://tus-php-server', 'redis'); |
| 14 | 14 | |
| 15 | 15 | // Alert: Sanitize all inputs properly in production code |
| 16 | -if (! empty($_FILES)) { |
|
| 16 | +if ( ! empty($_FILES)) { |
|
| 17 | 17 | $fileMeta = $_FILES['tus_file']; |
| 18 | 18 | $uploadKey = hash_file('md5', $fileMeta['tmp_name']); |
| 19 | 19 | |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | $client = new \TusPhp\Tus\Client('http://tus-php-server', 'redis'); |
| 15 | 15 | |
| 16 | 16 | // Alert: Sanitize all inputs properly in production code |
| 17 | -if (! empty($_FILES)) { |
|
| 17 | +if ( ! empty($_FILES)) { |
|
| 18 | 18 | $status = 'new'; |
| 19 | 19 | $fileMeta = $_FILES['tus_file']; |
| 20 | 20 | $uploadKey = hash_file('md5', $fileMeta['tmp_name']); |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function getUploadKey() |
| 180 | 180 | { |
| 181 | - if (! empty($this->uploadKey)) { |
|
| 181 | + if ( ! empty($this->uploadKey)) { |
|
| 182 | 182 | return $this->uploadKey; |
| 183 | 183 | } |
| 184 | 184 | |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | |
| 253 | 253 | $requestMethod = $this->getRequest()->method(); |
| 254 | 254 | |
| 255 | - if (! in_array($requestMethod, $this->getRequest()->allowedHttpVerbs())) { |
|
| 255 | + if ( ! in_array($requestMethod, $this->getRequest()->allowedHttpVerbs())) { |
|
| 256 | 256 | return $this->response->send(null, HttpResponse::HTTP_METHOD_NOT_ALLOWED); |
| 257 | 257 | } |
| 258 | 258 | |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | { |
| 308 | 308 | $key = $this->request->key(); |
| 309 | 309 | |
| 310 | - if (! $fileMeta = $this->cache->get($key)) { |
|
| 310 | + if ( ! $fileMeta = $this->cache->get($key)) { |
|
| 311 | 311 | return $this->response->send(null, HttpResponse::HTTP_NOT_FOUND); |
| 312 | 312 | } |
| 313 | 313 | |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | return $this->response->send(null, HttpResponse::HTTP_BAD_REQUEST); |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - if (! $this->verifyUploadSize()) { |
|
| 337 | + if ( ! $this->verifyUploadSize()) { |
|
| 338 | 338 | return $this->response->send(null, HttpResponse::HTTP_REQUEST_ENTITY_TOO_LARGE); |
| 339 | 339 | } |
| 340 | 340 | |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | { |
| 432 | 432 | $uploadKey = $this->request->key(); |
| 433 | 433 | |
| 434 | - if (! $meta = $this->cache->get($uploadKey)) { |
|
| 434 | + if ( ! $meta = $this->cache->get($uploadKey)) { |
|
| 435 | 435 | return $this->response->send(null, HttpResponse::HTTP_GONE); |
| 436 | 436 | } |
| 437 | 437 | |
@@ -502,14 +502,14 @@ discard block |
||
| 502 | 502 | return $this->response->send('400 bad request.', HttpResponse::HTTP_BAD_REQUEST); |
| 503 | 503 | } |
| 504 | 504 | |
| 505 | - if (! $fileMeta = $this->cache->get($key)) { |
|
| 505 | + if ( ! $fileMeta = $this->cache->get($key)) { |
|
| 506 | 506 | return $this->response->send('404 upload not found.', HttpResponse::HTTP_NOT_FOUND); |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | $resource = $fileMeta['file_path'] ?? null; |
| 510 | 510 | $fileName = $fileMeta['name'] ?? null; |
| 511 | 511 | |
| 512 | - if (! $resource || ! file_exists($resource)) { |
|
| 512 | + if ( ! $resource || ! file_exists($resource)) { |
|
| 513 | 513 | return $this->response->send('404 upload not found.', HttpResponse::HTTP_NOT_FOUND); |
| 514 | 514 | } |
| 515 | 515 | |
@@ -527,13 +527,13 @@ discard block |
||
| 527 | 527 | $fileMeta = $this->cache->get($key); |
| 528 | 528 | $resource = $fileMeta['file_path'] ?? null; |
| 529 | 529 | |
| 530 | - if (! $resource) { |
|
| 530 | + if ( ! $resource) { |
|
| 531 | 531 | return $this->response->send(null, HttpResponse::HTTP_NOT_FOUND); |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | $isDeleted = $this->cache->delete($key); |
| 535 | 535 | |
| 536 | - if (! $isDeleted || ! file_exists($resource)) { |
|
| 536 | + if ( ! $isDeleted || ! file_exists($resource)) { |
|
| 537 | 537 | return $this->response->send(null, HttpResponse::HTTP_GONE); |
| 538 | 538 | } |
| 539 | 539 | |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | |
| 627 | 627 | $checksum = base64_decode($checksum); |
| 628 | 628 | |
| 629 | - if (! in_array($checksumAlgorithm, hash_algos()) || false === $checksum) { |
|
| 629 | + if ( ! in_array($checksumAlgorithm, hash_algos()) || false === $checksum) { |
|
| 630 | 630 | return $this->response->send(null, HttpResponse::HTTP_BAD_REQUEST); |
| 631 | 631 | } |
| 632 | 632 | |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | |
| 665 | 665 | $path = $this->uploadDir . DIRECTORY_SEPARATOR . $actualKey . DIRECTORY_SEPARATOR; |
| 666 | 666 | |
| 667 | - if (! file_exists($path)) { |
|
| 667 | + if ( ! file_exists($path)) { |
|
| 668 | 668 | mkdir($path); |
| 669 | 669 | } |
| 670 | 670 | |
@@ -704,11 +704,11 @@ discard block |
||
| 704 | 704 | foreach ($cacheKeys as $key) { |
| 705 | 705 | $fileMeta = $this->cache->get($key, true); |
| 706 | 706 | |
| 707 | - if (! $this->isExpired($fileMeta)) { |
|
| 707 | + if ( ! $this->isExpired($fileMeta)) { |
|
| 708 | 708 | continue; |
| 709 | 709 | } |
| 710 | 710 | |
| 711 | - if (! $this->cache->delete($key)) { |
|
| 711 | + if ( ! $this->cache->delete($key)) { |
|
| 712 | 712 | continue; |
| 713 | 713 | } |
| 714 | 714 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | { |
| 69 | 69 | $this->filePath = $file; |
| 70 | 70 | |
| 71 | - if (! file_exists($file) || ! is_readable($file)) { |
|
| 71 | + if ( ! file_exists($file) || ! is_readable($file)) { |
|
| 72 | 72 | throw new FileException('Cannot read file: ' . $file); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | { |
| 377 | 377 | $this->partial = $state; |
| 378 | 378 | |
| 379 | - if (! $this->partial) { |
|
| 379 | + if ( ! $this->partial) { |
|
| 380 | 380 | return; |
| 381 | 381 | } |
| 382 | 382 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | protected function createCacheDir() |
| 86 | 86 | { |
| 87 | - if (! file_exists($this->cacheDir)) { |
|
| 87 | + if ( ! file_exists($this->cacheDir)) { |
|
| 88 | 88 | mkdir($this->cacheDir); |
| 89 | 89 | } |
| 90 | 90 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | $cacheFilePath = $this->getCacheFile(); |
| 102 | 102 | |
| 103 | - if (! file_exists($cacheFilePath)) { |
|
| 103 | + if ( ! file_exists($cacheFilePath)) { |
|
| 104 | 104 | touch($cacheFilePath); |
| 105 | 105 | } |
| 106 | 106 | } |
@@ -132,13 +132,13 @@ discard block |
||
| 132 | 132 | $key = $this->getActualCacheKey($key); |
| 133 | 133 | $cacheFile = $this->getCacheFile(); |
| 134 | 134 | |
| 135 | - if (! file_exists($cacheFile) || ! $this->isValid($key)) { |
|
| 135 | + if ( ! file_exists($cacheFile) || ! $this->isValid($key)) { |
|
| 136 | 136 | $this->createCacheFile(); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | $contents = json_decode(file_get_contents($cacheFile), true) ?? []; |
| 140 | 140 | |
| 141 | - if (! empty($contents[$key]) && is_array($value)) { |
|
| 141 | + if ( ! empty($contents[$key]) && is_array($value)) { |
|
| 142 | 142 | $contents[$key] = $value + $contents[$key]; |
| 143 | 143 | } else { |
| 144 | 144 | $contents[$key] = $value; |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | { |
| 207 | 207 | $cacheFile = $this->getCacheFile(); |
| 208 | 208 | |
| 209 | - if (! file_exists($cacheFile)) { |
|
| 209 | + if ( ! file_exists($cacheFile)) { |
|
| 210 | 210 | return false; |
| 211 | 211 | } |
| 212 | 212 | |
@@ -130,7 +130,7 @@ |
||
| 130 | 130 | |
| 131 | 131 | $response->prepare(HttpRequest::createFromGlobals()); |
| 132 | 132 | |
| 133 | - if (! is_null($name)) { |
|
| 133 | + if ( ! is_null($name)) { |
|
| 134 | 134 | $response = $response->setContentDisposition( |
| 135 | 135 | $disposition, |
| 136 | 136 | $name, |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | try { |
| 302 | 302 | $this->seek($output, $bytesWritten); |
| 303 | 303 | |
| 304 | - while (! feof($input)) { |
|
| 304 | + while ( ! feof($input)) { |
|
| 305 | 305 | if (CONNECTION_NORMAL !== connection_status()) { |
| 306 | 306 | throw new ConnectionException('Connection aborted by user.'); |
| 307 | 307 | } |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | $handle = $this->open($destination, self::APPEND_BINARY); |
| 460 | 460 | |
| 461 | 461 | foreach ($files as $file) { |
| 462 | - if (! file_exists($file['file_path'])) { |
|
| 462 | + if ( ! file_exists($file['file_path'])) { |
|
| 463 | 463 | throw new FileException('File to be merged not found.'); |
| 464 | 464 | } |
| 465 | 465 | |