Skip to content

Commit

Permalink
[TASK] Use local variable in CleanUpLocalProcessedFilesCommand
Browse files Browse the repository at this point in the history
With recent changes in phpstan/phpstan, it seems the possible return
value of methods is not set in stone anymore, allowing detection
of possible issues in the code.

This change uses a local method variable for the method return
value of `isVerbose()` and uses this instead of several method calls.

Resolves: #100941
Releases: main, 12.4
Change-Id: If4a91d544e43b03279711dd8d5fbbb12c349566f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/79127
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: core-ci <typo3@b13.com>
  • Loading branch information
sbuerk authored and maddy2101 committed Jun 1, 2023
1 parent cb80da5 commit 7f0740d
Showing 1 changed file with 4 additions and 3 deletions.
Expand Up @@ -138,7 +138,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int

protected function deleteFile(InputInterface $input, OutputInterface $output, array $files): array
{
if (!$output->isVerbose()) {
$isVerbose = $output->isVerbose();
if (!$isVerbose) {
$io = new SymfonyStyle($input, $output);
$progressBar = $io->createProgressBar(count($files));
}
Expand All @@ -149,10 +150,10 @@ protected function deleteFile(InputInterface $input, OutputInterface $output, ar
$path = PathUtility::stripPathSitePrefix($file->getRealPath());
if (unlink($file->getRealPath()) === false) {
$error[] = $file;
$output->isVerbose() ? $output->writeln('[FILE] Failed to delete ' . $path) : $progressBar->advance();
$isVerbose ? $output->writeln('[FILE] Failed to delete ' . $path) : $progressBar->advance();
} else {
$success[] = $file;
$output->isVerbose() ? $output->writeln('[FILE] Successfully deleted ' . $path) : $progressBar->advance();
$isVerbose ? $output->writeln('[FILE] Successfully deleted ' . $path) : $progressBar->advance();
}
}

Expand Down

0 comments on commit 7f0740d

Please sign in to comment.