Skip to content
This repository was archived by the owner on Nov 26, 2022. It is now read-only.

Commit e39de00

Browse files
committed
improve iterable support
1 parent 9ef04a8 commit e39de00

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/Parser/QueryParser.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,25 @@ private static function encodeMatches(array $matches): string
273273
}
274274

275275
/**
276-
* Converts a collection of key/value pairs and returns the store PHP variables as elements of an array.
276+
* Parses the query string like parse_str without mangling the results.
277277
*
278278
* The result is similar as PHP parse_str when used with its
279279
* second argument with the difference that variable names are
280280
* not mangled.
281281
*
282282
* @see http://php.net/parse_str
283283
* @see https://wiki.php.net/rfc/on_demand_name_mangling
284+
*
285+
* @param null|mixed $query
286+
*/
287+
public static function extract($query, string $separator = '&', int $enc_type = PHP_QUERY_RFC3986): array
288+
{
289+
return self::convert(self::parse($query, $separator, $enc_type));
290+
}
291+
292+
/**
293+
* Converts a collection of key/value pairs and returns
294+
* the store PHP variables as elements of an array.
284295
*/
285296
public static function convert(iterable $pairs): array
286297
{

src/functions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ function query_parse($query, string $separator = '&', int $enc_type = PHP_QUERY_
4444
/**
4545
* Parse the query string like parse_str without mangling the results.
4646
*
47-
* @see QueryExtracter::extract
47+
* @see QueryParser::extract
4848
*
4949
* @param null|mixed $query
5050
*/
5151
function query_extract($query, string $separator = '&', int $enc_type = PHP_QUERY_RFC3986): array
5252
{
53-
return QueryParser::convert(QueryParser::parse($query, $separator, $enc_type));
53+
return QueryParser::extract($query, $separator, $enc_type);
5454
}

0 commit comments

Comments
 (0)