Skip to content

Commit 6ac4986

Browse files
committed
regression test
1 parent 33c4498 commit 6ac4986

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
}

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)