Passed
Push — master ( 13d26f...cd746f )
by 世昌
02:18
created
public/dev.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 use nebula\request\Request;
6 6
 
7
-require_once __DIR__ .'/../vendor/autoload.php';
7
+require_once __DIR__.'/../vendor/autoload.php';
8 8
 
9 9
 $request = Request::buildFromServer();
10 10
 $request->apply(true);
@@ -12,13 +12,13 @@  discard block
 block discarded – undo
12 12
 var_dump($request);
13 13
 var_dump($request->getBasicURI());
14 14
 
15
-function formatBytes(int $bytes, int $precision=0)
15
+function formatBytes(int $bytes, int $precision = 0)
16 16
 {
17
-    $human= ['B', 'KB', 'MB', 'GB', 'TB'];
17
+    $human = ['B', 'KB', 'MB', 'GB', 'TB'];
18 18
     $bytes = max($bytes, 0);
19
-    $pow = floor(($bytes?log($bytes):0)/log(1024));
20
-    $pos = min($pow, count($human)-1);
21
-    $bytes /= (1 << (10* $pos));
19
+    $pow = floor(($bytes ?log($bytes) : 0) / log(1024));
20
+    $pos = min($pow, count($human) - 1);
21
+    $bytes /= (1 << (10 * $pos));
22 22
     return round($bytes, $precision).' '.$human[$pos];
23 23
 }
24 24
 
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
         if (array_key_exists(strtolower($name), $this->headers)) {
71 71
             return $this->headers[$name];
72 72
         }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      */
91 91
     public function ip()
92 92
     {
93
-        static $ipFrom = ['HTTP_CLIENT_IP','HTTP_X_FORWARDED_FOR','HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP','HTTP_FORWARDED_FOR','HTTP_FORWARDED','REMOTE_ADDR'];
93
+        static $ipFrom = ['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR'];
94 94
         foreach ($ipFrom as $key) {
95 95
             if (array_key_exists($key, $_SERVER)) {
96 96
                 foreach (explode(',', $_SERVER[$key]) as $ip) {
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
         }
118 118
         $method = strtoupper($server['REQUEST_METHOD'] ?? 'GET');
119 119
         $uri = $server['REQUEST_URI']??'/';
120
-        $headers  = HeaderItem::buildFromServer($server);
121
-        $request =  new Request($method, $uri, $headers);
120
+        $headers = HeaderItem::buildFromServer($server);
121
+        $request = new Request($method, $uri, $headers);
122 122
         $request->setDocumentRoot($server['DOCUMENT_ROOT']);
123 123
         if ($simulate) {
124 124
             $request->setServer($server);
Please login to merge, or discard this patch.
nebula/request/attribute/SchemeAttribute.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -7,52 +7,52 @@
 block discarded – undo
7 7
  */
8 8
 trait SchemeAttribute
9 9
 {
10
-   protected $host;
11
-   protected $port;
12
-   protected $scheme;
10
+    protected $host;
11
+    protected $port;
12
+    protected $scheme;
13 13
 
14
-   public  function getScheme()
15
-   {
16
-      $server = $this->getServer();
17
-       if (!isset($this->scheme)) {
18
-           if (array_key_exists('HTTPS',  $server) && strcasecmp($server['HTTPS'], 'off') != 0) {
19
-               $scheme = 'https';
20
-           } elseif (array_key_exists('REQUEST_SCHEME', $server)) {
21
-               $scheme = $server['REQUEST_SCHEME'];
22
-           } else {
23
-               $scheme = 'http';
24
-           }
25
-       }
26
-       return  $this->scheme = $scheme;
27
-   }
14
+    public  function getScheme()
15
+    {
16
+        $server = $this->getServer();
17
+        if (!isset($this->scheme)) {
18
+            if (array_key_exists('HTTPS',  $server) && strcasecmp($server['HTTPS'], 'off') != 0) {
19
+                $scheme = 'https';
20
+            } elseif (array_key_exists('REQUEST_SCHEME', $server)) {
21
+                $scheme = $server['REQUEST_SCHEME'];
22
+            } else {
23
+                $scheme = 'http';
24
+            }
25
+        }
26
+        return  $this->scheme = $scheme;
27
+    }
28 28
    
29
-   public  function getHost()
30
-   {
31
-      if (isset($this->host)) {
32
-         return $this->host;
33
-      }
34
-      return $this->host = $this->getServer()['HTTP_HOST'] ?? 'localhost';
35
-   }
29
+    public  function getHost()
30
+    {
31
+        if (isset($this->host)) {
32
+            return $this->host;
33
+        }
34
+        return $this->host = $this->getServer()['HTTP_HOST'] ?? 'localhost';
35
+    }
36 36
 
37
-   public  function getPort()
38
-   {
39
-      if (isset($this->port)) {
40
-         return $this->port;
41
-      }
42
-      return $this->port = $this->getServer()['SERVER_PORT'] ?? 80;
43
-   }
37
+    public  function getPort()
38
+    {
39
+        if (isset($this->port)) {
40
+            return $this->port;
41
+        }
42
+        return $this->port = $this->getServer()['SERVER_PORT'] ?? 80;
43
+    }
44 44
 
45
-   /**
46
-    * 获取服务器基础URI
47
-    *
48
-    * @return string
49
-    */
50
-   public  function getServerURI()
51
-   {
52
-       return $this->getScheme().'://'.$this->getHost();
53
-   }
45
+    /**
46
+     * 获取服务器基础URI
47
+     *
48
+     * @return string
49
+     */
50
+    public  function getServerURI()
51
+    {
52
+        return $this->getScheme().'://'.$this->getHost();
53
+    }
54 54
 
55
-   /**
55
+    /**
56 56
      * Get 服务器属性
57 57
      *
58 58
      * @return  array
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
    {
16 16
       $server = $this->getServer();
17 17
        if (!isset($this->scheme)) {
18
-           if (array_key_exists('HTTPS',  $server) && strcasecmp($server['HTTPS'], 'off') != 0) {
18
+           if (array_key_exists('HTTPS', $server) && strcasecmp($server['HTTPS'], 'off') != 0) {
19 19
                $scheme = 'https';
20 20
            } elseif (array_key_exists('REQUEST_SCHEME', $server)) {
21 21
                $scheme = $server['REQUEST_SCHEME'];
Please login to merge, or discard this patch.
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.