diff --git a/src/Command/WorkerCommand.php b/src/Command/WorkerCommand.php index 711359314d..122d3b4aa3 100644 --- a/src/Command/WorkerCommand.php +++ b/src/Command/WorkerCommand.php @@ -188,14 +188,11 @@ private function runWorker( $out->end(); }; $out->on('error', $handleError); - /** @var FileAnalyser $fileAnalyser */ $fileAnalyser = $container->getByType(FileAnalyser::class); - /** @var Registry $registry */ $registry = $container->getByType(Registry::class); - - $in->on('data', function (array $json) use ($fileAnalyser, $registry, $out, $analysedFiles, $tmpFile, $insteadOfFile): void { + $in->on('data', function (array $json) use ($fileAnalyser, $registry, $out, $analysedFiles, $tmpFile, $insteadOfFile, $output): void { $action = $json['action']; if ($action !== 'analyse') { return; @@ -222,12 +219,14 @@ private function runWorker( $this->errorCount++; $internalErrorsCount++; $internalErrorMessage = sprintf('Internal error: %s in file %s', $t->getMessage(), $file); - $internalErrorMessage .= sprintf( - '%sRun PHPStan with --debug option and post the stack trace to:%s%s', - "\n", - "\n", - 'https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md', - ); + + $bugReportUrl = 'https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md'; + if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { + $internalErrorMessage .= sprintf('%sPost the following stack trace to %s: %s%s', "\n\n", $bugReportUrl, "\n", $t->getTraceAsString()); + } else { + $internalErrorMessage .= sprintf('%sRun PHPStan with -v option and post the stack trace to:%s%s', "\n", "\n", $bugReportUrl); + } + $errors[] = $internalErrorMessage; } } diff --git a/src/Process/ProcessHelper.php b/src/Process/ProcessHelper.php index f01917130c..2597e771a8 100644 --- a/src/Process/ProcessHelper.php +++ b/src/Process/ProcessHelper.php @@ -53,6 +53,7 @@ public static function getWorkerCommand( 'autoload-file', 'memory-limit', 'xdebug', + 'verbose', ]; foreach ($options as $optionName) { /** @var bool|string|null $optionValue */