Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 21... Línea 21...
21
     */
21
     */
22
    public static function describeType($input): string
22
    public static function describeType($input): string
23
    {
23
    {
24
        switch (\gettype($input)) {
24
        switch (\gettype($input)) {
25
            case 'object':
25
            case 'object':
26
                return 'object(' . \get_class($input) . ')';
26
                return 'object('.\get_class($input).')';
27
            case 'array':
27
            case 'array':
28
                return 'array(' . \count($input) . ')';
28
                return 'array('.\count($input).')';
29
            default:
29
            default:
30
                \ob_start();
30
                \ob_start();
31
                \var_dump($input);
31
                \var_dump($input);
32
                // normalize float vs double
32
                // normalize float vs double
33
                /** @var string $varDumpContent */
33
                /** @var string $varDumpContent */
Línea 69... Línea 69...
69
        }
69
        }
70
        if (\defined('STDOUT')) {
70
        if (\defined('STDOUT')) {
71
            return \STDOUT;
71
            return \STDOUT;
72
        }
72
        }
Línea 73... Línea 73...
73
 
73
 
74
        return \GuzzleHttp\Psr7\Utils::tryFopen('php://output', 'w');
74
        return Psr7\Utils::tryFopen('php://output', 'w');
Línea 75... Línea 75...
75
    }
75
    }
76
 
76
 
77
    /**
77
    /**
78
     * Chooses and creates a default handler to use based on the environment.
78
     * Chooses and creates a default handler to use based on the environment.
79
     *
79
     *
80
     * The returned handler is not wrapped by any default middlewares.
-
 
81
     *
-
 
82
     * @throws \RuntimeException if no viable Handler is available.
80
     * The returned handler is not wrapped by any default middlewares.
-
 
81
     *
-
 
82
     * @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system.
83
     *
83
     *
84
     * @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system.
84
     * @throws \RuntimeException if no viable Handler is available.
85
     */
85
     */
86
    public static function chooseHandler(): callable
86
    public static function chooseHandler(): callable
Línea 87... Línea 87...
87
    {
87
    {
88
        $handler = null;
88
        $handler = null;
89
 
89
 
90
        if (\defined('CURLOPT_CUSTOMREQUEST')) {
90
        if (\defined('CURLOPT_CUSTOMREQUEST') && \function_exists('curl_version') && version_compare(curl_version()['version'], '7.21.2') >= 0) {
91
            if (\function_exists('curl_multi_exec') && \function_exists('curl_exec')) {
91
            if (\function_exists('curl_multi_exec') && \function_exists('curl_exec')) {
92
                $handler = Proxy::wrapSync(new CurlMultiHandler(), new CurlHandler());
92
                $handler = Proxy::wrapSync(new CurlMultiHandler(), new CurlHandler());
Línea 174... Línea 174...
174
            <<< EOT
174
            <<< EOT
175
No system CA bundle could be found in any of the the common system locations.
175
No system CA bundle could be found in any of the the common system locations.
176
PHP versions earlier than 5.6 are not properly configured to use the system's
176
PHP versions earlier than 5.6 are not properly configured to use the system's
177
CA bundle by default. In order to verify peer certificates, you will need to
177
CA bundle by default. In order to verify peer certificates, you will need to
178
supply the path on disk to a certificate bundle to the 'verify' request
178
supply the path on disk to a certificate bundle to the 'verify' request
179
option: http://docs.guzzlephp.org/en/latest/clients.html#verify. If you do not
179
option: https://docs.guzzlephp.org/en/latest/request-options.html#verify. If
180
need a specific certificate bundle, then Mozilla provides a commonly used CA
180
you do not need a specific certificate bundle, then Mozilla provides a commonly
181
bundle which can be downloaded here (provided by the maintainer of cURL):
181
used CA bundle which can be downloaded here (provided by the maintainer of
182
https://curl.haxx.se/ca/cacert.pem. Once
182
cURL): https://curl.haxx.se/ca/cacert.pem. Once you have a CA bundle available
183
you have a CA bundle available on disk, you can set the 'openssl.cafile' PHP
183
on disk, you can set the 'openssl.cafile' PHP ini setting to point to the path
184
ini setting to point to the path to the file, allowing you to omit the 'verify'
184
to the file, allowing you to omit the 'verify' request option. See
185
request option. See https://curl.haxx.se/docs/sslcerts.html for more
185
https://curl.haxx.se/docs/sslcerts.html for more information.
186
information.
-
 
187
EOT
186
EOT
188
        );
187
        );
189
    }
188
    }
Línea 190... Línea 189...
190
 
189
 
Línea 245... Línea 244...
245
                // Exact matches.
244
                // Exact matches.
246
                return true;
245
                return true;
247
            }
246
            }
