Skip to content

Commit 6d3bff1

Browse files
committed
[TASK] Apply cs-fixer cleanup to async queue files
1 parent 5d969dc commit 6d3bff1

6 files changed

Lines changed: 16 additions & 7 deletions

File tree

Classes/Command/ProcessWebpQueueCommand.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7171
}
7272
if (!$acquired) {
7373
$output->writeln('<info>Another webp:process-queue is running; exiting.</info>');
74+
7475
return Command::SUCCESS;
7576
}
7677
try {
7778
$folder = $input->getOption('folder');
78-
if (\is_string($folder) && $folder !== '') {
79+
if (\is_string($folder) && '' !== $folder) {
7980
return $this->runFolderMode($folder, $output);
8081
}
82+
8183
return $this->runQueueMode(\max(1, (int) $input->getOption('batch')), $output);
8284
} finally {
8385
$locker->release();
@@ -96,7 +98,7 @@ private function runQueueMode(int $batch, OutputInterface $output): int
9698
$originalFile = $this->resourceFactory->getFileObject($entry->originalFileId);
9799
$configuration = (array) \unserialize($entry->configuration, ['allowed_classes' => false]);
98100
$source = $this->resolveSource($entry->processedFileId, $originalFile);
99-
if ($source === null) {
101+
if (null === $source) {
100102
continue;
101103
}
102104
$processedFileWebp = $this->processedFileRepository->findOneByOriginalFileAndTaskTypeAndConfiguration(
@@ -131,14 +133,16 @@ private function runQueueMode(int $batch, OutputInterface $output): int
131133
$this->applyThrottle($throttleMs, $index === $lastIndex);
132134
}
133135
}
136+
134137
return Command::SUCCESS;
135138
}
136139

137140
private function runFolderMode(string $folder, OutputInterface $output): int
138141
{
139142
$rootPath = $this->resolveAgainstWebRoot($folder);
140-
if ($rootPath === null) {
143+
if (null === $rootPath) {
141144
$output->writeln(\sprintf('<error>Folder "%s" not found or outside the public web root</error>', $folder));
145+
142146
return Command::FAILURE;
143147
}
144148

@@ -155,6 +159,7 @@ private function runFolderMode(string $folder, OutputInterface $output): int
155159
}
156160
$this->applyThrottle($throttleMs, $index === $lastIndex);
157161
}
162+
158163
return Command::SUCCESS;
159164
}
160165

@@ -163,7 +168,7 @@ private function resolveSource(int $processedFileId, $originalFile): ?\TYPO3\CMS
163168
if (!$originalFile instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
164169
return null;
165170
}
166-
if ($processedFileId === 0) {
171+
if (0 === $processedFileId) {
167172
return $originalFile;
168173
}
169174
try {
@@ -176,7 +181,7 @@ private function resolveSource(int $processedFileId, $originalFile): ?\TYPO3\CMS
176181
private function resolveAgainstWebRoot(string $folder): ?string
177182
{
178183
$webRoot = \realpath(Environment::getPublicPath());
179-
if ($webRoot === false) {
184+
if (false === $webRoot) {
180185
return null;
181186
}
182187
$candidate = \realpath($webRoot . '/' . \ltrim($folder, '/'));

Classes/EventListener/AfterFileProcessing.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ private function processFile(
103103
$taskType,
104104
$configuration + ['webp' => true]
105105
);
106+
106107
return;
107108
} catch (\Doctrine\DBAL\Exception $e) {
108109
$this->logger->notice(

Classes/Task/ProcessWebpQueueTask.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public function execute(): bool
2020
{
2121
$command = GeneralUtility::makeInstance(ProcessWebpQueueCommand::class);
2222
$input = new ArrayInput(['--batch' => (string) $this->batchSize]);
23+
2324
return 0 === $command->run($input, new NullOutput());
2425
}
2526
}

Tests/Functional/Command/ProcessWebpQueueCommandTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ protected function setUp(): void
190190
private function runCommand(array $arguments): int
191191
{
192192
$tester = new CommandTester($this->get(ProcessWebpQueueCommand::class));
193+
193194
return $tester->execute($arguments);
194195
}
195196

Tests/Functional/Domain/Queue/WebpQueueRepositoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,6 @@ private function fetchEnqueuedAt(int $originalFileId): int
149149
->select(['enqueued_at'], 'tx_webp_queue', ['original_file_id' => $originalFileId])
150150
->fetchAssociative();
151151

152-
return $row !== false ? (int) $row['enqueued_at'] : 0;
152+
return false !== $row ? (int) $row['enqueued_at'] : 0;
153153
}
154154
}

Tests/Unit/Service/FolderScannerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,13 @@ private function removeRecursive(string $path): void
122122
}
123123
if (\is_dir($path)) {
124124
foreach (\scandir($path) ?: [] as $entry) {
125-
if ($entry === '.' || $entry === '..') {
125+
if ('.' === $entry || '..' === $entry) {
126126
continue;
127127
}
128128
$this->removeRecursive($path . '/' . $entry);
129129
}
130130
\rmdir($path);
131+
131132
return;
132133
}
133134
\unlink($path);

0 commit comments

Comments
 (0)