first commit
This commit is contained in:
45
vendor/symfony/http-foundation/RequestMatcher/AttributesRequestMatcher.php
vendored
Normal file
45
vendor/symfony/http-foundation/RequestMatcher/AttributesRequestMatcher.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\RequestMatcher;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
|
||||
|
||||
/**
|
||||
* Checks the Request attributes matches all regular expressions.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class AttributesRequestMatcher implements RequestMatcherInterface
|
||||
{
|
||||
/**
|
||||
* @param array<string, string> $regexps
|
||||
*/
|
||||
public function __construct(private array $regexps)
|
||||
{
|
||||
}
|
||||
|
||||
public function matches(Request $request): bool
|
||||
{
|
||||
foreach ($this->regexps as $key => $regexp) {
|
||||
$attribute = $request->attributes->get($key);
|
||||
if (!\is_string($attribute)) {
|
||||
return false;
|
||||
}
|
||||
if (!preg_match('{'.$regexp.'}', $attribute)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
43
vendor/symfony/http-foundation/RequestMatcher/ExpressionRequestMatcher.php
vendored
Normal file
43
vendor/symfony/http-foundation/RequestMatcher/ExpressionRequestMatcher.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\RequestMatcher;
|
||||
|
||||
use Symfony\Component\ExpressionLanguage\Expression;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
|
||||
|
||||
/**
|
||||
* ExpressionRequestMatcher uses an expression to match a Request.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class ExpressionRequestMatcher implements RequestMatcherInterface
|
||||
{
|
||||
public function __construct(
|
||||
private ExpressionLanguage $language,
|
||||
private Expression|string $expression,
|
||||
) {
|
||||
}
|
||||
|
||||
public function matches(Request $request): bool
|
||||
{
|
||||
return $this->language->evaluate($this->expression, [
|
||||
'request' => $request,
|
||||
'method' => $request->getMethod(),
|
||||
'path' => rawurldecode($request->getPathInfo()),
|
||||
'host' => $request->getHost(),
|
||||
'ip' => $request->getClientIp(),
|
||||
'attributes' => $request->attributes->all(),
|
||||
]);
|
||||
}
|
||||
}
|
32
vendor/symfony/http-foundation/RequestMatcher/HostRequestMatcher.php
vendored
Normal file
32
vendor/symfony/http-foundation/RequestMatcher/HostRequestMatcher.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\RequestMatcher;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
|
||||
|
||||
/**
|
||||
* Checks the Request URL host name matches a regular expression.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class HostRequestMatcher implements RequestMatcherInterface
|
||||
{
|
||||
public function __construct(private string $regexp)
|
||||
{
|
||||
}
|
||||
|
||||
public function matches(Request $request): bool
|
||||
{
|
||||
return preg_match('{'.$this->regexp.'}i', $request->getHost());
|
||||
}
|
||||
}
|
44
vendor/symfony/http-foundation/RequestMatcher/IpsRequestMatcher.php
vendored
Normal file
44
vendor/symfony/http-foundation/RequestMatcher/IpsRequestMatcher.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\RequestMatcher;
|
||||
|
||||
use Symfony\Component\HttpFoundation\IpUtils;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
|
||||
|
||||
/**
|
||||
* Checks the client IP of a Request.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class IpsRequestMatcher implements RequestMatcherInterface
|
||||
{
|
||||
private array $ips;
|
||||
|
||||
/**
|
||||
* @param string[]|string $ips A specific IP address or a range specified using IP/netmask like 192.168.1.0/24
|
||||
* Strings can contain a comma-delimited list of IPs/ranges
|
||||
*/
|
||||
public function __construct(array|string $ips)
|
||||
{
|
||||
$this->ips = array_reduce((array) $ips, static fn (array $ips, string $ip) => array_merge($ips, preg_split('/\s*,\s*/', $ip)), []);
|
||||
}
|
||||
|
||||
public function matches(Request $request): bool
|
||||
{
|
||||
if (!$this->ips) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return IpUtils::checkIp($request->getClientIp() ?? '', $this->ips);
|
||||
}
|
||||
}
|
28
vendor/symfony/http-foundation/RequestMatcher/IsJsonRequestMatcher.php
vendored
Normal file
28
vendor/symfony/http-foundation/RequestMatcher/IsJsonRequestMatcher.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\RequestMatcher;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
|
||||
|
||||
/**
|
||||
* Checks the Request content is valid JSON.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class IsJsonRequestMatcher implements RequestMatcherInterface
|
||||
{
|
||||
public function matches(Request $request): bool
|
||||
{
|
||||
return json_validate($request->getContent());
|
||||
}
|
||||
}
|
46
vendor/symfony/http-foundation/RequestMatcher/MethodRequestMatcher.php
vendored
Normal file
46
vendor/symfony/http-foundation/RequestMatcher/MethodRequestMatcher.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\RequestMatcher;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
|
||||
|
||||
/**
|
||||
* Checks the HTTP method of a Request.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class MethodRequestMatcher implements RequestMatcherInterface
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private array $methods = [];
|
||||
|
||||
/**
|
||||
* @param string[]|string $methods An HTTP method or an array of HTTP methods
|
||||
* Strings can contain a comma-delimited list of methods
|
||||
*/
|
||||
public function __construct(array|string $methods)
|
||||
{
|
||||
$this->methods = array_reduce(array_map('strtoupper', (array) $methods), static fn (array $methods, string $method) => array_merge($methods, preg_split('/\s*,\s*/', $method)), []);
|
||||
}
|
||||
|
||||
public function matches(Request $request): bool
|
||||
{
|
||||
if (!$this->methods) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return \in_array($request->getMethod(), $this->methods, true);
|
||||
}
|
||||
}
|
32
vendor/symfony/http-foundation/RequestMatcher/PathRequestMatcher.php
vendored
Normal file
32
vendor/symfony/http-foundation/RequestMatcher/PathRequestMatcher.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\RequestMatcher;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
|
||||
|
||||
/**
|
||||
* Checks the Request URL path info matches a regular expression.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class PathRequestMatcher implements RequestMatcherInterface
|
||||
{
|
||||
public function __construct(private string $regexp)
|
||||
{
|
||||
}
|
||||
|
||||
public function matches(Request $request): bool
|
||||
{
|
||||
return preg_match('{'.$this->regexp.'}', rawurldecode($request->getPathInfo()));
|
||||
}
|
||||
}
|
32
vendor/symfony/http-foundation/RequestMatcher/PortRequestMatcher.php
vendored
Normal file
32
vendor/symfony/http-foundation/RequestMatcher/PortRequestMatcher.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\RequestMatcher;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
|
||||
|
||||
/**
|
||||
* Checks the HTTP port of a Request.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class PortRequestMatcher implements RequestMatcherInterface
|
||||
{
|
||||
public function __construct(private int $port)
|
||||
{
|
||||
}
|
||||
|
||||
public function matches(Request $request): bool
|
||||
{
|
||||
return $request->getPort() === $this->port;
|
||||
}
|
||||
}
|
46
vendor/symfony/http-foundation/RequestMatcher/SchemeRequestMatcher.php
vendored
Normal file
46
vendor/symfony/http-foundation/RequestMatcher/SchemeRequestMatcher.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\RequestMatcher;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
|
||||
|
||||
/**
|
||||
* Checks the HTTP scheme of a Request.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class SchemeRequestMatcher implements RequestMatcherInterface
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private array $schemes;
|
||||
|
||||
/**
|
||||
* @param string[]|string $schemes A scheme or a list of schemes
|
||||
* Strings can contain a comma-delimited list of schemes
|
||||
*/
|
||||
public function __construct(array|string $schemes)
|
||||
{
|
||||
$this->schemes = array_reduce(array_map('strtolower', (array) $schemes), static fn (array $schemes, string $scheme) => array_merge($schemes, preg_split('/\s*,\s*/', $scheme)), []);
|
||||
}
|
||||
|
||||
public function matches(Request $request): bool
|
||||
{
|
||||
if (!$this->schemes) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return \in_array($request->getScheme(), $this->schemes, true);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user