@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | } else { |
153 | 153 | $indexFile = substr($this->getEntranceFile(), strlen($this->getDocumentRoot())); |
154 | 154 | } |
155 | - return $this->indexFile = str_replace('\\', '/' ,$indexFile); |
|
155 | + return $this->indexFile = str_replace('\\', '/', $indexFile); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -165,26 +165,26 @@ discard block |
||
165 | 165 | { |
166 | 166 | $Url = $this->Uri; |
167 | 167 | |
168 | - $queryString=''; |
|
168 | + $queryString = ''; |
|
169 | 169 | // for /?/xx |
170 | 170 | if (\strpos($Url, '/?/') === 0) { |
171 | 171 | $Url = substr($Url, 2); |
172 | 172 | } |
173 | 173 | $indexFile = $this->getIndexFile(); |
174 | - if (\strpos($Url, $indexFile) ===0) { |
|
174 | + if (\strpos($Url, $indexFile) === 0) { |
|
175 | 175 | // for /index.php/ |
176 | - $Url = \substr($Url, strlen($indexFile));// for /index.php?/ |
|
176 | + $Url = \substr($Url, strlen($indexFile)); // for /index.php?/ |
|
177 | 177 | if (\strpos($Url, '?/') === 0) { |
178 | 178 | $Url = ltrim($Url, '?'); |
179 | 179 | } |
180 | 180 | // for /index.php |
181 | - elseif (\strpos($Url, '/')!== 0) { |
|
181 | + elseif (\strpos($Url, '/') !== 0) { |
|
182 | 182 | $Url = '/'.$Url; |
183 | 183 | } |
184 | 184 | } |
185 | 185 | $queryStart = \strpos($Url, '?'); |
186 | 186 | if ($queryStart !== false) { |
187 | - $queryString = \substr($Url, $queryStart+1); |
|
187 | + $queryString = \substr($Url, $queryStart + 1); |
|
188 | 188 | $Url = \substr($Url, 0, $queryStart); |
189 | 189 | } |
190 | 190 | $this->Url = $Url; |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | parse_str($queryString, $this->queryParameter); |
193 | 193 | } |
194 | 194 | if ($applyServer) { |
195 | - $_SERVER['PATH_INFO'] = $this->Url; |
|
195 | + $_SERVER['PATH_INFO'] = $this->Url; |
|
196 | 196 | $_SERVER['SCRIPT_NAME'] = $this->getIndexFile(); |
197 | 197 | $_SERVER['PHP_SELF'] = $this->getIndexFile(); |
198 | 198 | $_GET = $this->queryParameter; |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | } |
211 | 211 | $serverBasicUri = $this->getServerUri(); |
212 | 212 | $indexFile = $this->getIndexFile(); |
213 | - $isWindows = DIRECTORY_SEPARATOR === '\\'; |
|
214 | - $isRoot= in_array(substr($indexFile, 1), static::getDefaultIndexs()); |
|
213 | + $isWindows = DIRECTORY_SEPARATOR === '\\'; |
|
214 | + $isRoot = in_array(substr($indexFile, 1), static::getDefaultIndexs()); |
|
215 | 215 | if ($this->enabledRewrite && $isRoot) { |
216 | 216 | if ($isWindows && !$this->enabledBeautifyUrl) { |
217 | 217 | return $this->basicUri = $serverBasicUri.'/?/'; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return array|null |
46 | 46 | */ |
47 | - public function json():?array; |
|
47 | + public function json(): ?array; |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * 获取GET参数 |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param mixed $default |
54 | 54 | * @return mixed |
55 | 55 | */ |
56 | - public function get(?string $name=null, $default =null); |
|
56 | + public function get(?string $name = null, $default = null); |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * 获取POST请求的值 |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param mixed $default |
63 | 63 | * @return mixed 获取的值 |
64 | 64 | */ |
65 | - public static function post(?string $name=null, $default=null); |
|
65 | + public static function post(?string $name = null, $default = null); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * 获取HTTP输入 |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param string|null $name |
86 | 86 | * @return boolean |
87 | 87 | */ |
88 | - public function hasGet(?string $name=null); |
|
88 | + public function hasGet(?string $name = null); |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * 判断是否有JSON数据请求 |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @return boolean |
101 | 101 | */ |
102 | - public function hasPost(?string $name=null); |
|
102 | + public function hasPost(?string $name = null); |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * 获取参数 |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param mixed $default |
116 | 116 | * @return mixed |
117 | 117 | */ |
118 | - public function getHeader(string $name, $default =null); |
|
118 | + public function getHeader(string $name, $default = null); |
|
119 | 119 | |
120 | 120 | // Uri |
121 | 121 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @param mixed $default |
67 | 67 | * @return mixed |
68 | 68 | */ |
69 | - public function getHeader(string $name, $default =null) |
|
69 | + public function getHeader(string $name, $default = null) |
|
70 | 70 | { |
71 | 71 | if (array_key_exists(strtolower($name), $this->headers)) { |
72 | 72 | return $this->headers[$name]; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function ip() |
94 | 94 | { |
95 | - static $ipFrom = ['HTTP_CLIENT_IP','HTTP_X_FORWARDED_FOR','HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP','HTTP_FORWARDED_FOR','HTTP_FORWARDED','REMOTE_ADDR']; |
|
95 | + static $ipFrom = ['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR']; |
|
96 | 96 | foreach ($ipFrom as $key) { |
97 | 97 | if (array_key_exists($key, $_SERVER)) { |
98 | 98 | foreach (explode(',', $_SERVER[$key]) as $ip) { |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | } |
122 | 122 | $method = strtoupper($server['REQUEST_METHOD'] ?? 'GET'); |
123 | 123 | $Uri = $server['REQUEST_Uri']??'/'; |
124 | - $headers = HeaderItem::buildFromServer($server ?: $_SERVER); |
|
125 | - $request = new Request($method, $Uri, $headers); |
|
124 | + $headers = HeaderItem::buildFromServer($server ?: $_SERVER); |
|
125 | + $request = new Request($method, $Uri, $headers); |
|
126 | 126 | $request->setDocumentRoot($server['DOCUMENT_ROOT']); |
127 | 127 | if ($simulate && $server !== null) { |
128 | 128 | $request->setServer($server); |