From aa991a89ea07970b54305fb0790aa72d153fdfeb Mon Sep 17 00:00:00 2001 From: Robert Vogel Date: Mon, 23 Sep 2024 16:59:01 +0200 Subject: [PATCH] Fix return value --- src/Commands/BatchFileProcessorBase.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Commands/BatchFileProcessorBase.php b/src/Commands/BatchFileProcessorBase.php index 6cbdc8f..bb230ea 100644 --- a/src/Commands/BatchFileProcessorBase.php +++ b/src/Commands/BatchFileProcessorBase.php @@ -68,9 +68,9 @@ protected function configure() { /** * @param Input\InputInterface $input * @param OutputInterface $output - * @return void + * @return int */ - protected function execute( Input\InputInterface $input, OutputInterface $output ) { + protected function execute( Input\InputInterface $input, OutputInterface $output ): int { $this->input = $input; $this->output = $output; @@ -81,9 +81,10 @@ protected function execute( Input\InputInterface $input, OutputInterface $output $this->output->writeln( "Destination: {$this->dest}\n" ); $this->makeFileList(); - $this->processFiles(); + $returnValue = $this->processFiles(); $this->output->writeln( 'Done.' ); + return $returnValue; } protected function makeFileList() { @@ -121,11 +122,17 @@ protected function makeFileList() { $this->output->writeln( 'done.' ); } - protected function processFiles() { + protected function processFiles(): int { + $overallReturn = 0; foreach ( $this->files as $file ) { $this->currentFile = $file; $result = $this->processFile( $file ); + if ( $result === false ) { + $this->output->writeln( "Failed to process file {$file->getPathname()}" ); + $overallReturn = 1; + } } + return $overallReturn; } /**