Skip to content

Commit

Permalink
parse_str() might return arrays by-ref
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Nov 13, 2022
1 parent d0207ed commit 563e438
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
14 changes: 7 additions & 7 deletions stubs/core.stub
Expand Up @@ -70,10 +70,16 @@ function bin2hex(string $string): string {}

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

/**
* @param array<mixed> $result
* @param-out array<int|string, string|list<string>|array<mixed>> $result
*/
function mb_parse_str(string $string, array &$result = []): bool {}

/** @param-out float $percent */
function similar_text(string $string1, string $string2, float &$percent = null) : int {}

Expand Down Expand Up @@ -300,12 +306,6 @@ function fsockopen(string $hostname, int $port = -1, int &$error_code = null, st
*/
function headers_sent(string &$filename = null, int &$line = null): bool {}

/**
* @param mixed $result
* @param-out array<string, string|array<string>> $result
*/
function mb_parse_str(string $string, &$result = []): bool {}

/**
* @param-out callable-string $callable_name
*/
Expand Down
Expand Up @@ -700,4 +700,15 @@ public function testBug6243(): void
$this->analyse([__DIR__ . '/data/bug-6243.php'], []);
}

public function testBug8356(): void
{
$this->bleedingEdge = true;
$this->analyse([__DIR__ . '/data/bug-8356.php'], [
[
"Offset 'x' might not exist on array|string.",
7,
],
]);
}

}
9 changes: 9 additions & 0 deletions tests/PHPStan/Rules/Arrays/data/bug-8356.php
@@ -0,0 +1,9 @@
<?php

namespace Bug8356;

function foo(): void {
parse_str('filter[x][y]=0', $output);
print $output['filter']['x']['y'];
}

0 comments on commit 563e438

Please sign in to comment.