1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 09:37:59 +01:00

Throw exception instead of silently logging issues occurred during scan

This commit is contained in:
Daniil Gentili 2024-04-11 20:22:31 +02:00
parent 7d6c88e88a
commit e93ecbe1d0
3 changed files with 5 additions and 25 deletions

View File

@ -511,10 +511,6 @@ final class Analyzer
$this->argument_map[$file_path] = $argument_map;
}
}
if ($pool->didHaveError()) {
exit(1);
}
} else {
$i = 0;

View File

@ -417,10 +417,6 @@ final class Scanner
);
}
}
if ($pool->didHaveError()) {
exit(1);
}
} else {
$i = 0;

View File

@ -80,8 +80,6 @@ final class Pool
/** @var resource[] */
private array $read_streams = [];
private bool $did_have_error = false;
/** @var ?Closure(mixed): void */
private ?Closure $task_done_closure = null;
@ -361,6 +359,7 @@ final class Pool
if ($message instanceof ForkProcessDoneMessage) {
$terminationMessages[] = $message->data;
} elseif ($message instanceof ForkTaskDoneMessage) {
$done[(int)$file] = true;
if ($this->task_done_closure !== null) {
($this->task_done_closure)($message->data);
}
@ -378,17 +377,15 @@ final class Pool
}
throw new Exception($message->message);
} else {
error_log('Child should return ForkMessage - response type=' . gettype($message));
$this->did_have_error = true;
throw new Exception('Child should return ForkMessage - response type=' . gettype($message));
}
}
}
// If the stream has closed, stop trying to select on it.
if (feof($file)) {
if ($content[(int)$file] !== '') {
error_log('Child did not send full message before closing the connection');
$this->did_have_error = true;
if ($content[(int)$file] !== '' || !isset($done[(int)$file])) {
throw new Exception('Child did not send full message before closing the connection');
}
fclose($file);
@ -450,8 +447,7 @@ final class Pool
* @psalm-suppress UndefinedConstant
*/
if ($term_sig !== SIGALRM) {
$this->did_have_error = true;
error_log("Child terminated with return code $return_code and signal $term_sig");
throw new Exception("Child terminated with return code $return_code and signal $term_sig");
}
}
}
@ -459,12 +455,4 @@ final class Pool
return $content;
}
/**
* Returns true if this had an error, e.g. due to memory limits or due to a child process crashing.
*/
public function didHaveError(): bool
{
return $this->did_have_error;
}
}