Skip to content

Commit 45a2620

Browse files
committed
regression test
1 parent b56ad89 commit 45a2620

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
@@ -2216,4 +2216,11 @@ public function testBug12317(): void
22162216
]);
22172217
}
22182218

2219+
public function testBug13197(): void
2220+
{
2221+
$this->checkExplicitMixed = true;
2222+
$this->checkImplicitMixed = true;
2223+
$this->analyse([__DIR__ . '/../../Analyser/nsrt/bug-13197.php'], []);
2224+
}
2225+
22192226
}

0 commit comments

Comments
 (0)