Skip to content

Commit 979fbd9

Browse files
committed
Improve getopt() function stub
1 parent 8873cdc commit 979fbd9

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

stubs/core.stub

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,11 @@ 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-out int $rest_index
325+
* @return __benevolent<array<string,string>|array<string,false>|array<string,list<mixed>>|false>
326+
*/
327+
function getopt(string $short_options, array $long_options = [], int &$rest_index = null): array|false {}
328+

tests/PHPStan/Analyser/nsrt/getopt.php

Lines changed: 2 additions & 1 deletion
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', $restIndex);

0 commit comments

Comments
 (0)