Passed
Push — master ( 145b60...d8f516 )
by 世昌
01:51
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.
nebula/route/uri/UriMatcher.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
      * @param boolean $ignoreCase
47 47
      * @return array|null
48 48
      */
49
-    public function match(string $url, bool $ignoreCase = true):?array
49
+    public function match(string $url, bool $ignoreCase = true): ?array
50 50
     {
51
-        $match = '#^'. $this->match.'$#'. ($ignoreCase?'i':'');
51
+        $match = '#^'.$this->match.'$#'.($ignoreCase ? 'i' : '');
52 52
         $parameter = [];
53 53
         if (preg_match($match, $url, $parameter, PREG_UNMATCHED_AS_NULL) > 0) {
54 54
             return array_slice($parameter, 1);
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
             } else {
73 73
                 $value = $parameter->unpackValue($match);
74 74
             }
75
-            $parameters[$parameter->getIndexName()] =  $value;
75
+            $parameters[$parameter->getIndexName()] = $value;
76 76
         }
77 77
         return $parameters;
78 78
     }
79 79
 
80
-    public function getParameter(string $name):?Parameter
80
+    public function getParameter(string $name): ?Parameter
81 81
     {
82 82
         foreach ($this->parameter as $parameter) {
83 83
             if ($parameter->getIndexName() === $name) {
Please login to merge, or discard this patch.
nebula/autoload/Loader.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
      *
16 16
      * @var array
17 17
      */
18
-    protected static $namespace=[ __NAMESPACE__ ];
18
+    protected static $namespace = [__NAMESPACE__];
19 19
 
20 20
     /**
21 21
      * 包含路径
22 22
      *
23 23
      * @var array
24 24
      */
25
-    protected static $includePath=[];
25
+    protected static $includePath = [];
26 26
 
27 27
     /**
28 28
      * 将JAVA,路径分割转换为PHP分割符
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      */
33 33
     public static function realName(string $name):string
34 34
     {
35
-        return str_replace(['.','/'], '\\', $name);
35
+        return str_replace(['.', '/'], '\\', $name);
36 36
     }
37 37
 
38 38
     /**
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
      * @param string $name
42 42
      * @return string|null
43 43
      */
44
-    public static function realPath(string $name):?string
44
+    public static function realPath(string $name): ?string
45 45
     {
46 46
         $absulotePath = static::toAbsolutePath($name);
47
-        return file_exists($absulotePath)?$absulotePath:null;
47
+        return file_exists($absulotePath) ? $absulotePath : null;
48 48
     }
49 49
 
50 50
     public static function register()
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 
97 97
     protected static function getClassPathByAlias(string $includePath, string $className):string
98 98
     {
99
-        $namepath=static::formatSeparator($className);
100
-        $className=static::realName($className);
99
+        $namepath = static::formatSeparator($className);
100
+        $className = static::realName($className);
101 101
         foreach (static::$namespace as $namespace) {
102 102
             $path = $includePath.DIRECTORY_SEPARATOR.$namespace.DIRECTORY_SEPARATOR.$namepath.'.php';
103 103
             if ($path = static::realPath($path)) {
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
         } else {
119 119
             $nl = strlen($includeNamespace);
120 120
             if (substr(static::realName($className), 0, $nl) === $includeNamespace) {
121
-                $path=$includePath.DIRECTORY_SEPARATOR.static::formatSeparator(substr($className, $nl)).'.php';
121
+                $path = $includePath.DIRECTORY_SEPARATOR.static::formatSeparator(substr($className, $nl)).'.php';
122 122
             } else {
123
-                $path=$includePath.DIRECTORY_SEPARATOR.static::formatSeparator($className).'.php';
123
+                $path = $includePath.DIRECTORY_SEPARATOR.static::formatSeparator($className).'.php';
124 124
             }
125 125
         }
126 126
         if ($path = static::realPath($path)) {
@@ -129,16 +129,16 @@  discard block
 block discarded – undo
129 129
         return nulll;
130 130
     }
131 131
 
132
-    public static function addIncludePath(string $path, string $namespace=null)
132
+    public static function addIncludePath(string $path, string $namespace = null)
133 133
     {
134 134
         if ($path = static::realPath($path)) {
135 135
             $namespace = $namespace ?? 0;
136 136
             if (array_key_exists($namespace, static::$includePath)) {
137 137
                 if (!\in_array($path, static::$includePath[$namespace])) {
138
-                    static::$includePath[$namespace][]=$path;
138
+                    static::$includePath[$namespace][] = $path;
139 139
                 }
140 140
             } else {
141
-                static::$includePath[$namespace][]=$path;
141
+                static::$includePath[$namespace][] = $path;
142 142
             }
143 143
         }
144 144
     }
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
     public static function setNamespace(string $namespace)
157 157
     {
158 158
         if (!in_array($namespace, static::$namespace)) {
159
-            static::$namespace[]=$namespace;
159
+            static::$namespace[] = $namespace;
160 160
         }
161 161
     }
162 162
 }
Please login to merge, or discard this patch.
nebula/autoload/PathInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,5 +11,5 @@
 block discarded – undo
11 11
 
12 12
     public static function toAbsolutePath(string $path, string $separator = DIRECTORY_SEPARATOR):string;
13 13
 
14
-    public static function getHomePath():?string;
14
+    public static function getHomePath(): ?string;
15 15
 }
Please login to merge, or discard this patch.
nebula/autoload/PathTrait.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 {    
10 10
     public static function formatSeparator(string $path):string
11 11
     {
12
-        return str_replace(['\\','/'], DIRECTORY_SEPARATOR, $path);
12
+        return str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $path);
13 13
     }
14 14
 
15 15
     public static function toAbsolutePath(string $path, string $separator = DIRECTORY_SEPARATOR):string{
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
             $subpath = substr($subpath, 1);
31 31
         } else {
32 32
             if (strpos($subpath, ':/') === false) {
33
-                $subpath=str_replace(['/', '\\'], '/', getcwd()).'/'.$subpath;
33
+                $subpath = str_replace(['/', '\\'], '/', getcwd()).'/'.$subpath;
34 34
             }
35 35
             list($root, $subpath) = explode(':/', $subpath, 2);
36 36
             $root .= ':'.DIRECTORY_SEPARATOR;
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
             } elseif ($name === '.') {
48 48
                 continue;
49 49
             } elseif (strlen($name)) {
50
-                $absulotePaths[]=$name;
50
+                $absulotePaths[] = $name;
51 51
             }
52 52
         }
53 53
         return implode($separator, $absulotePaths);
@@ -56,20 +56,20 @@  discard block
 block discarded – undo
56 56
     protected static function parsePathSchemeSubpath(string $path):array
57 57
     {
58 58
         if (static::getHomePath() !== null && strpos($path, '~') === 0) {
59
-            $scheme ='';
60
-            $subpath = static::getHomePath() .DIRECTORY_SEPARATOR.substr($path, 1);
59
+            $scheme = '';
60
+            $subpath = static::getHomePath().DIRECTORY_SEPARATOR.substr($path, 1);
61 61
         } elseif (strpos($path, '://') !== false) {
62 62
             list($scheme, $subpath) = explode('://', $path, 2);
63
-            $scheme.='://';
63
+            $scheme .= '://';
64 64
         } else {
65
-            $scheme ='';
65
+            $scheme = '';
66 66
             $subpath = $path;
67 67
         }
68 68
         return [$scheme, $subpath];
69 69
     }
70 70
 
71 71
 
72
-    public static function getHomePath():?string {
72
+    public static function getHomePath(): ?string {
73 73
         return null;
74 74
     }
75 75
 }
Please login to merge, or discard this patch.