mirror of
https://github.com/danog/psalm.git
synced 2024-12-03 10:07:52 +01:00
Throw exception instead of silently logging issues occurred during scan
This commit is contained in:
parent
7d6c88e88a
commit
e93ecbe1d0
@ -511,10 +511,6 @@ final class Analyzer
|
|||||||
$this->argument_map[$file_path] = $argument_map;
|
$this->argument_map[$file_path] = $argument_map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($pool->didHaveError()) {
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
|
@ -417,10 +417,6 @@ final class Scanner
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($pool->didHaveError()) {
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
|
@ -80,8 +80,6 @@ final class Pool
|
|||||||
/** @var resource[] */
|
/** @var resource[] */
|
||||||
private array $read_streams = [];
|
private array $read_streams = [];
|
||||||
|
|
||||||
private bool $did_have_error = false;
|
|
||||||
|
|
||||||
/** @var ?Closure(mixed): void */
|
/** @var ?Closure(mixed): void */
|
||||||
private ?Closure $task_done_closure = null;
|
private ?Closure $task_done_closure = null;
|
||||||
|
|
||||||
@ -361,6 +359,7 @@ final class Pool
|
|||||||
if ($message instanceof ForkProcessDoneMessage) {
|
if ($message instanceof ForkProcessDoneMessage) {
|
||||||
$terminationMessages[] = $message->data;
|
$terminationMessages[] = $message->data;
|
||||||
} elseif ($message instanceof ForkTaskDoneMessage) {
|
} elseif ($message instanceof ForkTaskDoneMessage) {
|
||||||
|
$done[(int)$file] = true;
|
||||||
if ($this->task_done_closure !== null) {
|
if ($this->task_done_closure !== null) {
|
||||||
($this->task_done_closure)($message->data);
|
($this->task_done_closure)($message->data);
|
||||||
}
|
}
|
||||||
@ -378,17 +377,15 @@ final class Pool
|
|||||||
}
|
}
|
||||||
throw new Exception($message->message);
|
throw new Exception($message->message);
|
||||||
} else {
|
} else {
|
||||||
error_log('Child should return ForkMessage - response type=' . gettype($message));
|
throw new Exception('Child should return ForkMessage - response type=' . gettype($message));
|
||||||
$this->did_have_error = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the stream has closed, stop trying to select on it.
|
// If the stream has closed, stop trying to select on it.
|
||||||
if (feof($file)) {
|
if (feof($file)) {
|
||||||
if ($content[(int)$file] !== '') {
|
if ($content[(int)$file] !== '' || !isset($done[(int)$file])) {
|
||||||
error_log('Child did not send full message before closing the connection');
|
throw new Exception('Child did not send full message before closing the connection');
|
||||||
$this->did_have_error = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose($file);
|
fclose($file);
|
||||||
@ -450,8 +447,7 @@ final class Pool
|
|||||||
* @psalm-suppress UndefinedConstant
|
* @psalm-suppress UndefinedConstant
|
||||||
*/
|
*/
|
||||||
if ($term_sig !== SIGALRM) {
|
if ($term_sig !== SIGALRM) {
|
||||||
$this->did_have_error = true;
|
throw new Exception("Child terminated with return code $return_code and signal $term_sig");
|
||||||
error_log("Child terminated with return code $return_code and signal $term_sig");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -459,12 +455,4 @@ final class Pool
|
|||||||
|
|
||||||
return $content;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user