← All changes
|
includes/sdk/google/guzzlehttp/psr7/src/Query.php
+13
-13
1.2.12
→
1.4.2
View file →
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | declare (strict_types=1); |
| 4 | -namespace Dudlewebs\WPMCS\GuzzleHttp\Psr7; | |
| 4 | +namespace Dudlewebs\WPMCS\GCP\GuzzleHttp\Psr7; | |
| 5 | 5 | |
| 6 | 6 | final class Query |
| 7 | 7 | { |
| 8 | 8 | /** |
| @@ -15,9 +15,9 @@ | ||
| 15 | 15 | * |
| 16 | 16 | * @param string $str Query string to parse |
| 17 | 17 | * @param int|bool $urlEncoding How the query string is encoded |
| 18 | 18 | */ |
| 19 | - public static function parse(string $str, $urlEncoding = \true): array | |
| 19 | + public static function parse(string $str, $urlEncoding = \true) : array | |
| 20 | 20 | { |
| 21 | 21 | $result = []; |
| 22 | 22 | if ($str === '') { |
| 23 | 23 | return $result; |
| @@ -23,9 +23,9 @@ | ||
| 23 | 23 | return $result; |
| 24 | 24 | } |
| 25 | 25 | if ($urlEncoding === \true) { |
| 26 | 26 | $decoder = function ($value) { |
| 27 | - return rawurldecode(str_replace('+', ' ', (string) $value)); | |
| 27 | + return \rawurldecode(\str_replace('+', ' ', (string) $value)); | |
| 28 | 28 | }; |
| 29 | 29 | } elseif ($urlEncoding === \PHP_QUERY_RFC3986) { |
| 30 | 30 | $decoder = 'rawurldecode'; |
| 31 | 31 | } elseif ($urlEncoding === \PHP_QUERY_RFC1738) { |
| @@ -34,16 +34,16 @@ | ||
| 34 | 34 | $decoder = function ($str) { |
| 35 | 35 | return $str; |
| 36 | 36 | }; |
| 37 | 37 | } |
| 38 | - foreach (explode('&', $str) as $kvp) { | |
| 39 | - $parts = explode('=', $kvp, 2); | |
| 38 | + foreach (\explode('&', $str) as $kvp) { | |
| 39 | + $parts = \explode('=', $kvp, 2); | |
| 40 | 40 | $key = $decoder($parts[0]); |
| 41 | 41 | $value = isset($parts[1]) ? $decoder($parts[1]) : null; |
| 42 | - if (!array_key_exists($key, $result)) { | |
| 42 | + if (!\array_key_exists($key, $result)) { | |
| 43 | 43 | $result[$key] = $value; |
| 44 | 44 | } else { |
| 45 | - if (!is_array($result[$key])) { | |
| 45 | + if (!\is_array($result[$key])) { | |
| 46 | 46 | $result[$key] = [$result[$key]]; |
| 47 | 47 | } |
| 48 | 48 | $result[$key][] = $value; |
| 49 | 49 | } |
| @@ -64,15 +64,15 @@ | ||
| 64 | 64 | * encode using RFC1738. |
| 65 | 65 | * @param bool $treatBoolsAsInts Set to true to encode as 0/1, and |
| 66 | 66 | * false as false/true. |
| 67 | 67 | */ |
| 68 | - public static function build(array $params, $encoding = \PHP_QUERY_RFC3986, bool $treatBoolsAsInts = \true): string | |
| 68 | + public static function build(array $params, $encoding = \PHP_QUERY_RFC3986, bool $treatBoolsAsInts = \true) : string | |
| 69 | 69 | { |
| 70 | 70 | if (!$params) { |
| 71 | 71 | return ''; |
| 72 | 72 | } |
| 73 | 73 | if ($encoding === \false) { |
| 74 | - $encoder = function (string $str): string { | |
| 74 | + $encoder = function (string $str) : string { | |
| 75 | 75 | return $str; |
| 76 | 76 | }; |
| 77 | 77 | } elseif ($encoding === \PHP_QUERY_RFC3986) { |
| 78 | 78 | $encoder = 'rawurlencode'; |
| @@ -88,11 +88,11 @@ | ||
| 88 | 88 | }; |
| 89 | 89 | $qs = ''; |
| 90 | 90 | foreach ($params as $k => $v) { |
| 91 | 91 | $k = $encoder((string) $k); |
| 92 | - if (!is_array($v)) { | |
| 92 | + if (!\is_array($v)) { | |
| 93 | 93 | $qs .= $k; |
| 94 | - $v = is_bool($v) ? $castBool($v) : $v; | |
| 94 | + $v = \is_bool($v) ? $castBool($v) : $v; | |
| 95 | 95 | if ($v !== null) { |
| 96 | 96 | $qs .= '=' . $encoder((string) $v); |
| 97 | 97 | } |
| 98 | 98 | $qs .= '&'; |
| @@ -98,9 +98,9 @@ | ||
| 98 | 98 | $qs .= '&'; |
| 99 | 99 | } else { |
| 100 | 100 | foreach ($v as $vv) { |
| 101 | 101 | $qs .= $k; |
| 102 | - $vv = is_bool($vv) ? $castBool($vv) : $vv; | |
| 102 | + $vv = \is_bool($vv) ? $castBool($vv) : $vv; | |
| 103 | 103 | if ($vv !== null) { |
| 104 | 104 | $qs .= '=' . $encoder((string) $vv); |
| 105 | 105 | } |
| 106 | 106 | $qs .= '&'; |
| @@ -106,7 +106,7 @@ | ||
| 106 | 106 | $qs .= '&'; |
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | - return $qs ? (string) substr($qs, 0, -1) : ''; | |
| 110 | + return $qs ? (string) \substr($qs, 0, -1) : ''; | |
| 111 | 111 | } |
| 112 | 112 | } |