Skip to content

Commit a87845f

Browse files
committed
Add regression test for #11100
Closes phpstan/phpstan#11100
1 parent b5e93d5 commit a87845f

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

tests/PHPStan/Rules/Pure/PureMethodRuleTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,12 @@ public function testAllMethodsArePure(): void
279279
]);
280280
}
281281

282+
public function testBug11100(): void
283+
{
284+
$this->treatPhpDocTypesAsCertain = true;
285+
$this->analyse([__DIR__ . '/data/bug-11100.php'], []);
286+
}
287+
282288
public function testBug12382(): void
283289
{
284290
$this->treatPhpDocTypesAsCertain = true;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php // lint >= 8.0
2+
3+
namespace Bug11100;
4+
5+
final class FooClass
6+
{
7+
/**
8+
* @param array<string, string|int> $getParams
9+
*
10+
* @phpstan-pure
11+
*/
12+
public function build(array $getParams, string $trailingSlash, bool $useSlashSeparator): string
13+
{
14+
if ($getParams === []) {
15+
return '';
16+
}
17+
18+
if ($useSlashSeparator) {
19+
return '/' . implode('/', array_map(
20+
static function (string $key, string|int $value): string {
21+
return rawurlencode($key) . '/' . rawurlencode((string) $value);
22+
},
23+
array_keys($getParams),
24+
$getParams
25+
)) . $trailingSlash;
26+
}
27+
28+
return $trailingSlash . '?' . http_build_query($getParams);
29+
}
30+
}

0 commit comments

Comments
 (0)