Skip to content

Commit 99299a2

Browse files
authored
Improve getopt() function stub
1 parent ed7dae5 commit 99299a2

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Diff for: stubs/core.stub

+9
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,12 @@ function abs($num) {}
318318
* @return ($categorize is true ? array<string, array<string, mixed>> : array<string, mixed>)
319319
*/
320320
function get_defined_constants(bool $categorize = false): array {}
321+
322+
/**
323+
* @param array<string> $long_options
324+
* @param mixed $rest_index
325+
* @param-out positive-int $rest_index
326+
* @return __benevolent<array<string,string>|array<string,false>|array<string,list<mixed>>|false>
327+
*/
328+
function getopt(string $short_options, array $long_options = [], &$rest_index = null) {}
329+

Diff for: tests/PHPStan/Analyser/nsrt/getopt.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
use function getopt;
66
use function PHPStan\Testing\assertType;
77

8-
$opts = getopt("ab:c::", ["longopt1", "longopt2:", "longopt3::"]);
8+
$opts = getopt("ab:c::", ["longopt1", "longopt2:", "longopt3::"], $restIndex);
99
assertType('(array<string, list<mixed>|string|false>|false)', $opts);
10+
assertType('int<1, max>', $restIndex);

0 commit comments

Comments
 (0)