Skip to content

Commit 4e4df1a

Browse files
committed
more precise parse_str param-out
1 parent 77fc29b commit 4e4df1a

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

stubs/core.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function bin2hex(string $string): string {}
7070

7171
/**
7272
* @param array<mixed> $result
73-
* @param-out array<int|string, string> $result
73+
* @param-out array<int|string, string|list<string>> $result
7474
*/
7575
function parse_str(string $string, array &$result): void {}
7676

tests/PHPStan/Analyser/data/param-out.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,20 @@ function fooDateTime(\SplFileObject $splFileObject, ?string $wouldBlock) {
303303
assertType('string', $wouldBlock);
304304
}
305305

306-
function testMtch() {
306+
function testMatch() {
307307
preg_match('#.*#', 'foo', $matches);
308308
assertType('array<string>', $matches);
309309
}
310+
311+
function testParseStr() {
312+
$str="first=value&arr[]=foo+bar&arr[]=baz";
313+
parse_str($str, $output);
314+
315+
/*
316+
echo $output['first'];//value
317+
echo $output['arr'][0];//foo bar
318+
echo $output['arr'][1];//baz
319+
*/
320+
321+
\PHPStan\Testing\assertType('array<int|string, list<string>|string>', $output);
322+
}

0 commit comments

Comments
 (0)