GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( ff2d37...e3959e )
by cao
03:01
created
src/DB/Rows.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,30 +2,30 @@
 block discarded – undo
2 2
 
3 3
 namespace PhpBoot\DB;
4 4
 
5
-if(!function_exists("array_column"))
5
+if (!function_exists("array_column"))
6 6
 {
7 7
 
8 8
     function array_column($array, $column_name)
9 9
     {
10 10
 
11
-        return array_map(function($element) use($column_name){return $element[$column_name];}, $array);
11
+        return array_map(function($element) use($column_name){return $element[$column_name]; }, $array);
12 12
 
13 13
     }
14 14
 
15 15
 }
16 16
 class Rows
17 17
 {
18
-    static function column($array,$column_name)
18
+    static function column($array, $column_name)
19 19
     {
20 20
 
21
-        return array_map(function($element) use($column_name){return $element[$column_name];}, $array);
21
+        return array_map(function($element) use($column_name){return $element[$column_name]; }, $array);
22 22
 
23 23
     }
24
-    static public function leftJoin(&$lh, $rh, $lKey, $rkey, $destKey){
25
-        $map = array_combine(self::column($rh,$rkey),$rh);
24
+    static public function leftJoin(&$lh, $rh, $lKey, $rkey, $destKey) {
25
+        $map = array_combine(self::column($rh, $rkey), $rh);
26 26
 
27
-        foreach ($lh as &$v){
28
-            $v[$destKey]=$map[$v[$lKey]];
27
+        foreach ($lh as &$v) {
28
+            $v[$destKey] = $map[$v[$lKey]];
29 29
         }
30 30
     }
31 31
 }
32 32
\ No newline at end of file
Please login to merge, or discard this patch.
src/DB/Raw.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@
 block discarded – undo
13 13
     function __construct($str) {
14 14
         $this->str = $str;
15 15
     }
16
-    public function __toString(){
16
+    public function __toString() {
17 17
         return $this->str;
18 18
     }
19
-    public function get(){
19
+    public function get() {
20 20
         return $this->str;
21 21
     }
22 22
     private $str;
Please login to merge, or discard this patch.
src/DB/rules/basic.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 class BasicRule
13 13
 {
14
-    public function __construct(Context $context){
14
+    public function __construct(Context $context) {
15 15
         $this->context = $context;
16 16
     }
17 17
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
 class OrderByRule extends LimitRule
50 50
 {
51
-    public function __construct($context){
51
+    public function __construct($context) {
52 52
         parent::__construct($context);
53 53
         $this->impl = new OrderByImpl();
54 54
     }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      * 
73 73
      * @return \PhpBoot\DB\rules\basic\LimitRule
74 74
      */
75
-    public function orderBy($column, $order=null) {
75
+    public function orderBy($column, $order = null) {
76 76
         $this->impl->orderBy($this->context, $column, $order);
77 77
         return new LimitRule($this->context);
78 78
     }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      * @param mixed $_
92 92
      * @return \PhpBoot\DB\rules\basic\OrderByRule
93 93
      */
94
-    public function where($expr, $_= null) {
94
+    public function where($expr, $_ = null) {
95 95
         WhereImpl::where($this->context, $expr, array_slice(func_get_args(), 1));
96 96
         return new OrderByRule($this->context);
97 97
     }
Please login to merge, or discard this patch.
src/RPC/MultiRequestCore.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
 
55 55
         $res =  array_pop($this->waitResults);
56 56
         if(isset($res[1])){
57
-             \PhpBoot\abort(new RpcException($res['reason']));
57
+                \PhpBoot\abort(new RpcException($res['reason']));
58 58
         }else{
59 59
             return $res[0];
60 60
         }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@  discard block
 block discarded – undo
13 13
      */
14 14
     public function __construct(array $threads, callable $waitAll)
15 15
     {
16
-        foreach ($threads as $thread){
16
+        foreach ($threads as $thread) {
17 17
             $pos = count($this->threadResults);
18
-            $this->threadResults[] = [null,null];
19
-            $this->threads[] = function ()use($thread, $pos){
20
-                try{
18
+            $this->threadResults[] = [null, null];
19
+            $this->threads[] = function()use($thread, $pos){
20
+                try {
21 21
                     $this->threadResults[$pos][0] = $thread();
22
-                }catch (\Exception $e){
22
+                }catch (\Exception $e) {
23 23
                     $this->threadResults[$pos][1] = $e;
24 24
                 }
25 25
             };
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 
30 30
     public function run()
31 31
     {
32
-        while ($thread = array_pop($this->threads)){
32
+        while ($thread = array_pop($this->threads)) {
33 33
             $thread();
34 34
         };
35 35
     }
@@ -42,20 +42,20 @@  discard block
 block discarded – undo
42 42
         return $this->threadResults;
43 43
     }
44 44
 
45
-    public function wait($waitAble){
45
+    public function wait($waitAble) {
46 46
         array_push($this->waits, $waitAble);
47 47
         $this->run();
48 48
 
49
-        if(count($this->waits)){
49
+        if (count($this->waits)) {
50 50
             $waitAll = $this->waitAll;
51 51
             $this->waitResults = $waitAll($this->waits);
52 52
             $this->waits = [];
53 53
         }
54 54
 
55
-        $res =  array_pop($this->waitResults);
56
-        if(isset($res[1])){
55
+        $res = array_pop($this->waitResults);
56
+        if (isset($res[1])) {
57 57
              \PhpBoot\abort(new RpcException($res['reason']));
58
-        }else{
58
+        }else {
59 59
             return $res[0];
60 60
         }
61 61
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
             $this->threads[] = function ()use($thread, $pos){
20 20
                 try{
21 21
                     $this->threadResults[$pos][0] = $thread();
22
-                }catch (\Exception $e){
22
+                } catch (\Exception $e){
23 23
                     $this->threadResults[$pos][1] = $e;
24 24
                 }
25 25
             };
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         $res =  array_pop($this->waitResults);
56 56
         if(isset($res[1])){
57 57
              \PhpBoot\abort(new RpcException($res['reason']));
58
-        }else{
58
+        } else{
59 59
             return $res[0];
60 60
         }
61 61
     }
Please login to merge, or discard this patch.
src/RPC/MultiRequest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
         return $request->getResults();
21 21
     }
22 22
 
23
-    public static function isRunning(){
23
+    public static function isRunning() {
24 24
         return !!self::$currentContext;
25 25
     }
26 26
 
Please login to merge, or discard this patch.
src/RPC/RpcProxy.php 2 patches
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
                                 ControllerContainerBuilder $builder,
34 34
                                 Client $http,
35 35
                                 $interface,
36
-                                $prefix='/')
36
+                                $prefix = '/')
37 37
     {
38 38
         $this->container = $builder->build($interface);
39 39
         $this->http = $http;
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
 
49 49
         $request = $this->createRequest($method, $route, $args);
50 50
 
51
-        if(MultiRpc::isRunning()){
51
+        if (MultiRpc::isRunning()) {
52 52
             $op = $this->http->sendAsync($request);
53 53
             $res = MultiRpc::wait($op);
54 54
             return $this->mapResponse($method, $route, $res, $args);
55
-        }else{
55
+        }else {
56 56
             $res = $this->http->send($request);
57 57
             return $this->mapResponse($method, $route, $res, $args);
58 58
         }
@@ -69,25 +69,25 @@  discard block
 block discarded – undo
69 69
         $params = $route->getRequestHandler()->getParamMetas();
70 70
         //TODO 支持 query、content、path以外的其他参数, 如cookie,path等
71 71
         $request = [];
72
-        foreach ($params as $pos=>$param){
73
-            if(!array_key_exists($pos, $args) && $param->isOptional){
72
+        foreach ($params as $pos=>$param) {
73
+            if (!array_key_exists($pos, $args) && $param->isOptional) {
74 74
                 $args[$pos] = $param->default;
75 75
             }
76 76
             array_key_exists($pos, $args) or \PhpBoot\abort(
77 77
                 $this->container->getClassName()." $actionName missing param {$param->name}");
78 78
 
79
-            if(!$param->isPassedByReference){
79
+            if (!$param->isPassedByReference) {
80 80
                 ArrayHelper::set($request, $param->source, $args[$pos]);
81 81
             }
82 82
         }
83 83
 
84
-        if(isset($request['request'])){
84
+        if (isset($request['request'])) {
85 85
             $request = $request['request'];
86 86
         }
87 87
         $uri = $route->getUri();
88
-        foreach($route->getPathParams() as $path){
89
-            if(isset($request[$path])){
90
-                $uri = str_replace('{'.$path.'}', urlencode($request[$path]) , $uri);
88
+        foreach ($route->getPathParams() as $path) {
89
+            if (isset($request[$path])) {
90
+                $uri = str_replace('{'.$path.'}', urlencode($request[$path]), $uri);
91 91
                 unset($request[$path]);
92 92
             }
93 93
         }
@@ -97,53 +97,53 @@  discard block
 block discarded – undo
97 97
         $body = null;
98 98
         $headers = [];
99 99
 
100
-        if(isset($request['query'])){
100
+        if (isset($request['query'])) {
101 101
             $query += $request['query'];
102 102
         }
103 103
         unset($request['query']);
104 104
 
105
-        if(isset($request['headers'])){
105
+        if (isset($request['headers'])) {
106 106
             $headers += $request['headers'];
107 107
         }
108 108
         unset($request['headers']);
109 109
 
110
-        if(isset($request['cookies'])){
110
+        if (isset($request['cookies'])) {
111 111
             $cookies = [];
112
-            foreach ($request['cookies'] as $k=>$v){
112
+            foreach ($request['cookies'] as $k=>$v) {
113 113
                 $cookies[] = "$k=$v";
114 114
             }
115 115
             $headers['Cookie'] = implode('; ', $cookies);
116 116
         }
117 117
         unset($request['cookies']);
118 118
 
119
-        if(isset($request['request'])){
120
-            if($body === null){
119
+        if (isset($request['request'])) {
120
+            if ($body === null) {
121 121
                 $body = [];
122 122
             }
123 123
             $body += $request['request'];
124 124
         }
125 125
         unset($request['request']);
126 126
 
127
-        if(isset($request['files'])){
127
+        if (isset($request['files'])) {
128 128
             \PhpBoot\abort(new \UnexpectedValueException("sending request with files is not support"));
129 129
         }
130
-        if(in_array($httpMethod, ['GET', 'OPTION'])){
131
-            foreach ($request as $k => $v){
132
-                if(!in_array($k, ['query', 'request', 'files', 'cookies', 'headers'])){
130
+        if (in_array($httpMethod, ['GET', 'OPTION'])) {
131
+            foreach ($request as $k => $v) {
132
+                if (!in_array($k, ['query', 'request', 'files', 'cookies', 'headers'])) {
133 133
                     $query[$k] = $v;
134 134
                 }
135 135
             }
136
-        }else{
137
-            foreach ($request as $k => $v){
138
-                if(!in_array($k, ['query', 'request', 'files', 'cookies', 'headers'])){
139
-                    if($body === null){
136
+        }else {
137
+            foreach ($request as $k => $v) {
138
+                if (!in_array($k, ['query', 'request', 'files', 'cookies', 'headers'])) {
139
+                    if ($body === null) {
140 140
                         $body = [];
141 141
                     }
142 142
                     $body[$k] = $v;
143 143
                 }
144 144
             }
145 145
         }
146
-        if($body !== null){
146
+        if ($body !== null) {
147 147
             $body = json_encode($body, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
148 148
         }
149 149
         $uri = $this->uriPrefix.ltrim($uri, '/').'?'.http_build_query($query);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
     }
157 157
 
158 158
 
159
-    public function mapResponse($actionName, Route $route, ResponseInterface $response, $requestArg=[])
159
+    public function mapResponse($actionName, Route $route, ResponseInterface $response, $requestArg = [])
160 160
     {
161 161
         $response = \Symfony\Component\HttpFoundation\Response::create(
162 162
             (string)$response->getBody(),
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
             );
166 166
         $namedArgs = [];
167 167
 
168
-        foreach ($route->getRequestHandler()->getParamMetas() as $pos=>$param){
168
+        foreach ($route->getRequestHandler()->getParamMetas() as $pos=>$param) {
169 169
 
170
-            if($param->isPassedByReference){
170
+            if ($param->isPassedByReference) {
171 171
                 $namedArgs[$param->name] = &$requestArg[$pos];
172 172
             }
173 173
         }
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         //TODO 远端接口没有抛出异常,但设置了 status( status 不是200)时如何处理
179 179
         $handler = $route->getResponseHandler();
180 180
 
181
-        if($response->getStatusCode() >= 200 && $response->getStatusCode() <300){
181
+        if ($response->getStatusCode()>=200 && $response->getStatusCode()<300) {
182 182
 
183 183
 
184 184
             $returns = $handler->getMappings();
@@ -195,30 +195,30 @@  discard block
 block discarded – undo
195 195
                 'params'=>$namedArgs
196 196
             ];
197 197
 
198
-            foreach ($returns as $map=>$return){
198
+            foreach ($returns as $map=>$return) {
199 199
 
200 200
                 $data = \JmesPath\search($map, $buffer);
201
-                if(!$return->container){
201
+                if (!$return->container) {
202 202
                     continue;
203 203
                 }
204 204
                 $data = $return->container->make($data, false);
205 205
                 ArrayHelper::set($mapping, $return->source, $data);
206 206
             }
207 207
 
208
-        }else{
208
+        }else {
209 209
 
210 210
             //TODO 如果多个 异常对应同一个 statusCode 怎么处理
211 211
             $exceptions = $route->getExceptionHandler()->getExceptions();
212 212
 
213 213
             $errName = null;
214
-            foreach ($exceptions as $err){
214
+            foreach ($exceptions as $err) {
215 215
 
216 216
                 $renderer = $this->app->get(ExceptionRenderer::class);
217 217
                 $exec = $renderer->render(
218 218
                     $this->app->make($err, ['message'=>(string)$response->getContent()])
219 219
                 );
220 220
 
221
-                if( $exec->getStatusCode() == $response->getStatusCode()){
221
+                if ($exec->getStatusCode() == $response->getStatusCode()) {
222 222
                     throw $exec;
223 223
                 }
224 224
             }
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 
227 227
         };
228 228
 
229
-        if(isset($mapping['return'])){
229
+        if (isset($mapping['return'])) {
230 230
             return $mapping['return'];
231 231
         };
232 232
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             $op = $this->http->sendAsync($request);
53 53
             $res = MultiRpc::wait($op);
54 54
             return $this->mapResponse($method, $route, $res, $args);
55
-        }else{
55
+        } else{
56 56
             $res = $this->http->send($request);
57 57
             return $this->mapResponse($method, $route, $res, $args);
58 58
         }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
                     $query[$k] = $v;
134 134
                 }
135 135
             }
136
-        }else{
136
+        } else{
137 137
             foreach ($request as $k => $v){
138 138
                 if(!in_array($k, ['query', 'request', 'files', 'cookies', 'headers'])){
139 139
                     if($body === null){
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
                 ArrayHelper::set($mapping, $return->source, $data);
206 206
             }
207 207
 
208
-        }else{
208
+        } else{
209 209
 
210 210
             //TODO 如果多个 异常对应同一个 statusCode 怎么处理
211 211
             $exceptions = $route->getExceptionHandler()->getExceptions();
Please login to merge, or discard this patch.
src/RPC/MultiRpc.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
          * ]
22 22
          *
23 23
          */
24
-        return MultiRequest::run($threads, function($promises){
24
+        return MultiRequest::run($threads, function($promises) {
25 25
             $res = [];
26
-            foreach (Promise\settle($promises)->wait() as $i){
27
-                if(isset($i['reason'])){
26
+            foreach (Promise\settle($promises)->wait() as $i) {
27
+                if (isset($i['reason'])) {
28 28
                     $res[] = [null, new RpcException($i['reason'])];
29
-                }else{
29
+                }else {
30 30
                     $res[] = [$i['value'], null];
31 31
                 }
32 32
             }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         });
35 35
     }
36 36
 
37
-    public static function isRunning(){
37
+    public static function isRunning() {
38 38
         return MultiRequest::isRunning();
39 39
     }
40 40
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
             foreach (Promise\settle($promises)->wait() as $i){
27 27
                 if(isset($i['reason'])){
28 28
                     $res[] = [null, new RpcException($i['reason'])];
29
-                }else{
29
+                } else{
30 30
                     $res[] = [$i['value'], null];
31 31
                 }
32 32
             }
Please login to merge, or discard this patch.
src/Docgen/Swagger/Swagger.php 5 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,6 @@  discard block
 block discarded – undo
8 8
 use PhpBoot\Docgen\Swagger\Schemas\ArraySchemaObject;
9 9
 use PhpBoot\Docgen\Swagger\Schemas\BodyParameterObject;
10 10
 use PhpBoot\Docgen\Swagger\Schemas\OperationObject;
11
-use PhpBoot\Docgen\Swagger\Schemas\OtherParameterObject;
12 11
 use PhpBoot\Docgen\Swagger\Schemas\PrimitiveSchemaObject;
13 12
 use PhpBoot\Docgen\Swagger\Schemas\RefSchemaObject;
14 13
 use PhpBoot\Docgen\Swagger\Schemas\ResponseObject;
@@ -22,7 +21,6 @@  discard block
 block discarded – undo
22 21
 use PhpBoot\Metas\ParamMeta;
23 22
 use PhpBoot\Metas\ReturnMeta;
24 23
 use PhpBoot\Utils\ArrayHelper;
25
-use PhpBoot\Validator\Validator;
26 24
 use Symfony\Component\HttpKernel\Exception\HttpException;
27 25
 
28 26
 class Swagger extends SwaggerObject
Please login to merge, or discard this patch.
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
      * @return RefSchemaObject
235 235
      */
236 236
     public function makeTempSchema(Application $app,
237
-                                   ControllerContainer $controller,
238
-                                   $action,
239
-                                   Route $route,
240
-                                   array $arr, $suffix)
237
+                                    ControllerContainer $controller,
238
+                                    $action,
239
+                                    Route $route,
240
+                                    array $arr, $suffix)
241 241
     {
242 242
         $className = self::getShortClassName($controller->getClassName());
243 243
         $name = $className . ucfirst($action) . $suffix;
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
      * @return RefSchemaObject
294 294
      */
295 295
     public function getRefSchema(Application $app,
296
-                                 ControllerContainer $controller,
297
-                                 $action,
298
-                                 Route $route,
299
-                                 EntityContainer $container)
296
+                                    ControllerContainer $controller,
297
+                                    $action,
298
+                                    Route $route,
299
+                                    EntityContainer $container)
300 300
     {
301 301
         $name = $container->getClassName();
302 302
         if (!isset($this->definitions[$name])) {
@@ -444,10 +444,10 @@  discard block
 block discarded – undo
444 444
      * @return ArraySchemaObject
445 445
      */
446 446
     public function getArraySchema(Application $app,
447
-                                   ControllerContainer $controller,
448
-                                   $action,
449
-                                   Route $route,
450
-                                   ArrayContainer $container)
447
+                                    ControllerContainer $controller,
448
+                                    $action,
449
+                                    Route $route,
450
+                                    ArrayContainer $container)
451 451
     {
452 452
         $schema = new ArraySchemaObject();
453 453
         $itemContainer = $container->getContainer();
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
     {
214 214
         if ($content instanceof ReturnMeta || $content instanceof ParamMeta) {
215 215
             return $this->makeExample($content->container);
216
-        }elseif ($content instanceof TypeContainerInterface){
216
+        } elseif ($content instanceof TypeContainerInterface){
217 217
             return $content->makeExample();
218
-        }elseif(is_array($content)) {
218
+        } elseif(is_array($content)) {
219 219
             $res = [];
220 220
             foreach ($content as $k => $v) {
221 221
                 $res[$k] = $this->makeExample($v);
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
                     $paramSchema = new PrimitiveSchemaObject();
371 371
                     if($isFile){
372 372
                         $paramSchema->type = 'file';
373
-                    }else{
373
+                    } else{
374 374
                         $paramSchema->type = self::mapType($param->type);
375 375
                         self::mapValidation($param->validation, $paramSchema);
376 376
                     }
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
         } elseif($container == null){
429 429
             $schema = null ;//new PrimitiveSchemaObject();
430 430
             //$schema->type = null;
431
-        }else {
431
+        } else {
432 432
             $schema = new PrimitiveSchemaObject();
433 433
             //$schema->type = 'mixed';
434 434
         }
Please login to merge, or discard this patch.
Doc Comments   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     }
94 94
 
95 95
     /**
96
-     * @param $object
96
+     * @param Swagger $object
97 97
      * @return array
98 98
      */
99 99
     static public function objectToArray($object)
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     /**
119 119
      * @param Application $app
120 120
      * @param ControllerContainer $controller
121
-     * @param $action
121
+     * @param integer $action
122 122
      * @param Route $route
123 123
      * @return array
124 124
      */
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
     /**
168 168
      * @param Application $app
169 169
      * @param ControllerContainer $controller
170
-     * @param $action
170
+     * @param integer $action
171 171
      * @param Route $route
172 172
      * @return null|ResponseObject
173 173
      */
@@ -305,6 +305,9 @@  discard block
 block discarded – undo
305 305
         return new RefSchemaObject("#/definitions/$name");
306 306
     }
307 307
 
308
+    /**
309
+     * @param integer $action
310
+     */
308 311
     public function getParamsSchema(Application $app,
309 312
                                     ControllerContainer $controller,
310 313
                                     $action,
@@ -577,6 +580,9 @@  discard block
 block discarded – undo
577 580
         return $className;
578 581
     }
579 582
 
583
+    /**
584
+     * @param string $glue
585
+     */
580 586
     static public function implode($glue , array $pieces )
581 587
     {
582 588
         $pieces = array_filter($pieces, function($i){return trim($i) !== '';});
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
             $op->description = $route->getDescription();
59 59
 
60 60
             $op->parameters = $this->getParamsSchema($app, $controller, $action, $route);
61
-            if($this->hasFileParam($route)){
61
+            if ($this->hasFileParam($route)) {
62 62
                 $op->consumes = ['multipart/form-data'];
63 63
             }
64 64
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
             }
109 109
             if (is_array($v) || is_object($v)) {
110 110
                 $res[$k] = self::objectToArray($v);
111
-            } else {
111
+            }else {
112 112
                 $res[$k] = $v;
113 113
             }
114 114
         }
@@ -140,21 +140,21 @@  discard block
 block discarded – undo
140 140
             //TODO status 重复怎么办
141 141
             if ($ins instanceof HttpException) {
142 142
                 $status = $ins->getStatusCode();
143
-            } else {
143
+            }else {
144 144
 
145 145
                 $status = 500;
146 146
             }
147 147
             if (isset($schemas[$status])) {
148 148
                 //$this->warnings[] = "status response $status has been used for $name, $desc";
149 149
                 $res = $schemas[$status];
150
-            } else {
150
+            }else {
151 151
                 $res = new ResponseObject();
152 152
             }
153 153
             $shortName = self::getShortClassName($name);
154 154
             $desc = "$shortName: $desc";
155 155
             $res->description = self::implode("\n", [$res->description, $desc]);
156 156
             $error = $app->get(ExceptionRenderer::class)->render($ins)->getContent();
157
-            if($error){
157
+            if ($error) {
158 158
                 $res->examples = [$shortName => $error];
159 159
             }
160 160
             //$res->schema = new RefSchemaObject("#/definitions/$name");
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
     {
214 214
         if ($content instanceof ReturnMeta || $content instanceof ParamMeta) {
215 215
             return $this->makeExample($content->container);
216
-        }elseif ($content instanceof TypeContainerInterface){
216
+        }elseif ($content instanceof TypeContainerInterface) {
217 217
             return $content->makeExample();
218
-        }elseif(is_array($content)) {
218
+        }elseif (is_array($content)) {
219 219
             $res = [];
220 220
             foreach ($content as $k => $v) {
221 221
                 $res[$k] = $this->makeExample($v);
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
                                    array $arr, $suffix)
241 241
     {
242 242
         $className = self::getShortClassName($controller->getClassName());
243
-        $name = $className . ucfirst($action) . $suffix;
243
+        $name = $className.ucfirst($action).$suffix;
244 244
 
245 245
         $schema = new SimpleModelSchemaObject();
246 246
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
                 } elseif ($v->container instanceof EntityContainer) {
259 259
                     $sub = $this->getRefSchema($app, $controller, $action, $route, $v->container);
260 260
                     //TODO array for validation
261
-                } else {
261
+                }else {
262 262
                     $sub = new PrimitiveSchemaObject();
263 263
                     $sub->type = self::mapType($v->type);
264 264
                     self::mapValidation($v->validation, $sub);
@@ -270,14 +270,14 @@  discard block
 block discarded – undo
270 270
                     $schema->required[] = $k;
271 271
                 }
272 272
                 $schema->properties[$k] = $sub;
273
-            } else {
273
+            }else {
274 274
                 //TODO how to do?
275 275
             }
276 276
         }
277 277
         $unused = $name;
278 278
         $tempId = 0;
279 279
         while (isset($this->definitions[$unused])) {
280
-            $unused = $name . $tempId;
280
+            $unused = $name.$tempId;
281 281
             $tempId++;
282 282
         }
283 283
         $this->definitions[$unused] = $schema;
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
         $in = 'query';
317 317
 
318 318
         $bodyType = 'body'; // 当有文件上传时, 必须是formData方式
319
-        if($this->hasFileParam($route)){
319
+        if ($this->hasFileParam($route)) {
320 320
             $bodyType = 'formData';
321 321
         }
322 322
 
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
                     || $route->getMethod() == 'PATCH'
356 356
                 ) {
357 357
                     $in = $bodyType;
358
-                } else {
358
+                }else {
359 359
                     $in = 'query';
360 360
                 }
361 361
             }
@@ -366,11 +366,11 @@  discard block
 block discarded – undo
366 366
                 } elseif ($param->container instanceof EntityContainer) {
367 367
                     $paramSchema = $this->getRefSchema($app, $controller, $action, $route, $param->container);
368 368
                     //TODO array for validation
369
-                } else {
369
+                }else {
370 370
                     $paramSchema = new PrimitiveSchemaObject();
371
-                    if($isFile){
371
+                    if ($isFile) {
372 372
                         $paramSchema->type = 'file';
373
-                    }else{
373
+                    }else {
374 374
                         $paramSchema->type = self::mapType($param->type);
375 375
                         self::mapValidation($param->validation, $paramSchema);
376 376
                     }
@@ -382,10 +382,10 @@  discard block
 block discarded – undo
382 382
                 $paramSchema->default = $param->default;
383 383
                 $paramSchema->required = !$param->isOptional;
384 384
                 $parameters[] = $paramSchema;
385
-            } else {
385
+            }else {
386 386
                 if (!$name) {
387 387
                     $body = $param;
388
-                } else {
388
+                }else {
389 389
                     ArrayHelper::set($body, $name, $param);
390 390
                 }
391 391
 
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
             $paramSchema->in = 'body';
399 399
             if (is_array($body)) {
400 400
                 $paramSchema->schema = $this->makeTempSchema($app, $controller, $action, $route, $body, 'Req');
401
-            } else {
401
+            }else {
402 402
                 $paramSchema->schema = $this->getAnySchema($app, $controller, $action, $route, $body->container);
403 403
             }
404 404
 
@@ -425,8 +425,8 @@  discard block
 block discarded – undo
425 425
         } elseif ($container instanceof ScalarTypeContainer) {
426 426
             $schema = new PrimitiveSchemaObject();
427 427
             $schema->type = self::mapType($container->getType());
428
-        } elseif($container == null){
429
-            $schema = null ;//new PrimitiveSchemaObject();
428
+        } elseif ($container == null) {
429
+            $schema = null; //new PrimitiveSchemaObject();
430 430
             //$schema->type = null;
431 431
         }else {
432 432
             $schema = new PrimitiveSchemaObject();
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
         } elseif ($itemContainer instanceof ScalarTypeContainer) {
459 459
             $itemSchema = new PrimitiveSchemaObject();
460 460
             $itemSchema->type = self::mapType($itemContainer->getType());
461
-        } else {
461
+        }else {
462 462
             $itemSchema = new PrimitiveSchemaObject();
463 463
             //$itemSchema->type = 'mixed';
464 464
         }
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
                 $propertySchema = $this->getRefSchema($app, $controller, $action, $route, $property->container);
485 485
             } elseif ($property->container instanceof ArrayContainer) {
486 486
                 $propertySchema = $this->getArraySchema($app, $controller, $action, $route, $property->container);
487
-            } else {
487
+            }else {
488 488
                 $propertySchema = new PrimitiveSchemaObject();
489 489
                 $propertySchema->type = self::mapType($property->type);
490 490
                 $propertySchema->description = self::implode("\n", [$property->summary, $property->description]);
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
     {
502 502
         $params = $route->getRequestHandler()->getParamMetas();
503 503
         foreach ($params as $name => $param) {
504
-            if(strpos($param->source, 'request.files.')===0){
504
+            if (strpos($param->source, 'request.files.') === 0) {
505 505
                 return true;
506 506
             }
507 507
         }
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
      */
515 515
     static public function mapValidation($v, PrimitiveSchemaObject $schemaObject)
516 516
     {
517
-        if(!$v){
517
+        if (!$v) {
518 518
             return $schemaObject;
519 519
         }
520 520
         $rules = explode('|', $v);
@@ -530,15 +530,15 @@  discard block
 block discarded – undo
530 530
             } elseif ($rule == 'lengthBetween' && isset($params[0]) && isset($params[1])) {
531 531
                 $schemaObject->minLength = intval($params[0]);
532 532
                 $schemaObject->maxLength = intval($params[1]);
533
-            } elseif ($rule == 'lengthMin'&& isset($params[0])) {
533
+            } elseif ($rule == 'lengthMin' && isset($params[0])) {
534 534
                 $schemaObject->minLength = intval($params[0]);
535
-            } elseif ($rule == 'lengthMax'&& isset($params[0])) {
535
+            } elseif ($rule == 'lengthMax' && isset($params[0])) {
536 536
                 $schemaObject->maxLength = intval($params[0]);
537
-            } elseif ($rule == 'min'&& isset($params[0])) {
537
+            } elseif ($rule == 'min' && isset($params[0])) {
538 538
                 $schemaObject->minimum = floatval($params[0]);
539
-            } elseif ($rule == 'max'&& isset($params[0])) {
539
+            } elseif ($rule == 'max' && isset($params[0])) {
540 540
                 $schemaObject->maximum = floatval($params[0]);
541
-            } elseif ($rule == 'regex'&& isset($params[0])) {
541
+            } elseif ($rule == 'regex' && isset($params[0])) {
542 542
                 $schemaObject->pattern = $params[0];
543 543
             } elseif ($rule == 'optional') {
544 544
                 $schemaObject->required = false;
@@ -577,9 +577,9 @@  discard block
 block discarded – undo
577 577
         return $className;
578 578
     }
579 579
 
580
-    static public function implode($glue , array $pieces )
580
+    static public function implode($glue, array $pieces)
581 581
     {
582
-        $pieces = array_filter($pieces, function($i){return trim($i) !== '';});
582
+        $pieces = array_filter($pieces, function($i) {return trim($i) !== ''; });
583 583
         return implode($glue, $pieces);
584 584
     }
585 585
 }
586 586
\ No newline at end of file
Please login to merge, or discard this patch.
src/Controller/ResponseRenderer.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,19 +15,19 @@
 block discarded – undo
15 15
     {
16 16
         $response = new Response();
17 17
         $response->headers->set('Content-Type', 'application/json');
18
-        foreach ($output as $key=>$value){
18
+        foreach ($output as $key=>$value) {
19 19
             //TODO 支持自定义格式输出
20 20
             //TODO 支持更多的输出目标
21
-            if($key == 'content'){
21
+            if ($key == 'content') {
22 22
                 //if(is_array($value) || is_object($value)){
23 23
                     $value = json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
24 24
                 //}
25 25
                 $response->setContent($value);
26
-            }elseif($key == 'headers'){
27
-                foreach ($value as $k=>$v){
26
+            }elseif ($key == 'headers') {
27
+                foreach ($value as $k=>$v) {
28 28
                     $response->headers->set($k, $v);
29 29
                 }
30
-            }else{
30
+            }else {
31 31
                 \PhpBoot\abort(new \UnexpectedValueException("Unexpected output target $key"));
32 32
             }
33 33
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@
 block discarded – undo
23 23
                     $value = json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
24 24
                 //}
25 25
                 $response->setContent($value);
26
-            }elseif($key == 'headers'){
26
+            } elseif($key == 'headers'){
27 27
                 foreach ($value as $k=>$v){
28 28
                     $response->headers->set($k, $v);
29 29
                 }
30
-            }else{
30
+            } else{
31 31
                 \PhpBoot\abort(new \UnexpectedValueException("Unexpected output target $key"));
32 32
             }
33 33
 
Please login to merge, or discard this patch.