Passed
Push — master ( 6668a8...516163 )
by 世昌
02:16
created
nebula/request/file/UploadedFile.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
 /**
8 8
  * HTTP请求文件
9 9
  */
10
-class UploadedFile  extends File  {
10
+class UploadedFile  extends File {
11 11
 
12 12
     private $originalName;
13 13
     private $mimeType;
Please login to merge, or discard this patch.
nebula/request/file/File.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 /**
6 6
  * HTTP请求文件
7 7
  */
8
-class File  extends \SplFileInfo  {
8
+class File  extends \SplFileInfo {
9 9
     /**
10 10
      * 创建文件
11 11
      *
Please login to merge, or discard this patch.
nebula/request/attribute/FormDataAttribute.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
      *
49 49
      * @return array|null
50 50
      */
51
-    public function json():?array {
51
+    public function json(): ?array {
52 52
         if (isset($this->json)) {
53 53
             return $this->json;
54 54
         }
55
-        $data =json_decode($this->input(), true, 512, JSON_BIGINT_AS_STRING);
56
-        if (json_last_error()!==JSON_ERROR_NONE) {
55
+        $data = json_decode($this->input(), true, 512, JSON_BIGINT_AS_STRING);
56
+        if (json_last_error() !== JSON_ERROR_NONE) {
57 57
             $this->json = null;
58 58
         }
59 59
         return $this->json = $data;
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      * @param mixed $default
67 67
      * @return mixed
68 68
      */
69
-    public function get(?string $name=null, $default =null)
69
+    public function get(?string $name = null, $default = null)
70 70
     {
71 71
         return $this->getParameter($name, $default);
72 72
     }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      * @param mixed $default
79 79
      * @return mixed 获取的值
80 80
      */
81
-    public static function post(?string $name=null, $default=null)
81
+    public static function post(?string $name = null, $default = null)
82 82
     {
83 83
         if (is_null($name)) {
84 84
             return $_POST;
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      * @param string|null $name
129 129
      * @return boolean
130 130
      */
131
-    public function hasGet(?string $name=null)
131
+    public function hasGet(?string $name = null)
132 132
     {
133 133
         $get = $this->getParameter();
134 134
         if (is_null($name)) {
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      *
158 158
      * @return boolean
159 159
      */
160
-    public function hasPost(?string $name=null)
160
+    public function hasPost(?string $name = null)
161 161
     {
162 162
         $post = $this->post();
163 163
         if ($name) {
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
      * @param mixed $default
181 181
      * @return mixed
182 182
      */
183
-    abstract public function getHeader(string $name, $default =null);
183
+    abstract public function getHeader(string $name, $default = null);
184 184
     /**
185 185
      * 获取请求参数
186 186
      *
Please login to merge, or discard this patch.
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/attribute/SchemeAttribute.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,9 +53,9 @@
 block discarded – undo
53 53
     }
54 54
 
55 55
     /**
56
-      * Get 服务器属性
57
-      *
58
-      * @return  array
59
-      */
56
+     * Get 服务器属性
57
+     *
58
+     * @return  array
59
+     */
60 60
     abstract public function getServer();
61 61
 }
Please login to merge, or discard this patch.
nebula/request/attribute/AttributeAbstract.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.
nebula/route/uri/parameter/Parameter.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 /**
5 5
  * 匹配参数
6 6
  */
7
-abstract class Parameter   {
7
+abstract class Parameter {
8 8
 
9 9
     protected static $name;
10 10
     /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     }
26 26
 
27 27
     public static function build(string $indexName, string $extra):Parameter {
28
-        $parameter =  new static($extra);
28
+        $parameter = new static($extra);
29 29
         $parameter->setIndexName($indexName);
30 30
         return $parameter;
31 31
     }
Please login to merge, or discard this patch.
nebula/route/uri/MatcherHelper.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,18 +26,18 @@  discard block
 block discarded – undo
26 26
         // 参数
27 27
         $parameters = [];
28 28
         // 转义正则
29
-        $url=preg_replace('/([\/\.\\\\\+\(\^\)\$\!\<\>\-\?\*])/', '\\\\$1', $uri);
29
+        $url = preg_replace('/([\/\.\\\\\+\(\^\)\$\!\<\>\-\?\*])/', '\\\\$1', $uri);
30 30
         // 添加忽略
31
-        $url=preg_replace('/(\[)([^\[\]]+)(?(1)\])/', '(?:$2)?', $url);
31
+        $url = preg_replace('/(\[)([^\[\]]+)(?(1)\])/', '(?:$2)?', $url);
32 32
         // 添加 * ? 匹配
33
-        $url=str_replace(['\*','\?'], ['[^/]*?','[^/]'], $url);
33
+        $url = str_replace(['\*', '\?'], ['[^/]*?', '[^/]'], $url);
34 34
         // 编译页面参数
35
-        $url=preg_replace_callback('/\{(\w+)(?:\:([^}]+?))?\}/', function ($match) use (&$parameters) {
35
+        $url = preg_replace_callback('/\{(\w+)(?:\:([^}]+?))?\}/', function($match) use (&$parameters) {
36 36
             $name = $match[1];
37 37
             $type = 'string';
38 38
             $extra = '';
39 39
             if (isset($match[2])) {
40
-                if (strpos($match[2], '=')!==false) {
40
+                if (strpos($match[2], '=') !== false) {
41 41
                     list($type, $extra) = \explode('=', $match[2]);
42 42
                 } else {
43 43
                     $type = $match[2];
@@ -56,16 +56,16 @@  discard block
 block discarded – undo
56 56
 
57 57
     public static function buildUri(UriMatcher $matcher, array $parameter, bool $allowQuery = true):string
58 58
     {
59
-        $uri =  $matcher->getUri();
59
+        $uri = $matcher->getUri();
60 60
         // 拆分参数
61 61
         list($mapper, $query) = static::analyseParameter($matcher, $parameter);
62 62
         // for * ?
63
-        $url=\str_replace(['*','?'], ['','-'], $uri);
63
+        $url = \str_replace(['*', '?'], ['', '-'], $uri);
64 64
         // for ignore value
65
-        $url=preg_replace_callback('/\[(.+?)\]/', function ($match) use ($matcher, $parameter, $mapper) {
65
+        $url = preg_replace_callback('/\[(.+?)\]/', function($match) use ($matcher, $parameter, $mapper) {
66 66
             if (preg_match('/\{(\w+).+?\}/', $match[1])) {
67 67
                 $count = 0;
68
-                $subUrl= static::replaceParameter($match[1], $matcher, $parameter, $mapper, $count);
68
+                $subUrl = static::replaceParameter($match[1], $matcher, $parameter, $mapper, $count);
69 69
                 if ($count > 0) {
70 70
                     return $subUrl;
71 71
                 }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
             return '';
74 74
         }, $url);
75 75
  
76
-        $url= static::replaceParameter($url, $matcher, $parameter, $mapper);
76
+        $url = static::replaceParameter($url, $matcher, $parameter, $mapper);
77 77
 
78 78
         if (count($query) && $allowQuery) {
79 79
             return $url.'?'.http_build_query($query, 'v', '&', PHP_QUERY_RFC3986);
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
         return [$mapper, $query];
98 98
     }
99 99
 
100
-    protected static function replaceParameter(string $input, UriMatcher $matcher, array $parameter, array $mapper, ?int &$count=null)
100
+    protected static function replaceParameter(string $input, UriMatcher $matcher, array $parameter, array $mapper, ?int &$count = null)
101 101
     {
102
-        return preg_replace_callback('/\{(\w+).+?\}/', function ($match) use ($matcher, $parameter, $mapper) {
102
+        return preg_replace_callback('/\{(\w+).+?\}/', function($match) use ($matcher, $parameter, $mapper) {
103 103
             if (\array_key_exists($match[1], $mapper)) {
104 104
                 return $mapper[$match[1]]->packValue($parameter[$match[1]]);
105 105
             }
Please login to merge, or discard this patch.
nebula/route/RouteCollection.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      *
24 24
      * @param RouteMatcher[] $collection
25 25
      */
26
-    public function __construct(array $collection=[])
26
+    public function __construct(array $collection = [])
27 27
     {
28 28
         $this->merge($collection);
29 29
     }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      * @param array $collection
35 35
      * @return void
36 36
      */
37
-    public function merge(array $collection=[])
37
+    public function merge(array $collection = [])
38 38
     {
39 39
         $this->collection = array_merge($this->collection, $collection);
40 40
     }
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      * @param string $name
58 58
      * @return RouteMatcher|null
59 59
      */
60
-    public function get(string $name):?RouteMatcher
60
+    public function get(string $name): ?RouteMatcher
61 61
     {
62 62
         return $this->collection[$name] ?? null;
63 63
     }
Please login to merge, or discard this patch.