1 |
efrain |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
namespace GuzzleHttp;
|
|
|
4 |
|
|
|
5 |
/**
|
|
|
6 |
* Debug function used to describe the provided value type and class.
|
|
|
7 |
*
|
|
|
8 |
* @param mixed $input Any type of variable to describe the type of. This
|
|
|
9 |
* parameter misses a typehint because of that.
|
|
|
10 |
*
|
|
|
11 |
* @return string Returns a string containing the type of the variable and
|
|
|
12 |
* if a class is provided, the class name.
|
|
|
13 |
*
|
|
|
14 |
* @deprecated describe_type will be removed in guzzlehttp/guzzle:8.0. Use Utils::describeType instead.
|
|
|
15 |
*/
|
|
|
16 |
function describe_type($input): string
|
|
|
17 |
{
|
|
|
18 |
return Utils::describeType($input);
|
|
|
19 |
}
|
|
|
20 |
|
|
|
21 |
/**
|
|
|
22 |
* Parses an array of header lines into an associative array of headers.
|
|
|
23 |
*
|
|
|
24 |
* @param iterable $lines Header lines array of strings in the following
|
|
|
25 |
* format: "Name: Value"
|
|
|
26 |
*
|
|
|
27 |
* @deprecated headers_from_lines will be removed in guzzlehttp/guzzle:8.0. Use Utils::headersFromLines instead.
|
|
|
28 |
*/
|
|
|
29 |
function headers_from_lines(iterable $lines): array
|
|
|
30 |
{
|
|
|
31 |
return Utils::headersFromLines($lines);
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
/**
|
|
|
35 |
* Returns a debug stream based on the provided variable.
|
|
|
36 |
*
|
|
|
37 |
* @param mixed $value Optional value
|
|
|
38 |
*
|
|
|
39 |
* @return resource
|
|
|
40 |
*
|
|
|
41 |
* @deprecated debug_resource will be removed in guzzlehttp/guzzle:8.0. Use Utils::debugResource instead.
|
|
|
42 |
*/
|
|
|
43 |
function debug_resource($value = null)
|
|
|
44 |
{
|
|
|
45 |
return Utils::debugResource($value);
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
/**
|
|
|
49 |
* Chooses and creates a default handler to use based on the environment.
|
|
|
50 |
*
|
|
|
51 |
* The returned handler is not wrapped by any default middlewares.
|
|
|
52 |
*
|
|
|
53 |
* @throws \RuntimeException if no viable Handler is available.
|
|
|
54 |
*
|
|
|
55 |
* @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system.
|
|
|
56 |
*
|
|
|
57 |
* @deprecated choose_handler will be removed in guzzlehttp/guzzle:8.0. Use Utils::chooseHandler instead.
|
|
|
58 |
*/
|
|
|
59 |
function choose_handler(): callable
|
|
|
60 |
{
|
|
|
61 |
return Utils::chooseHandler();
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
/**
|
|
|
65 |
* Get the default User-Agent string to use with Guzzle.
|
|
|
66 |
*
|
|
|
67 |
* @deprecated default_user_agent will be removed in guzzlehttp/guzzle:8.0. Use Utils::defaultUserAgent instead.
|
|
|
68 |
*/
|
|
|
69 |
function default_user_agent(): string
|
|
|
70 |
{
|
|
|
71 |
return Utils::defaultUserAgent();
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
/**
|
|
|
75 |
* Returns the default cacert bundle for the current system.
|
|
|
76 |
*
|
|
|
77 |
* First, the openssl.cafile and curl.cainfo php.ini settings are checked.
|
|
|
78 |
* If those settings are not configured, then the common locations for
|
|
|
79 |
* bundles found on Red Hat, CentOS, Fedora, Ubuntu, Debian, FreeBSD, OS X
|
|
|
80 |
* and Windows are checked. If any of these file locations are found on
|
|
|
81 |
* disk, they will be utilized.
|
|
|
82 |
*
|
|
|
83 |
* Note: the result of this function is cached for subsequent calls.
|
|
|
84 |
*
|
|
|
85 |
* @throws \RuntimeException if no bundle can be found.
|
|
|
86 |
*
|
|
|
87 |
* @deprecated default_ca_bundle will be removed in guzzlehttp/guzzle:8.0. This function is not needed in PHP 5.6+.
|
|
|
88 |
*/
|
|
|
89 |
function default_ca_bundle(): string
|
|
|
90 |
{
|
|
|
91 |
return Utils::defaultCaBundle();
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
/**
|
|
|
95 |
* Creates an associative array of lowercase header names to the actual
|
|
|
96 |
* header casing.
|
|
|
97 |
*
|
|
|
98 |
* @deprecated normalize_header_keys will be removed in guzzlehttp/guzzle:8.0. Use Utils::normalizeHeaderKeys instead.
|
|
|
99 |
*/
|
|
|
100 |
function normalize_header_keys(array $headers): array
|
|
|
101 |
{
|
|
|
102 |
return Utils::normalizeHeaderKeys($headers);
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
/**
|
|
|
106 |
* Returns true if the provided host matches any of the no proxy areas.
|
|
|
107 |
*
|
|
|
108 |
* This method will strip a port from the host if it is present. Each pattern
|
|
|
109 |
* can be matched with an exact match (e.g., "foo.com" == "foo.com") or a
|
|
|
110 |
* partial match: (e.g., "foo.com" == "baz.foo.com" and ".foo.com" ==
|
|
|
111 |
* "baz.foo.com", but ".foo.com" != "foo.com").
|
|
|
112 |
*
|
|
|
113 |
* Areas are matched in the following cases:
|
|
|
114 |
* 1. "*" (without quotes) always matches any hosts.
|
|
|
115 |
* 2. An exact match.
|
|
|
116 |
* 3. The area starts with "." and the area is the last part of the host. e.g.
|
|
|
117 |
* '.mit.edu' will match any host that ends with '.mit.edu'.
|
|
|
118 |
*
|
|
|
119 |
* @param string $host Host to check against the patterns.
|
|
|
120 |
* @param string[] $noProxyArray An array of host patterns.
|
|
|
121 |
*
|
|
|
122 |
* @throws Exception\InvalidArgumentException
|
|
|
123 |
*
|
|
|
124 |
* @deprecated is_host_in_noproxy will be removed in guzzlehttp/guzzle:8.0. Use Utils::isHostInNoProxy instead.
|
|
|
125 |
*/
|
|
|
126 |
function is_host_in_noproxy(string $host, array $noProxyArray): bool
|
|
|
127 |
{
|
|
|
128 |
return Utils::isHostInNoProxy($host, $noProxyArray);
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
/**
|
|
|
132 |
* Wrapper for json_decode that throws when an error occurs.
|
|
|
133 |
*
|
|
|
134 |
* @param string $json JSON data to parse
|
|
|
135 |
* @param bool $assoc When true, returned objects will be converted
|
|
|
136 |
* into associative arrays.
|
|
|
137 |
* @param int $depth User specified recursion depth.
|
|
|
138 |
* @param int $options Bitmask of JSON decode options.
|
|
|
139 |
*
|
|
|
140 |
* @return object|array|string|int|float|bool|null
|
|
|
141 |
*
|
|
|
142 |
* @throws Exception\InvalidArgumentException if the JSON cannot be decoded.
|
|
|
143 |
*
|
|
|
144 |
* @link https://www.php.net/manual/en/function.json-decode.php
|
|
|
145 |
* @deprecated json_decode will be removed in guzzlehttp/guzzle:8.0. Use Utils::jsonDecode instead.
|
|
|
146 |
*/
|
|
|
147 |
function json_decode(string $json, bool $assoc = false, int $depth = 512, int $options = 0)
|
|
|
148 |
{
|
|
|
149 |
return Utils::jsonDecode($json, $assoc, $depth, $options);
|
|
|
150 |
}
|
|
|
151 |
|
|
|
152 |
/**
|
|
|
153 |
* Wrapper for JSON encoding that throws when an error occurs.
|
|
|
154 |
*
|
|
|
155 |
* @param mixed $value The value being encoded
|
|
|
156 |
* @param int $options JSON encode option bitmask
|
|
|
157 |
* @param int $depth Set the maximum depth. Must be greater than zero.
|
|
|
158 |
*
|
|
|
159 |
* @throws Exception\InvalidArgumentException if the JSON cannot be encoded.
|
|
|
160 |
*
|
|
|
161 |
* @link https://www.php.net/manual/en/function.json-encode.php
|
|
|
162 |
* @deprecated json_encode will be removed in guzzlehttp/guzzle:8.0. Use Utils::jsonEncode instead.
|
|
|
163 |
*/
|
|
|
164 |
function json_encode($value, int $options = 0, int $depth = 512): string
|
|
|
165 |
{
|
|
|
166 |
return Utils::jsonEncode($value, $options, $depth);
|
|
|
167 |
}
|