File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php declare(strict_types = 1);
2+
3+ namespace Bug13197;
4+
5+ use function PHPStan\Testing\assertType;
6+
7+ /**
8+ * @return array{string, string}|null STDOUT & STDERR tuple
9+ */
10+ function execute(string $command): ?array
11+ {
12+ if (!function_exists('proc_open')) {
13+ return null;
14+ }
15+
16+ $pipes = [];
17+
18+ $process = @proc_open(
19+ $command,
20+ [
21+ ['pipe', 'rb'],
22+ ['pipe', 'wb'], // stdout
23+ ['pipe', 'wb'], // stderr
24+ ],
25+ $pipes
26+ );
27+
28+ assertType('list<resource>', $pipes);
29+
30+ if (!is_resource($process)) {
31+ return null;
32+ }
33+
34+ fclose($pipes[0]);
35+
36+ $stdout = (string) stream_get_contents($pipes[1]);
37+ $stderr = (string) stream_get_contents($pipes[2]);
38+
39+ proc_close($process);
40+
41+ return [$stdout, $stderr];
42+ }
Original file line number Diff line number Diff line change @@ -2317,4 +2317,11 @@ public function testBug12317(): void
23172317 ]);
23182318 }
23192319
2320+ public function testBug13197(): void
2321+ {
2322+ $this->checkExplicitMixed = true;
2323+ $this->checkImplicitMixed = true;
2324+ $this->analyse([__DIR__ . '/../../Analyser/nsrt/bug-13197.php'], []);
2325+ }
2326+
23202327}
You can’t perform that action at this time.
0 commit comments