Skip to content
Open
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
1 change: 1 addition & 0 deletions bin/functionMetadata_original.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
'array_key_last' => ['hasSideEffects' => false],
'array_key_exists' => ['hasSideEffects' => false],
'array_keys' => ['hasSideEffects' => false],
'array_map' => ['hasSideEffects' => false],
'array_merge' => ['hasSideEffects' => false],
'array_merge_recursive' => ['hasSideEffects' => false],
'array_pad' => ['hasSideEffects' => false],
Expand Down
1 change: 1 addition & 0 deletions resources/functionMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@
'array_key_last' => ['hasSideEffects' => false],
'array_keys' => ['hasSideEffects' => false],
'array_last' => ['hasSideEffects' => false],
'array_map' => ['hasSideEffects' => false],
'array_merge' => ['hasSideEffects' => false],
'array_merge_recursive' => ['hasSideEffects' => false],
'array_pad' => ['hasSideEffects' => false],
Expand Down
7 changes: 7 additions & 0 deletions tests/PHPStan/Rules/Pure/PureMethodRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,13 @@ public function testAllMethodsArePure(): void
]);
}

#[RequiresPhp('>= 8.0')]
public function testBug11100(): void
{
$this->treatPhpDocTypesAsCertain = true;
$this->analyse([__DIR__ . '/data/bug-11100.php'], []);
}

public function testBug12382(): void
{
$this->treatPhpDocTypesAsCertain = true;
Expand Down
32 changes: 32 additions & 0 deletions tests/PHPStan/Rules/Pure/data/bug-11100.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php // lint >= 8.0

declare(strict_types = 1);

namespace Bug11100;

final class FooClass
{
/**
* @param array<string, string|int> $getParams
*
* @phpstan-pure
*/
public function build(array $getParams, string $trailingSlash, bool $useSlashSeparator): string
{
if ($getParams === []) {
return '';
}

if ($useSlashSeparator) {
return '/' . implode('/', array_map(
static function (string $key, string|int $value): string {
return rawurlencode($key) . '/' . rawurlencode((string) $value);
},
array_keys($getParams),
$getParams
)) . $trailingSlash;
}

return $trailingSlash . '?' . http_build_query($getParams);
}
}
Loading