Passed
Push — master ( ffd702...013443 )
by 世昌
02:02
created
nebula/request/attribute/UriAttribute.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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.'/?/';
Please login to merge, or discard this patch.
nebula/request/Request.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
nebula/route/RouteMatcher.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
     protected $matcher;
41 41
     
42 42
 
43
-    public function __construct(array $methods, string $uri, array $attribute=[])
43
+    public function __construct(array $methods, string $uri, array $attribute = [])
44 44
     {
45
-        array_walk($methods, function ($value) {
45
+        array_walk($methods, function($value) {
46 46
             return strtoupper($value);
47 47
         });
48 48
         $this->methods = $methods;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      * @param RequestInterface $request
140 140
      * @return array|null
141 141
      */
142
-    public function match(RequestInterface $request):?array {
142
+    public function match(RequestInterface $request): ?array {
143 143
         if (\in_array($request->getMethod(), $this->methods)) {
144 144
             if ($parameter = $this->matcher->match($request->getUrl())) {
145 145
                 return $this->matcher->buildParamter($parameter);
Please login to merge, or discard this patch.