Dep: update

주로 PHAN
This commit is contained in:
2021-08-06 22:39:09 +09:00
parent 404cd24855
commit 21e7a4d966
1098 changed files with 92137 additions and 33228 deletions
+56 -6
View File
@@ -1,4 +1,5 @@
<?php
namespace GuzzleHttp\Psr7;
use Psr\Http\Message\UriInterface;
@@ -66,7 +67,7 @@ class Uri implements UriInterface
{
// weak type check to also accept null until we can add scalar type hints
if ($uri != '') {
$parts = parse_url($uri);
$parts = self::parse($uri);
if ($parts === false) {
throw new \InvalidArgumentException("Unable to parse URI: $uri");
}
@@ -74,6 +75,49 @@ class Uri implements UriInterface
}
}
/**
* UTF-8 aware \parse_url() replacement.
*
* The internal function produces broken output for non ASCII domain names
* (IDN) when used with locales other than "C".
*
* On the other hand, cURL understands IDN correctly only when UTF-8 locale
* is configured ("C.UTF-8", "en_US.UTF-8", etc.).
*
* @see https://bugs.php.net/bug.php?id=52923
* @see https://www.php.net/manual/en/function.parse-url.php#114817
* @see https://curl.haxx.se/libcurl/c/CURLOPT_URL.html#ENCODING
*
* @param string $url
*
* @return array|false
*/
private static function parse($url)
{
// If IPv6
$prefix = '';
if (preg_match('%^(.*://\[[0-9:a-f]+\])(.*?)$%', $url, $matches)) {
$prefix = $matches[1];
$url = $matches[2];
}
$encodedUrl = preg_replace_callback(
'%[^:/@?&=#]+%usD',
static function ($matches) {
return urlencode($matches[0]);
},
$url
);
$result = parse_url($prefix . $encodedUrl);
if ($result === false) {
return false;
}
return array_map('urldecode', $result);
}
public function __toString()
{
return self::composeComponents(
@@ -166,6 +210,7 @@ class Uri implements UriInterface
* @param UriInterface $uri
*
* @return bool
*
* @see Uri::isNetworkPathReference
* @see Uri::isAbsolutePathReference
* @see Uri::isRelativePathReference
@@ -184,6 +229,7 @@ class Uri implements UriInterface
* @param UriInterface $uri
*
* @return bool
*
* @link https://tools.ietf.org/html/rfc3986#section-4.2
*/
public static function isNetworkPathReference(UriInterface $uri)
@@ -199,6 +245,7 @@ class Uri implements UriInterface
* @param UriInterface $uri
*
* @return bool
*
* @link https://tools.ietf.org/html/rfc3986#section-4.2
*/
public static function isAbsolutePathReference(UriInterface $uri)
@@ -217,6 +264,7 @@ class Uri implements UriInterface
* @param UriInterface $uri
*
* @return bool
*
* @link https://tools.ietf.org/html/rfc3986#section-4.2
*/
public static function isRelativePathReference(UriInterface $uri)
@@ -237,6 +285,7 @@ class Uri implements UriInterface
* @param UriInterface|null $base An optional base URI to compare against
*
* @return bool
*
* @link https://tools.ietf.org/html/rfc3986#section-4.4
*/
public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null)
@@ -357,6 +406,7 @@ class Uri implements UriInterface
* @param array $parts
*
* @return UriInterface
*
* @link http://php.net/manual/en/function.parse-url.php
*
* @throws \InvalidArgumentException If the components do not form a valid URI.
@@ -575,7 +625,7 @@ class Uri implements UriInterface
throw new \InvalidArgumentException('Scheme must be a string');
}
return strtolower($scheme);
return \strtr($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
}
/**
@@ -611,7 +661,7 @@ class Uri implements UriInterface
throw new \InvalidArgumentException('Host must be a string');
}
return strtolower($host);
return \strtr($host, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
}
/**
@@ -640,7 +690,7 @@ class Uri implements UriInterface
/**
* @param UriInterface $uri
* @param array $keys
*
*
* @return array
*/
private static function getFilteredQueryString(UriInterface $uri, array $keys)
@@ -661,7 +711,7 @@ class Uri implements UriInterface
/**
* @param string $key
* @param string|null $value
*
*
* @return string
*/
private static function generateQueryString($key, $value)
@@ -753,7 +803,7 @@ class Uri implements UriInterface
'by adding a leading slash to the path is deprecated since version 1.4 and will throw an exception instead.',
E_USER_DEPRECATED
);
$this->path = '/'. $this->path;
$this->path = '/' . $this->path;
//throw new \InvalidArgumentException('The path of a URI with an authority must start with a slash "/" or be empty');
}
}