Passed
Push — master ( 6744f1...4151ee )
by Darko
10:57
created
app/Services/AdditionalProcessing/ReleaseFileManager.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
             return false;
56 56
         }
57 57
 
58
-        if (! isset($file['name'])) {
58
+        if (!isset($file['name'])) {
59 59
             return false;
60 60
         }
61 61
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             $file['crc32'] ?? ''
116 116
         );
117 117
 
118
-        if (! empty($added)) {
118
+        if (!empty($added)) {
119 119
             $context->addedFileInfo++;
120 120
 
121 121
             // Check for codec spam
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
                 }
126 126
                 $context->releaseHasPassword = true;
127 127
                 $context->passwordStatus = Releases::PASSWD_RAR;
128
-            } elseif ($file['name'] !== '' && ! str_starts_with($file['name'], '.')) {
128
+            } elseif ($file['name'] !== '' && !str_starts_with($file['name'], '.')) {
129 129
                 // Run PreDB filename check
130 130
                 $context->release['filename'] = $file['name'];
131 131
                 $context->release['releases_id'] = $context->release->id;
@@ -176,12 +176,12 @@  discard block
 block discarded – undo
176 176
         $passwordStatus = max([$context->passwordStatus]);
177 177
 
178 178
         // Set to no password if processing is off
179
-        if (! $processPasswords) {
179
+        if (!$processPasswords) {
180 180
             $context->releaseHasPassword = false;
181 181
         }
182 182
 
183 183
         // Update based on conditions
184
-        if (! $context->releaseHasPassword && $context->nzbHasCompressedFile && $releaseFilesCount === 0) {
184
+        if (!$context->releaseHasPassword && $context->nzbHasCompressedFile && $releaseFilesCount === 0) {
185 185
             Release::query()->where('id', $context->release->id)->update($updateRows);
186 186
         } else {
187 187
             $updateRows['passwordstatus'] = $processPasswords ? $passwordStatus : Releases::PASSWD_NONE;
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
         $filesAdded = 0;
298 298
 
299 299
         foreach ($par2Info->getFileList() as $file) {
300
-            if (! isset($file['name'])) {
300
+            if (!isset($file['name'])) {
301 301
                 continue;
302 302
             }
303 303
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
             }
329 329
 
330 330
             // Try to get a new name
331
-            if (! $foundName) {
331
+            if (!$foundName) {
332 332
                 $context->release->textstring = $file['name'];
333 333
                 $context->release->releases_id = $context->release->id;
334 334
                 if ($this->nameFixer->checkName($context->release, $this->config->echoCLI, 'PAR2, ', 1, 1)) {
@@ -392,10 +392,10 @@  discard block
 block discarded – undo
392 392
         // Alternative NFO filenames
393 393
         $nfoPatterns = [
394 394
             '/^(?:file[_-]?id|readme|release|info(?:rmation)?|about|notes?)\.(?:txt|diz)$/i',
395
-            '/^00-[a-z0-9_-]+\.nfo$/i',           // Scene: 00-group.nfo
396
-            '/^0+-[a-z0-9_-]+\.nfo$/i',           // Scene variations
395
+            '/^00-[a-z0-9_-]+\.nfo$/i', // Scene: 00-group.nfo
396
+            '/^0+-[a-z0-9_-]+\.nfo$/i', // Scene variations
397 397
             '/^[a-z0-9_-]+-[a-z0-9_.-]+\.nfo$/i', // Scene: group-release.nfo
398
-            '/info\.txt$/i',                      // info.txt (common alternative)
398
+            '/info\.txt$/i', // info.txt (common alternative)
399 399
         ];
400 400
 
401 401
         $basename = basename($filename);
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
             } elseif ($this->config->debugMode) {
494 494
                 Log::debug('RarInfo: Ignored low-quality candidate "'.$candidate.'" from inner file name.');
495 495
             }
496
-        } elseif (! empty($dataSummary['archives'][$rarFileName[0]]['file_list'])) {
496
+        } elseif (!empty($dataSummary['archives'][$rarFileName[0]]['file_list'])) {
497 497
             // Try nested archive
498 498
             $archiveData = $dataSummary['archives'][$rarFileName[0]]['file_list'];
499 499
             $archiveFileName = array_column($archiveData, 'name');
Please login to merge, or discard this patch.
app/Services/AdditionalProcessing/ArchiveExtractionService.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         }
72 72
 
73 73
         // Try ArchiveInfo for RAR/ZIP
74
-        if (! $this->archiveInfo->setData($compressedData, true)) {
74
+        if (!$this->archiveInfo->setData($compressedData, true)) {
75 75
             // Handle standalone video detection
76 76
             $videoType = $this->detectStandaloneVideo($compressedData);
77 77
             if ($videoType !== null) {
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         }
105 105
 
106 106
         // Check for encryption
107
-        if (! empty($this->archiveInfo->isEncrypted)
107
+        if (!empty($this->archiveInfo->isEncrypted)
108 108
             || (isset($dataSummary['is_encrypted']) && (int) $dataSummary['is_encrypted'] !== 0)
109 109
         ) {
110 110
             if ($this->config->debugMode) {
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
         // Get file list
128 128
         $files = $this->archiveInfo->getArchiveFileList();
129
-        if (! is_array($files) || count($files) === 0) {
129
+        if (!is_array($files) || count($files) === 0) {
130 130
             return $result;
131 131
         }
132 132
 
@@ -207,14 +207,14 @@  discard block
 block discarded – undo
207 207
             'passwordStatus' => Releases::PASSWD_NONE,
208 208
         ];
209 209
 
210
-        if (! $this->config->sevenZipPath) {
210
+        if (!$this->config->sevenZipPath) {
211 211
             return $result;
212 212
         }
213 213
 
214 214
         // Try listing with external 7z binary
215 215
         $listed = $this->listSevenZipEntries($compressedData, $tmpPath);
216
-        if (! empty($listed)) {
217
-            if (! empty($listed[0]['__any_encrypted__'])) {
216
+        if (!empty($listed)) {
217
+            if (!empty($listed[0]['__any_encrypted__'])) {
218 218
                 return [
219 219
                     'success' => false,
220 220
                     'files' => [],
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
             }
225 225
 
226 226
             $files = $this->filterSevenZipFiles($listed);
227
-            if (! empty($files)) {
227
+            if (!empty($files)) {
228 228
                 return [
229 229
                     'success' => true,
230 230
                     'files' => $files,
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
         // Fallback: scan for filenames in raw data
239 239
         $scannedNames = $this->scanSevenZipFilenames($compressedData);
240
-        if (! empty($scannedNames)) {
240
+        if (!empty($scannedNames)) {
241 241
             $files = array_map(fn($name) => [
242 242
                 'name' => $name,
243 243
                 'size' => 0,
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
      */
265 265
     public function listSevenZipEntries(string $compressedData, string $tmpPath): array
266 266
     {
267
-        if (! $this->config->sevenZipPath) {
267
+        if (!$this->config->sevenZipPath) {
268 268
             return [];
269 269
         }
270 270
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
             $stderr = null;
281 281
             $ok = $this->execCommand($cmd, $exitCode, $stdout, $stderr);
282 282
 
283
-            if (! $ok || $exitCode !== 0 || empty($stdout)) {
283
+            if (!$ok || $exitCode !== 0 || empty($stdout)) {
284 284
                 // Try plain listing fallback
285 285
                 $plainResult = $this->listSevenZipPlain($tmpFile);
286 286
                 File::delete($tmpFile);
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
         $stderr = null;
309 309
         $ok = $this->execCommand($cmd, $exitCode, $stdout, $stderr);
310 310
 
311
-        if (! $ok || $exitCode !== 0 || empty($stdout)) {
311
+        if (!$ok || $exitCode !== 0 || empty($stdout)) {
312 312
             return [];
313 313
         }
314 314
 
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
         $filtered = [];
399 399
 
400 400
         foreach ($files as $entry) {
401
-            if (! empty($entry['__any_encrypted__'])) {
401
+            if (!empty($entry['__any_encrypted__'])) {
402 402
                 continue;
403 403
             }
404 404
 
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
             }
409 409
 
410 410
             $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
411
-            if (! in_array($ext, $allowedExtensions, true)) {
411
+            if (!in_array($ext, $allowedExtensions, true)) {
412 412
                 continue;
413 413
             }
414 414
 
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
             }
461 461
             $candidate = trim($candidate, " .-\t\n\r");
462 462
             $lower = strtolower($candidate);
463
-            if (! isset($names[$lower])) {
463
+            if (!isset($names[$lower])) {
464 464
                 $names[$lower] = $candidate;
465 465
                 if (count($names) >= 80) {
466 466
                     break;
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
             'passwordStatus' => Releases::PASSWD_NONE,
484 484
         ];
485 485
 
486
-        if ($this->config->extractUsingRarInfo || ! $this->config->sevenZipPath) {
486
+        if ($this->config->extractUsingRarInfo || !$this->config->sevenZipPath) {
487 487
             return $result;
488 488
         }
489 489
 
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
             $marker = $markerMap[$type] ?? $type;
495 495
 
496 496
             $extractDir = $tmpPath.'un7z/'.uniqid('', true).'/';
497
-            if (! File::isDirectory($extractDir)) {
497
+            if (!File::isDirectory($extractDir)) {
498 498
                 File::makeDirectory($extractDir, 0777, true, true);
499 499
             }
500 500
 
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 
524 524
             File::delete($fileName);
525 525
 
526
-            if (! empty($files)) {
526
+            if (!empty($files)) {
527 527
                 return [
528 528
                     'success' => true,
529 529
                     'files' => $this->filterExtractedFiles($files),
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
             $name = $file['name'] ?? '';
554 554
             $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
555 555
 
556
-            if (! in_array($ext, $allowedExtensions, true)) {
556
+            if (!in_array($ext, $allowedExtensions, true)) {
557 557
                 continue;
558 558
             }
559 559
 
@@ -635,14 +635,14 @@  discard block
 block discarded – undo
635 635
      */
636 636
     public function sortFilesWithNfoPriority(array $files): array
637 637
     {
638
-        usort($files, function ($a, $b) {
638
+        usort($files, function($a, $b) {
639 639
             $aIsNfo = $this->isNfoFile($a['name'] ?? '');
640 640
             $bIsNfo = $this->isNfoFile($b['name'] ?? '');
641 641
 
642
-            if ($aIsNfo && ! $bIsNfo) {
642
+            if ($aIsNfo && !$bIsNfo) {
643 643
                 return -1;
644 644
             }
645
-            if (! $aIsNfo && $bIsNfo) {
645
+            if (!$aIsNfo && $bIsNfo) {
646 646
                 return 1;
647 647
             }
648 648
 
@@ -664,12 +664,12 @@  discard block
 block discarded – undo
664 664
         try {
665 665
             if ($this->config->unrarPath) {
666 666
                 $unrarDir = $tmpPath.'unrar/';
667
-                if (! File::isDirectory($unrarDir)) {
667
+                if (!File::isDirectory($unrarDir)) {
668 668
                     File::makeDirectory($unrarDir, 0777, true, true);
669 669
                 }
670 670
             }
671 671
             $unzipDir = $tmpPath.'unzip/';
672
-            if (! File::isDirectory($unzipDir)) {
672
+            if (!File::isDirectory($unzipDir)) {
673 673
                 File::makeDirectory($unzipDir, 0777, true, true);
674 674
             }
675 675
         } catch (\Throwable $e) {
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 
689 689
         switch ($dataSummary['main_type']) {
690 690
             case ArchiveInfo::TYPE_RAR:
691
-                if (! $this->config->extractUsingRarInfo && $this->config->unrarPath) {
691
+                if (!$this->config->extractUsingRarInfo && $this->config->unrarPath) {
692 692
                     $fileName = $tmpPath.uniqid('', true).'.rar';
693 693
                     File::put($fileName, $compressedData);
694 694
                     runCmd($killString.$this->config->unrarPath.'" e -ai -ep -c- -id -inul -kb -or -p- -r -y "'.$fileName.'" "'.$tmpPath.'unrar/"');
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
                 return 'r';
698 698
 
699 699
             case ArchiveInfo::TYPE_ZIP:
700
-                if (! $this->config->extractUsingRarInfo && $this->config->unzipPath) {
700
+                if (!$this->config->extractUsingRarInfo && $this->config->unzipPath) {
701 701
                     $fileName = $tmpPath.uniqid('', true).'.zip';
702 702
                     File::put($fileName, $compressedData);
703 703
                     runCmd($this->config->unzipPath.' -o "'.$fileName.'" -d "'.$tmpPath.'unzip/"');
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
         if ($len >= 188 * 5) {
737 737
             $isTs = true;
738 738
             for ($i = 0; $i < 5; $i++) {
739
-                if (! isset($data[188 * $i]) || $data[188 * $i] !== "\x47") {
739
+                if (!isset($data[188 * $i]) || $data[188 * $i] !== "\x47") {
740 740
                     $isTs = false;
741 741
                     break;
742 742
                 }
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
         ];
784 784
 
785 785
         $process = @proc_open($cmd, $descriptorSpec, $pipes, null, null, ['bypass_shell' => true]);
786
-        if (! is_resource($process)) {
786
+        if (!is_resource($process)) {
787 787
             $exitCode = -1;
788 788
             return false;
789 789
         }
Please login to merge, or discard this patch.