|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace BEAR\Package\Provide\Router; |
|
6
|
|
|
|
|
7
|
|
|
use BEAR\Sunday\Annotation\DefaultSchemeHost; |
|
8
|
|
|
use BEAR\Sunday\Extension\Router\RouterInterface; |
|
9
|
|
|
use BEAR\Sunday\Extension\Router\RouterMatch; |
|
10
|
|
|
use Override; |
|
11
|
|
|
|
|
12
|
|
|
use function assert; |
|
13
|
|
|
use function parse_url; |
|
14
|
|
|
|
|
15
|
|
|
use const PHP_URL_PATH; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @psalm-import-type Globals from RouterInterface |
|
19
|
|
|
* @psalm-import-type Server from RouterInterface |
|
20
|
|
|
* @psalm-suppress ClassMustBeFinal |
|
21
|
|
|
*/ |
|
22
|
|
|
class WebRouter implements RouterInterface, WebRouterInterface |
|
23
|
|
|
{ |
|
24
|
|
|
public function __construct( |
|
25
|
|
|
#[DefaultSchemeHost] |
|
26
|
|
|
private string $schemeHost, |
|
27
|
|
|
private HttpMethodParamsInterface $httpMethodParams, |
|
28
|
|
|
) { |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @param array{HTTP_X_HTTP_METHOD_OVERRIDE?: string, REQUEST_METHOD: string, REQUEST_URI: string, ...} $server |
|
33
|
|
|
* @param array{_GET: array<string|array>, _POST: array<string|array>} $globals |
|
34
|
|
|
*/ |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* {@inheritDoc} |
|
38
|
|
|
* |
|
39
|
|
|
* @param Globals $globals |
|
|
|
|
|
|
40
|
|
|
* @param Server $server |
|
|
|
|
|
|
41
|
|
|
*/ |
|
42
|
|
|
#[Override] |
|
43
|
|
|
public function match(array $globals, array $server) |
|
44
|
|
|
{ |
|
45
|
|
|
$requestUri = $server['REQUEST_URI']; |
|
46
|
|
|
$get = $globals['_GET']; |
|
47
|
|
|
$post = $globals['_POST']; |
|
48
|
|
|
[$method, $query] = $this->httpMethodParams->get($server, $get, $post); |
|
49
|
|
|
$parsedPath = parse_url($requestUri, PHP_URL_PATH); |
|
50
|
|
|
assert($parsedPath !== null && $parsedPath !== false); |
|
51
|
|
|
$path = $this->schemeHost . $parsedPath; |
|
52
|
|
|
|
|
53
|
|
|
return new RouterMatch($method, $path, $query); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* {@inheritDoc} |
|
58
|
|
|
*/ |
|
59
|
|
|
#[Override] |
|
60
|
|
|
public function generate($name, $data) |
|
61
|
|
|
{ |
|
62
|
|
|
return false; |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths