fix:更新已知bug,优化代码

This commit is contained in:
Ying
2022-11-28 19:11:12 +08:00
parent f6aee95cfc
commit 9445b206a2
1378 changed files with 53759 additions and 20789 deletions

View File

@@ -18,47 +18,36 @@ namespace Symfony\Component\HttpFoundation;
*/
class RequestMatcher implements RequestMatcherInterface
{
/**
* @var string|null
*/
private $path;
/**
* @var string|null
*/
private $host;
/**
* @var int|null
*/
private $port;
private ?string $path = null;
private ?string $host = null;
private ?int $port = null;
/**
* @var string[]
*/
private $methods = [];
private array $methods = [];
/**
* @var string[]
*/
private $ips = [];
/**
* @var array
*/
private $attributes = [];
private array $ips = [];
/**
* @var string[]
*/
private $schemes = [];
private array $attributes = [];
/**
* @var string[]
*/
private array $schemes = [];
/**
* @param string|string[]|null $methods
* @param string|string[]|null $ips
* @param string|string[]|null $schemes
*/
public function __construct(string $path = null, string $host = null, $methods = null, $ips = null, array $attributes = [], $schemes = null, int $port = null)
public function __construct(string $path = null, string $host = null, string|array $methods = null, string|array $ips = null, array $attributes = [], string|array $schemes = null, int $port = null)
{
$this->matchPath($path);
$this->matchHost($host);
@@ -77,7 +66,7 @@ class RequestMatcher implements RequestMatcherInterface
*
* @param string|string[]|null $scheme An HTTP scheme or an array of HTTP schemes
*/
public function matchScheme($scheme)
public function matchScheme(string|array|null $scheme)
{
$this->schemes = null !== $scheme ? array_map('strtolower', (array) $scheme) : [];
}
@@ -123,7 +112,7 @@ class RequestMatcher implements RequestMatcherInterface
*
* @param string|string[]|null $ips A specific IP address or a range specified using IP/netmask like 192.168.1.0/24
*/
public function matchIps($ips)
public function matchIps(string|array|null $ips)
{
$ips = null !== $ips ? (array) $ips : [];
@@ -137,7 +126,7 @@ class RequestMatcher implements RequestMatcherInterface
*
* @param string|string[]|null $method An HTTP method or an array of HTTP methods
*/
public function matchMethod($method)
public function matchMethod(string|array|null $method)
{
$this->methods = null !== $method ? array_map('strtoupper', (array) $method) : [];
}
@@ -153,7 +142,7 @@ class RequestMatcher implements RequestMatcherInterface
/**
* {@inheritdoc}
*/
public function matches(Request $request)
public function matches(Request $request): bool
{
if ($this->schemes && !\in_array($request->getScheme(), $this->schemes, true)) {
return false;