1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the Shieldon package. |
4
|
|
|
* |
5
|
|
|
* (c) Terry L. <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
declare(strict_types=1); |
12
|
|
|
|
13
|
|
|
namespace Shieldon\Psr17; |
14
|
|
|
|
15
|
|
|
use Psr\Http\Message\UriFactoryInterface; |
16
|
|
|
use Psr\Http\Message\UriInterface; |
17
|
|
|
use Shieldon\Psr7\Uri; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* PSR-17 Uri Factory |
21
|
|
|
*/ |
22
|
|
|
class UriFactory implements UriFactoryInterface |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
*/ |
27
|
|
|
public function createUri(string $uri = '') : UriInterface |
28
|
|
|
{ |
29
|
|
|
return new Uri($uri); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/* |
33
|
|
|
|-------------------------------------------------------------------------- |
34
|
|
|
| Non PSR-7 Methods. |
35
|
|
|
|-------------------------------------------------------------------------- |
36
|
|
|
*/ |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Create a UriInterface instance from global variable. |
40
|
|
|
* |
41
|
|
|
* @return UriInterface |
42
|
|
|
*/ |
43
|
|
|
public static function fromGlobal(): UriInterface |
44
|
|
|
{ |
45
|
|
|
$server = $_SERVER ?? []; |
46
|
|
|
|
47
|
|
|
$uri = ''; |
48
|
|
|
$user = ''; |
49
|
|
|
$host = ''; |
50
|
|
|
$pass = ''; |
51
|
|
|
$path = ''; |
52
|
|
|
$port = ''; |
53
|
|
|
$query = ''; |
54
|
|
|
$scheme = ''; |
55
|
|
|
|
56
|
|
|
$uriComponents = [ |
57
|
|
|
'user' => 'PHP_AUTH_USER', |
58
|
|
|
'host' => 'HTTP_HOST', |
59
|
|
|
'pass' => 'PHP_AUTH_PW', |
60
|
|
|
'path' => 'REQUEST_URI', |
61
|
|
|
'port' => 'SERVER_PORT', |
62
|
|
|
'query' => 'QUERY_STRING', |
63
|
|
|
'scheme' => 'REQUEST_SCHEME', |
64
|
|
|
]; |
65
|
|
|
|
66
|
|
|
foreach ($uriComponents as $key => $value) { |
67
|
|
|
${$key} = $server[$value] ?? ''; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
$userInfo = $user; |
71
|
|
|
|
72
|
|
|
if ($pass) { |
73
|
|
|
$userInfo .= ':' . $pass; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
$authority = ''; |
77
|
|
|
|
78
|
|
|
if ($userInfo) { |
79
|
|
|
$authority .= $userInfo . '@'; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
$authority .= $host; |
83
|
|
|
|
84
|
|
|
if ($port) { |
85
|
|
|
$authority .= ':' . $port; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
if ($scheme) { |
89
|
|
|
$uri .= $scheme . ':'; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
if ($authority) { |
93
|
|
|
$uri .= '//' . $authority; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
$uri .= '/' . ltrim($path, '/'); |
97
|
|
|
|
98
|
|
|
if ($query) { |
99
|
|
|
$uri .= '?' . $query; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
return new Uri($uri); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Create a new URI. |
107
|
|
|
* |
108
|
|
|
* @return StreamInterface |
|
|
|
|
109
|
|
|
*/ |
110
|
|
|
public function fromNew(): UriInterface |
111
|
|
|
{ |
112
|
|
|
return new Uri(); |
|
|
|
|
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|
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