Skip to content

Commit 605a5f3

Browse files
committed
more precise types
1 parent 45a2620 commit 605a5f3

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

stubs/core.stub

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,15 @@ function header_register_callback(callable $callback): bool {}
364364
function register_tick_function(callable $callback, mixed ...$args): bool {}
365365

366366
/**
367-
* @param string|array<string> $command
368-
* @param list<list<string>|resource> $descriptor_spec
369-
* @param array<resource> $pipes
370-
* @param array<mixed> $env_vars
367+
* @template P of int = int
368+
*
369+
* @param string|list<string> $command
370+
* @param array<P, list<string>|resource> $descriptor_spec
371+
* @param array<mixed> $pipes
372+
* @param array<string, mixed> $env_vars
371373
* @param array<string, bool> $options
372374
*
373-
* @param-out list<resource> $pipes
375+
* @param-out array<P, resource> $pipes
374376
*
375377
* @return resource|false
376378
*/

tests/PHPStan/Analyser/nsrt/bug-13197.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function execute(string $command): ?array
2525
$pipes
2626
);
2727

28-
assertType('list<resource>', $pipes);
28+
assertType('array<0|1|2, resource>', $pipes);
2929

3030
if (!is_resource($process)) {
3131
return null;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug13197b;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
function execute(string $command): void
8+
{
9+
if (!function_exists('proc_open')) {
10+
return;
11+
}
12+
13+
$pipes = [];
14+
15+
$process = @proc_open(
16+
$command,
17+
[
18+
['pipe', 'rb'],
19+
3 => ['pipe', 'wb'], // stdout
20+
5 => ['pipe', 'wb'], // stderr
21+
],
22+
$pipes
23+
);
24+
25+
assertType('array<0|3|5, resource>', $pipes);
26+
}

0 commit comments

Comments
 (0)