diff --git a/packages/Parallel/Application/ParallelFileProcessor.php b/packages/Parallel/Application/ParallelFileProcessor.php index c1e2d01d4d4..83d4ed2f971 100644 --- a/packages/Parallel/Application/ParallelFileProcessor.php +++ b/packages/Parallel/Application/ParallelFileProcessor.php @@ -74,6 +74,7 @@ public function process( // initial counters $fileDiffs = []; + /** @var SystemError[] $systemErrors */ $systemErrors = []; $tcpServer = new TcpServer('127.0.0.1:0', $streamSelectLoop); @@ -166,7 +167,7 @@ function (array $json) use ( // decode arrays to objects foreach ($json[Bridge::SYSTEM_ERRORS] as $jsonError) { if (is_string($jsonError)) { - $systemErrors[] = 'System error: ' . $jsonError; + $systemErrors[] = new SystemError('System error: ' . $jsonError); continue; } @@ -211,7 +212,7 @@ function ($exitCode, string $stdErr) use (&$systemErrors, $processIdentifier): v return; } - $systemErrors[] = 'Child process error: ' . $stdErr; + $systemErrors[] = new SystemError('Child process error: ' . $stdErr); } ); @@ -221,10 +222,10 @@ function ($exitCode, string $stdErr) use (&$systemErrors, $processIdentifier): v $streamSelectLoop->run(); if ($reachedSystemErrorsCountLimit) { - $systemErrors[] = sprintf( + $systemErrors[] = new SystemError(sprintf( 'Reached system errors count limit of %d, exiting...', self::SYSTEM_ERROR_COUNT_LIMIT - ); + )); } return [ diff --git a/src/ValueObject/Error/SystemError.php b/src/ValueObject/Error/SystemError.php index e2af17e904f..5a11c57bc69 100644 --- a/src/ValueObject/Error/SystemError.php +++ b/src/ValueObject/Error/SystemError.php @@ -11,7 +11,7 @@ final class SystemError implements SerializableInterface { public function __construct( private readonly string $message, - private readonly string $relativeFilePath, + private readonly string|null $relativeFilePath = null, private readonly int|null $line = null, private readonly string|null $rectorClass = null ) { @@ -22,7 +22,7 @@ public function getMessage(): string return $this->message; } - public function getFile(): string + public function getFile(): string|null { return $this->relativeFilePath; } @@ -38,7 +38,7 @@ public function getFileWithLine(): string } /** - * @return array{message: string, relative_file_path: string, line: int|null, rector_class: string|null} + * @return array{message: string, relative_file_path: string|null, line: int|null, rector_class: string|null} */ public function jsonSerialize(): array {