Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass verbosity to workers and show stack trace on error #935

Merged
merged 4 commits into from Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 7 additions & 10 deletions src/Command/WorkerCommand.php
Expand Up @@ -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;
Expand All @@ -222,12 +219,12 @@ 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',
);
$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');

if (OutputInterface::VERBOSITY_VERBOSE >= $output->getVerbosity()) {
$internalErrorMessage .= sprintf('%sStack trace: %s%s', "\n\n", "\n", $t->getTraceAsString());
}

$errors[] = $internalErrorMessage;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Process/ProcessHelper.php
Expand Up @@ -53,6 +53,7 @@ public static function getWorkerCommand(
'autoload-file',
'memory-limit',
'xdebug',
'verbose'
];
foreach ($options as $optionName) {
/** @var bool|string|null $optionValue */
Expand Down