248
            // Special match if the area when prefixed with ".". Remove any
247
            // Special match if the area when prefixed with ".". Remove any
249
            // existing leading "." and add a new leading ".".
248
            // existing leading "." and add a new leading ".".
250
            $area = '.' . \ltrim($area, '.');
249
            $area = '.'.\ltrim($area, '.');
251
            if (\substr($host, -(\strlen($area))) === $area) {
250
            if (\substr($host, -\strlen($area)) === $area) {
252
                return true;
251
                return true;
253
            }
252
            }
254
        }
253
        }
Línea 255... Línea 254...
255
 
254
 
Línea 267... Línea 266...
267
     *
266
     *
268
     * @return object|array|string|int|float|bool|null
267
     * @return object|array|string|int|float|bool|null
269
     *
268
     *
270
     * @throws InvalidArgumentException if the JSON cannot be decoded.
269
     * @throws InvalidArgumentException if the JSON cannot be decoded.
271
     *
270
     *
272
     * @link https://www.php.net/manual/en/function.json-decode.php
271
     * @see https://www.php.net/manual/en/function.json-decode.php
273
     */
272
     */
274
    public static function jsonDecode(string $json, bool $assoc = false, int $depth = 512, int $options = 0)
273
    public static function jsonDecode(string $json, bool $assoc = false, int $depth = 512, int $options = 0)
275
    {
274
    {
276
        $data = \json_decode($json, $assoc, $depth, $options);
275
        $data = \json_decode($json, $assoc, $depth, $options);
277
        if (\JSON_ERROR_NONE !== \json_last_error()) {
276
        if (\JSON_ERROR_NONE !== \json_last_error()) {
278
            throw new InvalidArgumentException('json_decode error: ' . \json_last_error_msg());
277
            throw new InvalidArgumentException('json_decode error: '.\json_last_error_msg());
279
        }
278
        }
Línea 280... Línea 279...
280
 
279
 
281
        return $data;
280
        return $data;
Línea 288... Línea 287...
288
     * @param int   $options JSON encode option bitmask
287
     * @param int   $options JSON encode option bitmask
289
     * @param int   $depth   Set the maximum depth. Must be greater than zero.
288
     * @param int   $depth   Set the maximum depth. Must be greater than zero.
290
     *
289
     *
291
     * @throws InvalidArgumentException if the JSON cannot be encoded.
290
     * @throws InvalidArgumentException if the JSON cannot be encoded.
292
     *
291
     *
293
     * @link https://www.php.net/manual/en/function.json-encode.php
292
     * @see https://www.php.net/manual/en/function.json-encode.php
294
     */
293
     */
295
    public static function jsonEncode($value, int $options = 0, int $depth = 512): string
294
    public static function jsonEncode($value, int $options = 0, int $depth = 512): string
296
    {
295
    {
297
        $json = \json_encode($value, $options, $depth);
296
        $json = \json_encode($value, $options, $depth);
298
        if (\JSON_ERROR_NONE !== \json_last_error()) {
297
        if (\JSON_ERROR_NONE !== \json_last_error()) {
299
            throw new InvalidArgumentException('json_encode error: ' . \json_last_error_msg());
298
            throw new InvalidArgumentException('json_encode error: '.\json_last_error_msg());
300
        }
299
        }
Línea 301... Línea 300...
301
 
300
 
302
        /** @var string */
301
        /** @var string */
303
        return $json;
302
        return $json;
Línea 339... Línea 338...
339
                    }
338
                    }
340
                }
339
                }
Línea 341... Línea 340...
341
 
340
 
342
                $errorMessage = 'IDN conversion failed';
341
                $errorMessage = 'IDN conversion failed';
343
                if ($errors) {
342
                if ($errors) {
344
                    $errorMessage .= ' (errors: ' . implode(', ', $errors) . ')';
343
                    $errorMessage .= ' (errors: '.implode(', ', $errors).')';
Línea 345... Línea 344...
345
                }
344
                }
346
 
345
 
347
                throw new InvalidArgumentException($errorMessage);
346
                throw new InvalidArgumentException($errorMessage);