PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.5
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / vendor_prefixed / guzzlehttp / guzzle / src / functions.php

functions.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.5, at vendor_prefixed/guzzlehttp/guzzle/src/functions.php

240 lines 10.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace YoastSEO_Vendor\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 get_debug_type() instead.
15 */
16 function describe_type($input) : string
17 {
18 \YoastSEO_Vendor\trigger_deprecation('guzzlehttp/guzzle', '7.1', '%s() is deprecated and will be removed in 8.0. Use get_debug_type() instead.', __FUNCTION__);
19 switch (\gettype($input)) {
20 case 'object':
21 return 'object(' . \get_class($input) . ')';
22 case 'array':
23 return 'array(' . \count($input) . ')';
24 default:
25 \ob_start();
26 \var_dump($input);
27 // normalize float vs double
28 /** @var string $varDumpContent */
29 $varDumpContent = \ob_get_clean();
30 return \str_replace('double(', 'float(', \rtrim($varDumpContent, " \n\r\t\x00\v"));
31 }
32 }
33 /**
34 * Parses an array of header lines into an associative array of headers.
35 *
36 * @param iterable $lines Header lines array of strings in the following
37 * format: "Name: Value"
38 *
39 * @deprecated headers_from_lines will be removed in guzzlehttp/guzzle:8.0. Use Utils::headersFromLines instead.
40 */
41 function headers_from_lines(iterable $lines) : array
42 {
43 \YoastSEO_Vendor\trigger_deprecation('guzzlehttp/guzzle', '7.1', '%s() is deprecated and will be removed in 8.0. Use Utils::headersFromLines() instead.', __FUNCTION__);
44 return \YoastSEO_Vendor\GuzzleHttp\Utils::headersFromLines($lines);
45 }
46 /**
47 * Returns a debug stream based on the provided variable.
48 *
49 * @param mixed $value Optional value
50 *
51 * @return resource
52 *
53 * @deprecated debug_resource will be removed in guzzlehttp/guzzle:8.0. Use Utils::debugResource instead.
54 */
55 function debug_resource($value = null)
56 {
57 \YoastSEO_Vendor\trigger_deprecation('guzzlehttp/guzzle', '7.1', '%s() is deprecated and will be removed in 8.0. Use Utils::debugResource() instead.', __FUNCTION__);
58 return \YoastSEO_Vendor\GuzzleHttp\Utils::debugResource($value);
59 }
60 /**
61 * Chooses and creates a default handler to use based on the environment.
62 *
63 * The returned handler is not wrapped by any default middlewares.
64 *
65 * @return callable(\Psr\Http\Message\RequestInterface, array): Promise\PromiseInterface Returns the best handler for the given system.
66 *
67 * @throws \RuntimeException if no viable Handler is available.
68 *
69 * @deprecated choose_handler will be removed in guzzlehttp/guzzle:8.0. Use Utils::chooseHandler instead.
70 */
71 function choose_handler() : callable
72 {
73 \YoastSEO_Vendor\trigger_deprecation('guzzlehttp/guzzle', '7.1', '%s() is deprecated and will be removed in 8.0. Use Utils::chooseHandler() instead.', __FUNCTION__);
74 return \YoastSEO_Vendor\GuzzleHttp\Utils::chooseHandler();
75 }
76 /**
77 * Get the default User-Agent string to use with Guzzle.
78 *
79 * @deprecated default_user_agent will be removed in guzzlehttp/guzzle:8.0. Use Utils::defaultUserAgent instead.
80 */
81 function default_user_agent() : string
82 {
83 \YoastSEO_Vendor\trigger_deprecation('guzzlehttp/guzzle', '7.1', '%s() is deprecated and will be removed in 8.0. Use Utils::defaultUserAgent() instead.', __FUNCTION__);
84 return \YoastSEO_Vendor\GuzzleHttp\Utils::defaultUserAgent();
85 }
86 /**
87 * Returns the default cacert bundle for the current system.
88 *
89 * First, the openssl.cafile and curl.cainfo php.ini settings are checked.
90 * If those settings are not configured, then the common locations for
91 * bundles found on Red Hat, CentOS, Fedora, Ubuntu, Debian, FreeBSD, OS X
92 * and Windows are checked. If any of these file locations are found on
93 * disk, they will be utilized.
94 *
95 * Note: the result of this function is cached for subsequent calls.
96 *
97 * @throws \RuntimeException if no bundle can be found.
98 *
99 * @deprecated default_ca_bundle will be removed in guzzlehttp/guzzle:8.0. This function is not needed in PHP 5.6+.
100 */
101 function default_ca_bundle() : string
102 {
103 \YoastSEO_Vendor\trigger_deprecation('guzzlehttp/guzzle', '7.1', '%s() is deprecated and will be removed in 8.0. This function is not needed in PHP 5.6+.', __FUNCTION__);
104 static $cached = null;
105 static $cafiles = [
106 // Red Hat, CentOS, Fedora (provided by the ca-certificates package)
107 '/etc/pki/tls/certs/ca-bundle.crt',
108 // Ubuntu, Debian (provided by the ca-certificates package)
109 '/etc/ssl/certs/ca-certificates.crt',
110 // FreeBSD (provided by the ca_root_nss package)
111 '/usr/local/share/certs/ca-root-nss.crt',
112 // SLES 12 (provided by the ca-certificates package)
113 '/var/lib/ca-certificates/ca-bundle.pem',
114 // OS X provided by homebrew (using the default path)
115 '/usr/local/etc/openssl/cert.pem',
116 // Google app engine
117 '/etc/ca-certificates.crt',
118 // Windows?
119 'C:\\windows\\system32\\curl-ca-bundle.crt',
120 'C:\\windows\\curl-ca-bundle.crt',
121 ];
122 if ($cached) {
123 return $cached;
124 }
125 if ($ca = \ini_get('openssl.cafile')) {
126 return $cached = $ca;
127 }
128 if ($ca = \ini_get('curl.cainfo')) {
129 return $cached = $ca;
130 }
131 foreach ($cafiles as $filename) {
132 if (\file_exists($filename)) {
133 return $cached = $filename;
134 }
135 }
136 throw new \RuntimeException(<<<EOT
137 No system CA bundle could be found in any of the the common system locations.
138 PHP versions earlier than 5.6 are not properly configured to use the system's
139 CA bundle by default. In order to verify peer certificates, you will need to
140 supply the path on disk to a certificate bundle to the 'verify' request option:
141 https://github.com/guzzle/guzzle/blob/7.15/docs/request-options.md#verify. If
142 you do not need a specific certificate bundle, then Mozilla provides a commonly
143 used CA bundle which can be downloaded here (provided by the maintainer of
144 cURL): https://curl.se/ca/cacert.pem. Once you have a CA bundle available on
145 disk, you can set the 'openssl.cafile' PHP ini setting to point to the path to
146 the file, allowing you to omit the 'verify' request option. See
147 https://curl.se/docs/sslcerts.html for more information.
148 EOT
149 );
150 }
151 /**
152 * Creates an associative array of lowercase header names to the actual
153 * header casing.
154 *
155 * @deprecated normalize_header_keys will be removed in guzzlehttp/guzzle:8.0. Use Utils::normalizeHeaderKeys instead.
156 */
157 function normalize_header_keys(array $headers) : array
158 {
159 \YoastSEO_Vendor\trigger_deprecation('guzzlehttp/guzzle', '7.1', '%s() is deprecated and will be removed in 8.0. Use Utils::normalizeHeaderKeys() instead.', __FUNCTION__);
160 return \YoastSEO_Vendor\GuzzleHttp\Utils::normalizeHeaderKeys($headers);
161 }
162 /**
163 * Returns true if the provided host matches any of the no proxy areas.
164 *
165 * This method will strip a port from the host if it is present. Each pattern
166 * can be matched with an exact match (e.g., "foo.com" == "foo.com") or a
167 * partial match: (e.g., "foo.com" == "baz.foo.com" and ".foo.com" ==
168 * "baz.foo.com", but ".foo.com" != "foo.com").
169 *
170 * Areas are matched in the following cases:
171 * 1. "*" (without quotes) always matches any hosts.
172 * 2. An exact match.
173 * 3. The area starts with "." and the area is the last part of the host. e.g.
174 * '.mit.edu' will match any host that ends with '.mit.edu'.
175 *
176 * @param string $host Host to check against the patterns.
177 * @param string[] $noProxyArray An array of host patterns.
178 *
179 * @throws Exception\InvalidArgumentException
180 *
181 * @deprecated is_host_in_noproxy will be removed in guzzlehttp/guzzle:8.0. Use Utils::isHostInNoProxy instead.
182 */
183 function is_host_in_noproxy(string $host, array $noProxyArray) : bool
184 {
185 \YoastSEO_Vendor\trigger_deprecation('guzzlehttp/guzzle', '7.1', '%s() is deprecated and will be removed in 8.0. Use Utils::isHostInNoProxy() instead.', __FUNCTION__);
186 return \YoastSEO_Vendor\GuzzleHttp\Utils::isHostInNoProxy($host, $noProxyArray);
187 }
188 /**
189 * Wrapper for json_decode that throws when an error occurs.
190 *
191 * @param string $json JSON data to parse
192 * @param bool $assoc When true, returned objects will be converted
193 * into associative arrays.
194 * @param int $depth User specified recursion depth.
195 * @param int $options Bitmask of JSON decode options.
196 *
197 * @return object|array|string|int|float|bool|null
198 *
199 * @throws Exception\InvalidArgumentException if the JSON cannot be decoded.
200 *
201 * @see https://www.php.net/manual/en/function.json-decode.php
202 * @deprecated json_decode will be removed in guzzlehttp/guzzle:8.0. Use PHP's json_decode() instead.
203 */
204 function json_decode(string $json, bool $assoc = \false, int $depth = 512, int $options = 0)
205 {
206 \YoastSEO_Vendor\trigger_deprecation('guzzlehttp/guzzle', '7.1', '%s() is deprecated and will be removed in 8.0. Use PHP\'s json_decode() instead.', __FUNCTION__);
207 if ($depth < 1) {
208 throw new \YoastSEO_Vendor\GuzzleHttp\Exception\InvalidArgumentException('json_decode error: Maximum stack depth exceeded');
209 }
210 $data = \json_decode($json, $assoc, $depth, $options);
211 if (\JSON_ERROR_NONE !== \json_last_error()) {
212 throw new \YoastSEO_Vendor\GuzzleHttp\Exception\InvalidArgumentException('json_decode error: ' . \json_last_error_msg());
213 }
214 /** @var object|array|string|int|float|bool|null $data */
215 return $data;
216 }
217 /**
218 * Wrapper for JSON encoding that throws when an error occurs.
219 *
220 * @param mixed $value The value being encoded
221 * @param int $options JSON encode option bitmask
222 * @param int $depth Set the maximum depth. Must be greater than zero.
223 *
224 * @throws Exception\InvalidArgumentException if the JSON cannot be encoded.
225 *
226 * @see https://www.php.net/manual/en/function.json-encode.php
227 * @deprecated json_encode will be removed in guzzlehttp/guzzle:8.0. Use PHP's json_encode() instead.
228 */
229 function json_encode($value, int $options = 0, int $depth = 512) : string
230 {
231 \YoastSEO_Vendor\trigger_deprecation('guzzlehttp/guzzle', '7.1', '%s() is deprecated and will be removed in 8.0. Use PHP\'s json_encode() instead.', __FUNCTION__);
232 /** @var positive-int $depth */
233 $json = \json_encode($value, $options, $depth);
234 if (\JSON_ERROR_NONE !== \json_last_error()) {
235 throw new \YoastSEO_Vendor\GuzzleHttp\Exception\InvalidArgumentException('json_encode error: ' . \json_last_error_msg());
236 }
237 /** @var non-empty-string $json */
238 return $json;
239 }
240