Skip to content

Commit a5e5719

Browse files
committed
Prevent Call to end() on null
1 parent aa62a8a commit a5e5719

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

build/baseline-7.4.neon

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ parameters:
1818
message: "#^Class PHPStan\\\\Parallel\\\\Process has an uninitialized property \\$process\\. Give it default value or assign it in the constructor\\.$#"
1919
count: 1
2020
path: ../src/Parallel/Process.php
21-
-
22-
message: "#^Class PHPStan\\\\Parallel\\\\Process has an uninitialized property \\$in\\. Give it default value or assign it in the constructor\\.$#"
23-
count: 1
24-
path: ../src/Parallel/Process.php
2521
-
2622
message: "#^Class PHPStan\\\\PhpDoc\\\\ResolvedPhpDocBlock has an uninitialized property \\$phpDocNodes\\. Give it default value or assign it in the constructor\\.$#"
2723
count: 1

src/Parallel/Process.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Process
2121

2222
public \React\ChildProcess\Process $process;
2323

24-
private WritableStreamInterface $in;
24+
private ?WritableStreamInterface $in = null;
2525

2626
/** @var resource */
2727
private $stdOut;
@@ -106,6 +106,9 @@ private function cancelTimer(): void
106106
public function request(array $data): void
107107
{
108108
$this->cancelTimer();
109+
if ($this->in === null) {
110+
throw new ShouldNotHappenException();
111+
}
109112
$this->in->write($data);
110113
$this->timer = $this->loop->addTimer($this->timeoutSeconds, function (): void {
111114
$onError = $this->onError;
@@ -124,6 +127,10 @@ public function quit(): void
124127
$pipe->close();
125128
}
126129

130+
if ($this->in === null) {
131+
return;
132+
}
133+
127134
$this->in->end();
128135
}
129136

0 commit comments

Comments
 (0)