From 7f0740dd0fd479f084e13ce237d2780e14447763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Thu, 1 Jun 2023 12:21:50 +0200 Subject: [PATCH] [TASK] Use local variable in `CleanUpLocalProcessedFilesCommand` 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 Tested-by: Anja Leichsenring Tested-by: core-ci --- .../Classes/Command/CleanUpLocalProcessedFilesCommand.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/typo3/sysext/lowlevel/Classes/Command/CleanUpLocalProcessedFilesCommand.php b/typo3/sysext/lowlevel/Classes/Command/CleanUpLocalProcessedFilesCommand.php index 93fb20e20957..b83c0b5443c2 100644 --- a/typo3/sysext/lowlevel/Classes/Command/CleanUpLocalProcessedFilesCommand.php +++ b/typo3/sysext/lowlevel/Classes/Command/CleanUpLocalProcessedFilesCommand.php @@ -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)); } @@ -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(); } }