Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stubs/core.stub
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function str_shuffle(string $string): string {}

/**
* @param array<mixed> $result
* @param-out array<int|string, array<mixed>|string> $result
* @param-out ($string is lowercase-string ? array<int|string, array<mixed>|lowercase-string> : array<int|string, array<mixed>|string>) $result
*/
function parse_str(string $string, array &$result): void {}

Expand Down
36 changes: 36 additions & 0 deletions tests/PHPStan/Analyser/nsrt/lowercase-string-parse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace LowercaseStringParseStr;

use function PHPStan\Testing\assertType;

class Foo
{

/**
* @param lowercase-string $lowercase
*/
public function parse(string $lowercase, string $string): void
{
$a = [];
parse_str($lowercase, $a);

if (array_key_exists('foo', $a)) {
$value = $a['foo'];
if (\is_string($value)) {
assertType('lowercase-string', $value);
}
}

$b = [];
parse_str($string, $b);

if (array_key_exists('foo', $b)) {
$value = $b['foo'];
if (\is_string($value)) {
assertType('string', $value);
}
}
}

}
Loading