|
7 | 7 | use Nette\Utils\Random;
|
8 | 8 | use PHPStan\Analyser\AnalyserResult;
|
9 | 9 | use PHPStan\Analyser\Error;
|
| 10 | +use PHPStan\Command\Output; |
10 | 11 | use PHPStan\Dependency\ExportedNode;
|
11 | 12 | use PHPStan\Process\ProcessHelper;
|
12 | 13 | use React\EventLoop\StreamSelectLoop;
|
@@ -52,7 +53,8 @@ public function analyse(
|
52 | 53 | ?string $projectConfigFile,
|
53 | 54 | ?string $tmpFile,
|
54 | 55 | ?string $insteadOfFile,
|
55 |
| - InputInterface $input |
| 56 | + InputInterface $input, |
| 57 | + Output $errorOutput |
56 | 58 | ): AnalyserResult
|
57 | 59 | {
|
58 | 60 | $jobs = array_reverse($schedule->getJobs());
|
@@ -131,7 +133,7 @@ public function analyse(
|
131 | 133 | $commandOptions,
|
132 | 134 | $input
|
133 | 135 | ), $loop, $this->processTimeout);
|
134 |
| - $process->start(function (array $json) use ($process, &$internalErrors, &$errors, &$dependencies, &$exportedNodes, &$jobs, $postFileCallback, &$internalErrorsCount, &$reachedInternalErrorsCountLimit, $processIdentifier): void { |
| 136 | + $process->start(function (array $json) use ($process, &$internalErrors, &$errors, &$dependencies, &$exportedNodes, &$jobs, $postFileCallback, &$internalErrorsCount, &$reachedInternalErrorsCountLimit, $processIdentifier, $errorOutput): void { |
135 | 137 | foreach ($json['errors'] as $jsonError) {
|
136 | 138 | if (is_string($jsonError)) {
|
137 | 139 | $internalErrors[] = sprintf('Internal error: %s', $jsonError);
|
@@ -175,14 +177,24 @@ public function analyse(
|
175 | 177 | }
|
176 | 178 |
|
177 | 179 | if (count($jobs) === 0) {
|
| 180 | + if ($errorOutput->isDebug()) { |
| 181 | + $errorOutput->writeLineFormatted(sprintf('Process %s ended successfully - no more jobs remaining.', $processIdentifier)); |
| 182 | + } |
178 | 183 | $this->processPool->quitProcess($processIdentifier);
|
179 | 184 | return;
|
180 | 185 | }
|
181 | 186 |
|
| 187 | + if ($errorOutput->isDebug()) { |
| 188 | + $errorOutput->writeLineFormatted(sprintf('Process %s analysis successful - queueing a new job.', $processIdentifier)); |
| 189 | + } |
| 190 | + |
182 | 191 | $job = array_pop($jobs);
|
183 | 192 | $process->request(['action' => 'analyse', 'files' => $job]);
|
184 |
| - }, $handleError, function ($exitCode, string $output) use (&$internalErrors, &$internalErrorsCount, $processIdentifier): void { |
| 193 | + }, $handleError, function ($exitCode, $termSignal, string $output) use (&$internalErrors, &$internalErrorsCount, $processIdentifier, $errorOutput): void { |
185 | 194 | $this->processPool->tryQuitProcess($processIdentifier);
|
| 195 | + if ($errorOutput->isDebug()) { |
| 196 | + $errorOutput->writeLineFormatted(sprintf('Process %s exited - exit code %s, term signal %s, output: %s', $processIdentifier, $exitCode ?? 'null', $termSignal ?? 'null', $output)); |
| 197 | + } |
186 | 198 | if ($exitCode === 0) {
|
187 | 199 | return;
|
188 | 200 | }
|
|
0 commit comments