Skip to content

Commit 734bb32

Browse files
committed
fix
1 parent a1fc513 commit 734bb32

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

src/ParallelCommand.php

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
namespace Webmozarts\Console\Parallelization;
1515

16-
use Closure;
1716
use Symfony\Bundle\FrameworkBundle\Console\Application as FrameworkBundleApplication;
1817
use Symfony\Component\Console\Command\Command;
1918
use Symfony\Component\Console\Input\InputDefinition;
@@ -30,13 +29,10 @@
3029
use Webmozarts\Console\Parallelization\Logger\DebugProgressBarFactory;
3130
use Webmozarts\Console\Parallelization\Logger\Logger;
3231
use Webmozarts\Console\Parallelization\Logger\StandardLogger;
32+
use function func_get_args;
3333

3434
abstract class ParallelCommand extends Command
3535
{
36-
use Parallelization;
37-
// TODO: simply add the Parallelization trait for 3.x where all the BC
38-
// layer of the trait is removed.
39-
4036
protected function configure(): void
4137
{
4238
ParallelizationInput::configureCommand($this);
@@ -125,14 +121,15 @@ protected function getParallelExecutableFactory(
125121
InputDefinition $commandDefinition,
126122
ErrorHandler $errorHandler
127123
): ParallelExecutorFactory {
128-
return ParallelExecutorFactory::create(
129-
Closure::fromCallable($fetchItems),
130-
Closure::fromCallable($runSingleCommand),
131-
Closure::fromCallable($getItemName),
132-
$commandName,
133-
$commandDefinition,
134-
$errorHandler,
135-
);
124+
// If you are looking at this code to wonder if you should call it when
125+
// overriding this method, it is highly recommended you don't and just
126+
// call `ParallelExecutorFactory::create(...func_get_args())`.
127+
//
128+
// Configuring the factory is recommended to be done in
129+
// ::configureParallelExecutableFactory() instead which is
130+
// simpler to override, unless you _really_ need one of the
131+
// parameters passed to this method.
132+
return ParallelExecutorFactory::create(...func_get_args());
136133
}
137134

138135
/**

src/Parallelization.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ protected function getParallelExecutableFactory(
146146
// call `ParallelExecutorFactory::create(...func_get_args())`.
147147
//
148148
// Configuring the factory is recommended to be done in
149-
// ::configureParallelExecutableFactory() instead.
149+
// ::configureParallelExecutableFactory() instead which is
150+
// simpler to override, unless you _really_ need one of the
151+
// parameters passed to this method.
150152
return ParallelExecutorFactory::create(...func_get_args())
151153
->withRunBeforeFirstCommand($this->runBeforeFirstCommand(...))
152154
->withRunAfterLastCommand($this->runAfterLastCommand(...))
@@ -172,11 +174,11 @@ protected function configureParallelExecutableFactory(
172174

173175
protected function createErrorHandler(InputInterface $input, OutputInterface $output): ErrorHandler
174176
{
175-
$errorHandler = new ThrowableCodeErrorHandler(
176-
ResetServiceErrorHandler::forContainer($this->getContainer()),
177+
return new LoggingErrorHandler(
178+
new ThrowableCodeErrorHandler(
179+
ResetServiceErrorHandler::forContainer($this->getContainer()),
180+
),
177181
);
178-
179-
return new LoggingErrorHandler($errorHandler);
180182
}
181183

182184
protected function createLogger(InputInterface $input, OutputInterface $output): Logger

0 commit comments

Comments
 (0)