upgraded dependencies
This commit is contained in:
24
vendor/guzzlehttp/psr7/src/Query.php
vendored
24
vendor/guzzlehttp/psr7/src/Query.php
vendored
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
final class Query
|
||||
@@ -14,10 +16,8 @@ final class Query
|
||||
*
|
||||
* @param string $str Query string to parse
|
||||
* @param int|bool $urlEncoding How the query string is encoded
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function parse($str, $urlEncoding = true)
|
||||
public static function parse(string $str, $urlEncoding = true): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
@@ -27,7 +27,7 @@ final class Query
|
||||
|
||||
if ($urlEncoding === true) {
|
||||
$decoder = function ($value) {
|
||||
return rawurldecode(str_replace('+', ' ', $value));
|
||||
return rawurldecode(str_replace('+', ' ', (string) $value));
|
||||
};
|
||||
} elseif ($urlEncoding === PHP_QUERY_RFC3986) {
|
||||
$decoder = 'rawurldecode';
|
||||
@@ -43,7 +43,7 @@ final class Query
|
||||
$parts = explode('=', $kvp, 2);
|
||||
$key = $decoder($parts[0]);
|
||||
$value = isset($parts[1]) ? $decoder($parts[1]) : null;
|
||||
if (!isset($result[$key])) {
|
||||
if (!array_key_exists($key, $result)) {
|
||||
$result[$key] = $value;
|
||||
} else {
|
||||
if (!is_array($result[$key])) {
|
||||
@@ -67,17 +67,15 @@ final class Query
|
||||
* @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986
|
||||
* to encode using RFC3986, or PHP_QUERY_RFC1738
|
||||
* to encode using RFC1738.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function build(array $params, $encoding = PHP_QUERY_RFC3986)
|
||||
public static function build(array $params, $encoding = PHP_QUERY_RFC3986): string
|
||||
{
|
||||
if (!$params) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($encoding === false) {
|
||||
$encoder = function ($str) {
|
||||
$encoder = function (string $str): string {
|
||||
return $str;
|
||||
};
|
||||
} elseif ($encoding === PHP_QUERY_RFC3986) {
|
||||
@@ -90,18 +88,20 @@ final class Query
|
||||
|
||||
$qs = '';
|
||||
foreach ($params as $k => $v) {
|
||||
$k = $encoder($k);
|
||||
$k = $encoder((string) $k);
|
||||
if (!is_array($v)) {
|
||||
$qs .= $k;
|
||||
$v = is_bool($v) ? (int) $v : $v;
|
||||
if ($v !== null) {
|
||||
$qs .= '=' . $encoder($v);
|
||||
$qs .= '=' . $encoder((string) $v);
|
||||
}
|
||||
$qs .= '&';
|
||||
} else {
|
||||
foreach ($v as $vv) {
|
||||
$qs .= $k;
|
||||
$vv = is_bool($vv) ? (int) $vv : $vv;
|
||||
if ($vv !== null) {
|
||||
$qs .= '=' . $encoder($vv);
|
||||
$qs .= '=' . $encoder((string) $vv);
|
||||
}
|
||||
$qs .= '&';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user