@@ -99,6 +99,7 @@ public function process(Schedule $schedule, string $mainScript, callable $postFi
9999 $ serverPort = parse_url ($ serverAddress , \PHP_URL_PORT );
100100 $ systemErrorsCount = 0 ;
101101 $ reachedSystemErrorsCountLimit = \false;
102+ $ totalChanged = 0 ;
102103 $ handleErrorCallable = function (Throwable $ throwable ) use (&$ systemErrors , &$ systemErrorsCount , &$ reachedSystemErrorsCountLimit ): void {
103104 $ systemErrors [] = new SystemError ($ throwable ->getMessage (), $ throwable ->getFile (), $ throwable ->getLine ());
104105 ++$ systemErrorsCount ;
@@ -111,14 +112,22 @@ public function process(Schedule $schedule, string $mainScript, callable $postFi
111112 };
112113 $ timeoutInSeconds = SimpleParameterProvider::provideIntParameter (Option::PARALLEL_JOB_TIMEOUT_IN_SECONDS );
113114 $ fileChunksBudgetPerProcess = [];
114- $ processSpawner = function () use (&$ systemErrors , &$ fileDiffs , &$ jobs , $ postFileCallback , &$ systemErrorsCount , &$ reachedInternalErrorsCountLimit , $ mainScript , $ input , $ serverPort , $ streamSelectLoop , $ timeoutInSeconds , $ handleErrorCallable , &$ fileChunksBudgetPerProcess , &$ processSpawner ): void {
115+ $ processSpawner = function () use (&$ systemErrors , &$ fileDiffs , &$ jobs , $ postFileCallback , &$ systemErrorsCount , &$ reachedInternalErrorsCountLimit , $ mainScript , $ input , $ serverPort , $ streamSelectLoop , $ timeoutInSeconds , $ handleErrorCallable , &$ fileChunksBudgetPerProcess , &$ processSpawner, & $ totalChanged ): void {
115116 $ processIdentifier = Random::generate ();
116117 $ workerCommandLine = $ this ->workerCommandLineFactory ->create ($ mainScript , ProcessCommand::class, 'worker ' , $ input , $ processIdentifier , $ serverPort );
117118 $ fileChunksBudgetPerProcess [$ processIdentifier ] = self ::MAX_CHUNKS_PER_WORKER ;
118119 $ parallelProcess = new ParallelProcess ($ workerCommandLine , $ streamSelectLoop , $ timeoutInSeconds );
119120 $ parallelProcess ->start (
120121 // 1. callable on data
121- function (array $ json ) use ($ parallelProcess , &$ systemErrors , &$ fileDiffs , &$ jobs , $ postFileCallback , &$ systemErrorsCount , &$ reachedInternalErrorsCountLimit , $ processIdentifier , &$ fileChunksBudgetPerProcess , &$ processSpawner ): void {
122+ function (array $ json ) use ($ parallelProcess , &$ systemErrors , &$ fileDiffs , &$ jobs , $ postFileCallback , &$ systemErrorsCount , &$ reachedInternalErrorsCountLimit , $ processIdentifier , &$ fileChunksBudgetPerProcess , &$ processSpawner , &$ totalChanged ): void {
123+ /** @var array{
124+ * total_changed: int,
125+ * system_errors: mixed[],
126+ * file_diffs: array<string, mixed>,
127+ * files_count: int,
128+ * system_errors_count: int
129+ * } $json */
130+ $ totalChanged += $ json [Bridge::TOTAL_CHANGED ];
122131 // decode arrays to objects
123132 foreach ($ json [Bridge::SYSTEM_ERRORS ] as $ jsonError ) {
124133 if (is_string ($ jsonError )) {
@@ -177,6 +186,6 @@ function ($exitCode, string $stdErr) use (&$systemErrors, $processIdentifier): v
177186 if ($ reachedSystemErrorsCountLimit ) {
178187 $ systemErrors [] = new SystemError (sprintf ('Reached system errors count limit of %d, exiting... ' , self ::SYSTEM_ERROR_LIMIT ));
179188 }
180- return new ProcessResult ($ systemErrors , $ fileDiffs );
189+ return new ProcessResult ($ systemErrors , $ fileDiffs, $ totalChanged );
181190 }
182191}
0 commit comments