1212use Rector \Autoloading \AdditionalAutoloader ;
1313use Rector \Configuration \ConfigurationFactory ;
1414use Rector \Configuration \ConfigurationRuleFilter ;
15+ use Rector \Configuration \Option ;
1516use Rector \Console \ProcessConfigureDecorator ;
1617use Rector \Parallel \ValueObject \Bridge ;
1718use Rector \StaticReflection \DynamicSourceLocatorDecorator ;
@@ -89,16 +90,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8990 $ parallelIdentifier = $ configuration ->getParallelIdentifier ();
9091 $ tcpConnector = new TcpConnector ($ streamSelectLoop );
9192 $ promise = $ tcpConnector ->connect ('127.0.0.1: ' . $ configuration ->getParallelPort ());
92- $ promise ->then (function (ConnectionInterface $ connection ) use ($ parallelIdentifier , $ configuration , $ output ): void {
93+ $ promise ->then (function (ConnectionInterface $ connection ) use ($ parallelIdentifier , $ configuration , $ input , $ output ): void {
9394 $ inDecoder = new Decoder ($ connection , \true, 512 , \JSON_INVALID_UTF8_IGNORE );
9495 $ outEncoder = new Encoder ($ connection , \JSON_INVALID_UTF8_IGNORE );
9596 $ outEncoder ->write ([ReactCommand::ACTION => Action::HELLO , ReactCommand::IDENTIFIER => $ parallelIdentifier ]);
96- $ this ->runWorker ($ outEncoder , $ inDecoder , $ configuration , $ output );
97+ $ this ->runWorker ($ outEncoder , $ inDecoder , $ configuration , $ input , $ output );
9798 });
9899 $ streamSelectLoop ->run ();
99100 return self ::SUCCESS ;
100101 }
101- private function runWorker (Encoder $ encoder , Decoder $ decoder , Configuration $ configuration , OutputInterface $ output ): void
102+ private function runWorker (Encoder $ encoder , Decoder $ decoder , Configuration $ configuration , InputInterface $ input , OutputInterface $ output ): void
102103 {
103104 $ this ->additionalAutoloader ->autoloadPaths ();
104105 $ this ->dynamicSourceLocatorDecorator ->addPaths ($ configuration ->getPaths ());
@@ -117,7 +118,7 @@ private function runWorker(Encoder $encoder, Decoder $decoder, Configuration $co
117118 };
118119 $ encoder ->on (ReactEvent::ERROR , $ handleErrorCallback );
119120 // 2. collect diffs + errors from file processor
120- $ decoder ->on (ReactEvent::DATA , function (array $ json ) use ($ preFileCallback , $ encoder , $ configuration ): void {
121+ $ decoder ->on (ReactEvent::DATA , function (array $ json ) use ($ preFileCallback , $ encoder , $ configuration, $ input ): void {
121122 $ action = $ json [ReactCommand::ACTION ];
122123 if ($ action !== Action::MAIN ) {
123124 return ;
@@ -129,7 +130,7 @@ private function runWorker(Encoder $encoder, Decoder $decoder, Configuration $co
129130 /**
130131 * this invokes all listeners listening $decoder->on(...) @see \Symplify\EasyParallel\Enum\ReactEvent::DATA
131132 */
132- $ encoder ->write ([ReactCommand::ACTION => Action::RESULT , self ::RESULT => [Bridge::FILE_DIFFS => $ processResult ->getFileDiffs (), Bridge::FILES_COUNT => count ($ filePaths ), Bridge::SYSTEM_ERRORS => $ processResult ->getSystemErrors (), Bridge::SYSTEM_ERRORS_COUNT => count ($ processResult ->getSystemErrors ()), Bridge::TOTAL_CHANGED => $ processResult ->getTotalChanged ()]]);
133+ $ encoder ->write ([ReactCommand::ACTION => Action::RESULT , self ::RESULT => [Bridge::FILE_DIFFS => $ processResult ->getFileDiffs ($ input -> getOption (Option:: OUTPUT_FORMAT ) !== ' json ' ), Bridge::FILES_COUNT => count ($ filePaths ), Bridge::SYSTEM_ERRORS => $ processResult ->getSystemErrors (), Bridge::SYSTEM_ERRORS_COUNT => count ($ processResult ->getSystemErrors ()), Bridge::TOTAL_CHANGED => $ processResult ->getTotalChanged ()]]);
133134 });
134135 $ decoder ->on (ReactEvent::ERROR , $ handleErrorCallback );
135136 }
0 commit comments