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.
Completed
Push — master ( db4c43...dccf06 )
by cao
07:01
created
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.
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.
Braces   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -138,10 +138,10 @@  discard block
 block discarded – undo
138 138
             $ins = null;
139 139
             try{
140 140
                 $ins = $app->make($name);
141
-            }catch (\Exception $e){
141
+            } catch (\Exception $e){
142 142
                 try{
143 143
                     $ins = new $name("");
144
-                }catch (\Exception $e){
144
+                } catch (\Exception $e){
145 145
 
146 146
                 }
147 147
             }
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
     {
224 224
         if ($content instanceof ReturnMeta || $content instanceof ParamMeta) {
225 225
             return $this->makeExample($content->container);
226
-        }elseif ($content instanceof TypeContainerInterface){
226
+        } elseif ($content instanceof TypeContainerInterface){
227 227
             return $content->makeExample();
228
-        }elseif(is_array($content)) {
228
+        } elseif(is_array($content)) {
229 229
             $res = [];
230 230
             foreach ($content as $k => $v) {
231 231
                 $res[$k] = $this->makeExample($v);
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
                     $paramSchema = new PrimitiveSchemaObject();
385 385
                     if($isFile){
386 386
                         $paramSchema->type = 'file';
387
-                    }else{
387
+                    } else{
388 388
                         $paramSchema->type = self::mapType($param->type);
389 389
                         self::mapValidation($param->validation, $paramSchema);
390 390
                     }
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
         } elseif($container == null){
443 443
             $schema = null ;//new PrimitiveSchemaObject();
444 444
             //$schema->type = null;
445
-        }else {
445
+        } else {
446 446
             $schema = new PrimitiveSchemaObject();
447 447
             //$schema->type = 'mixed';
448 448
         }
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 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
         }
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
             list($name, $desc) = $exception;
137 137
 
138 138
             $ins = null;
139
-            try{
139
+            try {
140 140
                 $ins = $app->make($name);
141
-            }catch (\Exception $e){
142
-                try{
141
+            }catch (\Exception $e) {
142
+                try {
143 143
                     $ins = new $name("");
144
-                }catch (\Exception $e){
144
+                }catch (\Exception $e) {
145 145
 
146 146
                 }
147 147
             }
@@ -149,21 +149,21 @@  discard block
 block discarded – undo
149 149
             //TODO status 重复怎么办
150 150
             if ($ins instanceof HttpException) {
151 151
                 $status = $ins->getStatusCode();
152
-            } else {
152
+            }else {
153 153
                 $status = 500;
154 154
             }
155 155
             if (isset($schemas[$status])) {
156 156
                 //$this->warnings[] = "status response $status has been used for $name, $desc";
157 157
                 $res = $schemas[$status];
158
-            } else {
158
+            }else {
159 159
                 $res = new ResponseObject();
160 160
             }
161 161
             $shortName = self::getShortClassName($name);
162 162
             $desc = "$shortName: $desc";
163 163
             $res->description = self::implode("\n", [$res->description, $desc]);
164
-            if($ins){
164
+            if ($ins) {
165 165
                 $error = $app->get(ExceptionRenderer::class)->render($ins)->getContent();
166
-                if($error){
166
+                if ($error) {
167 167
                     $res->examples = [$shortName => $error];
168 168
                 }
169 169
             }
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
     {
224 224
         if ($content instanceof ReturnMeta || $content instanceof ParamMeta) {
225 225
             return $this->makeExample($content->container);
226
-        }elseif ($content instanceof TypeContainerInterface){
226
+        }elseif ($content instanceof TypeContainerInterface) {
227 227
             return $content->makeExample();
228
-        }elseif(is_array($content)) {
228
+        }elseif (is_array($content)) {
229 229
             $res = [];
230 230
             foreach ($content as $k => $v) {
231 231
                 $res[$k] = $this->makeExample($v);
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
                                    array $arr, $suffix)
251 251
     {
252 252
         $className = self::getShortClassName($controller->getClassName());
253
-        $name = $className . ucfirst($action) . $suffix;
253
+        $name = $className.ucfirst($action).$suffix;
254 254
 
255 255
         $schema = new SimpleModelSchemaObject();
256 256
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
                 $schema->properties[$k] = $this->makeTempSchema($app, $controller, $action, $route, $v, $suffix);
260 260
             } elseif ($v instanceof ReturnMeta) {
261 261
                 $sub = $this->getAnySchema($app, $controller, $action, $route, $v->container);
262
-                if($sub){
262
+                if ($sub) {
263 263
                     $sub->description = $v->description;
264 264
                 }
265 265
                 $schema->properties[$k] = $sub;
@@ -270,13 +270,13 @@  discard block
 block discarded – undo
270 270
                 } elseif ($v->container instanceof EntityContainer) {
271 271
                     $sub = $this->getRefSchema($app, $controller, $action, $route, $v->container);
272 272
                     //TODO array for validation
273
-                } else {
273
+                }else {
274 274
                     $sub = new PrimitiveSchemaObject();
275 275
                     $sub->type = self::mapType($v->type);
276 276
                     self::mapValidation($v->validation, $sub);
277 277
                     unset($sub->required);
278 278
                 }
279
-                if($sub){
279
+                if ($sub) {
280 280
                     $sub->description = $v->description;
281 281
                     $sub->default = $v->default;
282 282
                 }
@@ -284,14 +284,14 @@  discard block
 block discarded – undo
284 284
                     $schema->required[] = $k;
285 285
                 }
286 286
                 $schema->properties[$k] = $sub;
287
-            } else {
287
+            }else {
288 288
                 //TODO how to do?
289 289
             }
290 290
         }
291 291
         $unused = $name;
292 292
         $tempId = 0;
293 293
         while (isset($this->definitions[$unused])) {
294
-            $unused = $name . $tempId;
294
+            $unused = $name.$tempId;
295 295
             $tempId++;
296 296
         }
297 297
         $this->definitions[$unused] = $schema;
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
         $in = 'query';
331 331
 
332 332
         $bodyType = 'body'; // 当有文件上传时, 必须是formData方式
333
-        if($this->hasFileParam($route)){
333
+        if ($this->hasFileParam($route)) {
334 334
             $bodyType = 'formData';
335 335
         }
336 336
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
                     || $route->getMethod() == 'PATCH'
370 370
                 ) {
371 371
                     $in = $bodyType;
372
-                } else {
372
+                }else {
373 373
                     $in = 'query';
374 374
                 }
375 375
             }
@@ -380,11 +380,11 @@  discard block
 block discarded – undo
380 380
                 } elseif ($param->container instanceof EntityContainer) {
381 381
                     $paramSchema = $this->getRefSchema($app, $controller, $action, $route, $param->container);
382 382
                     //TODO array for validation
383
-                } else {
383
+                }else {
384 384
                     $paramSchema = new PrimitiveSchemaObject();
385
-                    if($isFile){
385
+                    if ($isFile) {
386 386
                         $paramSchema->type = 'file';
387
-                    }else{
387
+                    }else {
388 388
                         $paramSchema->type = self::mapType($param->type);
389 389
                         self::mapValidation($param->validation, $paramSchema);
390 390
                     }
@@ -396,10 +396,10 @@  discard block
 block discarded – undo
396 396
                 $paramSchema->default = $param->default;
397 397
                 $paramSchema->required = !$param->isOptional;
398 398
                 $parameters[] = $paramSchema;
399
-            } else {
399
+            }else {
400 400
                 if (!$name) {
401 401
                     $body = $param;
402
-                } else {
402
+                }else {
403 403
                     ArrayHelper::set($body, $name, $param);
404 404
                 }
405 405
 
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
             $paramSchema->in = 'body';
413 413
             if (is_array($body)) {
414 414
                 $paramSchema->schema = $this->makeTempSchema($app, $controller, $action, $route, $body, 'Req');
415
-            } else {
415
+            }else {
416 416
                 $paramSchema->schema = $this->getAnySchema($app, $controller, $action, $route, $body->container);
417 417
             }
418 418
 
@@ -439,8 +439,8 @@  discard block
 block discarded – undo
439 439
         } elseif ($container instanceof ScalarTypeContainer) {
440 440
             $schema = new PrimitiveSchemaObject();
441 441
             $schema->type = self::mapType($container->getType());
442
-        } elseif($container == null){
443
-            $schema = null ;//new PrimitiveSchemaObject();
442
+        } elseif ($container == null) {
443
+            $schema = null; //new PrimitiveSchemaObject();
444 444
             //$schema->type = null;
445 445
         }else {
446 446
             $schema = new PrimitiveSchemaObject();
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
         } elseif ($itemContainer instanceof ScalarTypeContainer) {
473 473
             $itemSchema = new PrimitiveSchemaObject();
474 474
             $itemSchema->type = self::mapType($itemContainer->getType());
475
-        } else {
475
+        }else {
476 476
             $itemSchema = new PrimitiveSchemaObject();
477 477
             //$itemSchema->type = 'mixed';
478 478
         }
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
                 $propertySchema = $this->getRefSchema($app, $controller, $action, $route, $property->container);
499 499
             } elseif ($property->container instanceof ArrayContainer) {
500 500
                 $propertySchema = $this->getArraySchema($app, $controller, $action, $route, $property->container);
501
-            } else {
501
+            }else {
502 502
                 $propertySchema = new PrimitiveSchemaObject();
503 503
                 $propertySchema->type = self::mapType($property->type);
504 504
                 $propertySchema->description = self::implode("\n", [$property->summary, $property->description]);
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
     {
516 516
         $params = $route->getRequestHandler()->getParamMetas();
517 517
         foreach ($params as $name => $param) {
518
-            if(strpos($param->source, 'request.files.')===0){
518
+            if (strpos($param->source, 'request.files.') === 0) {
519 519
                 return true;
520 520
             }
521 521
         }
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
      */
529 529
     static public function mapValidation($v, PrimitiveSchemaObject $schemaObject)
530 530
     {
531
-        if(!$v){
531
+        if (!$v) {
532 532
             return $schemaObject;
533 533
         }
534 534
         $rules = explode('|', $v);
@@ -544,15 +544,15 @@  discard block
 block discarded – undo
544 544
             } elseif ($rule == 'lengthBetween' && isset($params[0]) && isset($params[1])) {
545 545
                 $schemaObject->minLength = intval($params[0]);
546 546
                 $schemaObject->maxLength = intval($params[1]);
547
-            } elseif ($rule == 'lengthMin'&& isset($params[0])) {
547
+            } elseif ($rule == 'lengthMin' && isset($params[0])) {
548 548
                 $schemaObject->minLength = intval($params[0]);
549
-            } elseif ($rule == 'lengthMax'&& isset($params[0])) {
549
+            } elseif ($rule == 'lengthMax' && isset($params[0])) {
550 550
                 $schemaObject->maxLength = intval($params[0]);
551
-            } elseif ($rule == 'min'&& isset($params[0])) {
551
+            } elseif ($rule == 'min' && isset($params[0])) {
552 552
                 $schemaObject->minimum = floatval($params[0]);
553
-            } elseif ($rule == 'max'&& isset($params[0])) {
553
+            } elseif ($rule == 'max' && isset($params[0])) {
554 554
                 $schemaObject->maximum = floatval($params[0]);
555
-            } elseif ($rule == 'regex'&& isset($params[0])) {
555
+            } elseif ($rule == 'regex' && isset($params[0])) {
556 556
                 $schemaObject->pattern = $params[0];
557 557
             } elseif ($rule == 'optional') {
558 558
                 $schemaObject->required = false;
@@ -591,9 +591,9 @@  discard block
 block discarded – undo
591 591
         return $className;
592 592
     }
593 593
 
594
-    static public function implode($glue , array $pieces )
594
+    static public function implode($glue, array $pieces)
595 595
     {
596
-        $pieces = array_filter($pieces, function($i){return trim($i) !== '';});
596
+        $pieces = array_filter($pieces, function($i) {return trim($i) !== ''; });
597 597
         return implode($glue, $pieces);
598 598
     }
599 599
 }
600 600
\ 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.
src/DB/rules/insert.php 2 patches
Doc Comments   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,6 +41,9 @@  discard block
 block discarded – undo
41 41
 
42 42
 class OnDuplicateKeyUpdateRule extends ExecRule
43 43
 {
44
+    /**
45
+     * @param \PhpBoot\DB\Context $context
46
+     */
44 47
     public function __construct($context)
45 48
     {
46 49
         parent::__construct($context);
@@ -91,8 +94,6 @@  discard block
 block discarded – undo
91 94
      *      ->onDuplicateKeyUpdate('a=a+1')
92 95
      *  => "INSERT INTO table(a,b) VALUES(1,now()) ON DUPLICATE KEY UPDATE a=a+1"
93 96
      *
94
-     * @param string $column
95
-     * @param mixed $value
96 97
      * @return \PhpBoot\DB\rules\basic\ExecRule
97 98
      */
98 99
     public function onDuplicateKeyUpdate($expr, $_=null) {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      * @param array $values
45 45
      * @return \PhpBoot\DB\rules\insert\OnDuplicateKeyUpdateRule
46 46
      */
47
-    public function batchValues(array $values){
47
+    public function batchValues(array $values) {
48 48
         ValuesImpl::batchValues($this->context, $values);
49 49
         return new OnDuplicateKeyUpdateRule($this->context);
50 50
     }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      * @param mixed $value
107 107
      * @return \PhpBoot\DB\rules\basic\ExecRule
108 108
      */
109
-    public function onDuplicateKeyUpdate($expr, $_=null) {
109
+    public function onDuplicateKeyUpdate($expr, $_ = null) {
110 110
         $this->impl->set($this->context, $expr, array_slice(func_get_args(), 1));
111 111
         return new ExecRule($this->context);
112 112
     }
Please login to merge, or discard this patch.
src/Controller/ResponseHandler.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      */
28 28
     public function eraseMapping($target)
29 29
     {
30
-        if(!isset($this->mappings[$target])){
30
+        if (!isset($this->mappings[$target])) {
31 31
             return null;
32 32
         }
33 33
         $ori = $this->mappings[$target];
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function getMapping($target)
43 43
     {
44
-        if(!array_key_exists($target, $this->mappings)){
44
+        if (!array_key_exists($target, $this->mappings)) {
45 45
             return null;
46 46
         }
47 47
         return $this->mappings[$target];
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function getMappingBySource($source)
55 55
     {
56
-        foreach ($this->mappings as $k=>$v){
57
-            if($v->source == $source){
56
+        foreach ($this->mappings as $k=>$v) {
57
+            if ($v->source == $source) {
58 58
                 return [$k, $v];
59 59
             }
60 60
         }
61
-        return [null,null];
61
+        return [null, null];
62 62
     }
63 63
 
64 64
 
@@ -75,15 +75,15 @@  discard block
 block discarded – undo
75 75
             'params'=>$params
76 76
         ];
77 77
 
78
-        if($return instanceof Response){ //直接返回Response时, 对return不再做映射
78
+        if ($return instanceof Response) { //直接返回Response时, 对return不再做映射
79 79
             return $return;
80 80
         }
81 81
         $mappings = $this->getMappings();
82 82
 
83 83
         $output = [];
84
-        foreach($mappings as $key=>$map){
84
+        foreach ($mappings as $key=>$map) {
85 85
             $val = \JmesPath\search($map->source, $input);
86
-            if(substr($key, 0, strlen('response.')) == 'response.'){
86
+            if (substr($key, 0, strlen('response.')) == 'response.') {
87 87
                 $key = substr($key, strlen('response.'));
88 88
             }
89 89
             ArrayHelper::set($output, $key, $val);
Please login to merge, or discard this patch.
src/Controller/Annotations/RouteAnnotationHandler.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
             'DELETE'
44 44
         ]) or \PhpBoot\abort(new AnnotationSyntaxException("unknown method http $httpMethod in {$container->getClassName()}::$target"));
45 45
         //获取方法参数信息
46
-        $rfl =  new \ReflectionClass($container->getClassName());
46
+        $rfl = new \ReflectionClass($container->getClassName());
47 47
         $method = $rfl->getMethod($target);
48 48
         $methodParams = $method->getParameters();
49 49
 
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
         $routeParser = new Std();
69 69
         $uri = $params->getParam(1);
70 70
         $info = $routeParser->parse($uri); //0.4和1.0返回值不同, 不兼容
71
-        if(isset($info[0])){
72
-            foreach ($info[0] as $i){
73
-                if(is_array($i)) {
71
+        if (isset($info[0])) {
72
+            foreach ($info[0] as $i) {
73
+                if (is_array($i)) {
74 74
                     $route->addPathParam($i[0]);
75 75
                 }
76 76
             }
@@ -79,31 +79,31 @@  discard block
 block discarded – undo
79 79
         $hasRefParam = false;
80 80
         //设置参数列表
81 81
         $paramsMeta = [];
82
-        foreach ($methodParams as $param){
82
+        foreach ($methodParams as $param) {
83 83
             $paramName = $param->getName();
84 84
             $source = "request.$paramName";
85
-            if($route->hasPathParam($paramName)){ //参数来自路由
85
+            if ($route->hasPathParam($paramName)) { //参数来自路由
86 86
                 $source = "request.$paramName";
87
-            }elseif($httpMethod == 'GET'){
87
+            }elseif ($httpMethod == 'GET') {
88 88
                 $source = "request.$paramName"; //GET请求显示指定来自query string
89 89
             }
90 90
             $paramClass = $param->getClass();
91
-            if($paramClass){
91
+            if ($paramClass) {
92 92
                 $paramClass = $paramClass->getName();
93 93
             }
94 94
             $entityContainer = ContainerFactory::create($entityBuilder, $paramClass);
95 95
             $meta = new ParamMeta($paramName,
96 96
                 $source,
97
-                $paramClass?:'mixed',
97
+                $paramClass ?: 'mixed',
98 98
                 $param->isOptional(),
99
-                $param->isOptional()?$param->getDefaultValue():null,
99
+                $param->isOptional() ? $param->getDefaultValue() : null,
100 100
                 $param->isPassedByReference(),
101 101
                 null,
102 102
                 '',
103 103
                 $entityContainer
104 104
             );
105 105
             $paramsMeta[] = $meta;
106
-            if($meta->isPassedByReference){
106
+            if ($meta->isPassedByReference) {
107 107
                 $hasRefParam = true;
108 108
                 $responseHandler->setMapping('response.content.'.$meta->name, new ReturnMeta(
109 109
                     'params.'.$meta->name,
@@ -114,16 +114,16 @@  discard block
 block discarded – undo
114 114
         }
115 115
 
116 116
         $requestHandler->setParamMetas($paramsMeta);
117
-        if(!$hasRefParam){
118
-            $responseHandler->setMapping('response.content', new ReturnMeta('return','mixed','', new MixedTypeContainer()));
119
-        }else{
117
+        if (!$hasRefParam) {
118
+            $responseHandler->setMapping('response.content', new ReturnMeta('return', 'mixed', '', new MixedTypeContainer()));
119
+        }else {
120 120
             //当存在引用参数作为输出时, 默认将 return 数据绑定的到 data 下, 以防止和引用参数作为输出重叠
121
-            $responseHandler->setMapping($this->returnTarget, new ReturnMeta('return','mixed','', new MixedTypeContainer()));
121
+            $responseHandler->setMapping($this->returnTarget, new ReturnMeta('return', 'mixed', '', new MixedTypeContainer()));
122 122
         }
123 123
 
124 124
 
125 125
         $container->addRoute($target, $route);
126 126
     }
127 127
 
128
-    public $returnTarget='response.content.data';
128
+    public $returnTarget = 'response.content.data';
129 129
 }
130 130
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
             $source = "request.$paramName";
85 85
             if($route->hasPathParam($paramName)){ //参数来自路由
86 86
                 $source = "request.$paramName";
87
-            }elseif($httpMethod == 'GET'){
87
+            } elseif($httpMethod == 'GET'){
88 88
                 $source = "request.$paramName"; //GET请求显示指定来自query string
89 89
             }
90 90
             $paramClass = $param->getClass();
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         $requestHandler->setParamMetas($paramsMeta);
117 117
         if(!$hasRefParam){
118 118
             $responseHandler->setMapping('response.content', new ReturnMeta('return','mixed','', new MixedTypeContainer()));
119
-        }else{
119
+        } else{
120 120
             //当存在引用参数作为输出时, 默认将 return 数据绑定的到 data 下, 以防止和引用参数作为输出重叠
121 121
             $responseHandler->setMapping($this->returnTarget, new ReturnMeta('return','mixed','', new MixedTypeContainer()));
122 122
         }
Please login to merge, or discard this patch.
src/DB/rules/basic.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -48,6 +48,9 @@
 block discarded – undo
48 48
 
49 49
 class OrderByRule extends LimitRule
50 50
 {
51
+    /**
52
+     * @param Context $context
53
+     */
51 54
     public function __construct($context){
52 55
         parent::__construct($context);
53 56
         $this->impl = new OrderByImpl();
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 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
     }
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      * 
64 64
      * @return \PhpBoot\DB\rules\basic\LimitRule
65 65
      */
66
-    public function orderBy($column, $order=null) {
66
+    public function orderBy($column, $order = null) {
67 67
         $this->impl->orderBy($this->context, $column, $order);
68 68
         return new LimitRule($this->context);
69 69
     }
@@ -95,17 +95,17 @@  discard block
 block discarded – undo
95 95
      * @param mixed $_
96 96
      * @return NextWhereRule
97 97
      */
98
-    public function where($conditions=null, $_=null) {
99
-        if(is_callable($conditions)){
100
-            $callback = function ($context)use($conditions){
98
+    public function where($conditions = null, $_ = null) {
99
+        if (is_callable($conditions)) {
100
+            $callback = function($context)use($conditions){
101 101
                 $rule = new ScopedQuery($context);
102 102
                 $conditions($rule);
103 103
             };
104 104
             $conditions = $callback;
105 105
         }
106
-        if($this->isTheFirst){
107
-            WhereImpl::where($this->context, 'WHERE' ,$conditions, array_slice(func_get_args(), 1));
108
-        }else{
106
+        if ($this->isTheFirst) {
107
+            WhereImpl::where($this->context, 'WHERE', $conditions, array_slice(func_get_args(), 1));
108
+        }else {
109 109
             WhereImpl::where($this->context, 'AND', $conditions, array_slice(func_get_args(), 1));
110 110
         }
111 111
         return new NextWhereRule($this->context, false);
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
      * @param mixed $_
134 134
      * @return WhereRule
135 135
      */
136
-    public function orWhere($conditions=null, $_=null) {
137
-        if(is_callable($conditions)){
138
-            $callback = function ($context)use($conditions){
136
+    public function orWhere($conditions = null, $_ = null) {
137
+        if (is_callable($conditions)) {
138
+            $callback = function($context)use($conditions){
139 139
                 $rule = new ScopedQuery($context);
140 140
                 $conditions($rule);
141 141
             };
@@ -160,17 +160,17 @@  discard block
 block discarded – undo
160 160
      * @param null $_
161 161
      * @return NextScopedQuery
162 162
      */
163
-    public function where($expr, $_= null){
164
-        if(is_callable($expr)){
165
-            $callback = function ($context)use($expr){
163
+    public function where($expr, $_ = null) {
164
+        if (is_callable($expr)) {
165
+            $callback = function($context)use($expr){
166 166
                 $rule = new ScopedQuery($context, true);
167 167
                 $expr($rule);
168 168
             };
169 169
             $expr = $callback;
170 170
         }
171
-        if($this->isTheFirst){
171
+        if ($this->isTheFirst) {
172 172
             WhereImpl::where($this->context, '', $expr, array_slice(func_get_args(), 1));
173
-        }else{
173
+        }else {
174 174
             WhereImpl::where($this->context, 'AND', $expr, array_slice(func_get_args(), 1));
175 175
         }
176 176
         return new NextScopedQuery($this->context, false);
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
186 186
      * @param null $_
187 187
      * @return ScopedQuery
188 188
      */
189
-    public function orWhere($expr, $_= null){
190
-        if(is_callable($expr)){
191
-            $callback = function ($context)use($expr){
189
+    public function orWhere($expr, $_ = null) {
190
+        if (is_callable($expr)) {
191
+            $callback = function($context)use($expr){
192 192
                 $rule = new ScopedQuery($context, true);
193 193
                 $expr($rule);
194 194
             };
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
         }
106 106
         if($this->isTheFirst){
107 107
             WhereImpl::where($this->context, 'WHERE' ,$conditions, array_slice(func_get_args(), 1));
108
-        }else{
108
+        } else{
109 109
             WhereImpl::where($this->context, 'AND', $conditions, array_slice(func_get_args(), 1));
110 110
         }
111 111
         return new NextWhereRule($this->context, false);
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
         }
171 171
         if($this->isTheFirst){
172 172
             WhereImpl::where($this->context, '', $expr, array_slice(func_get_args(), 1));
173
-        }else{
173
+        } else{
174 174
             WhereImpl::where($this->context, 'AND', $expr, array_slice(func_get_args(), 1));
175 175
         }
176 176
         return new NextScopedQuery($this->context, false);
Please login to merge, or discard this patch.