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.
Test Failed
Push — master ( b4390b...d91f3b )
by cao
04:15
created
src/DB/rules/update.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -24,6 +24,9 @@
 block discarded – undo
24 24
 
25 25
 class UpdateSetRule extends WhereRule
26 26
 {
27
+    /**
28
+     * @param \PhpBoot\DB\Context $context
29
+     */
27 30
     public function __construct($context){
28 31
         parent::__construct($context);
29 32
         $this->impl = new UpdateSetImpl();
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
 class UpdateSetRule extends WhereRule
26 26
 {
27
-    public function __construct($context){
27
+    public function __construct($context) {
28 28
         parent::__construct($context);
29 29
         $this->impl = new UpdateSetImpl();
30 30
     }
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      * @param mixed $_
56 56
      * @return \PhpBoot\DB\rules\update\UpdateSetRule
57 57
      */
58
-    public function setExpr($expr, $_=null) {
58
+    public function setExpr($expr, $_ = null) {
59 59
         $this->impl->setExpr($this->context, $expr, array_slice(func_get_args(), 1));
60 60
         return $this;
61 61
     }
Please login to merge, or discard this patch.
src/Docgen/Swagger/Swagger.php 5 patches
Doc Comments   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     }
89 89
 
90 90
     /**
91
-     * @param $object
91
+     * @param Swagger $object
92 92
      * @return array
93 93
      */
94 94
     static public function objectToArray($object)
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     /**
114 114
      * @param Application $app
115 115
      * @param ControllerContainer $controller
116
-     * @param $action
116
+     * @param integer $action
117 117
      * @param Route $route
118 118
      * @return array
119 119
      */
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
     /**
163 163
      * @param Application $app
164 164
      * @param ControllerContainer $controller
165
-     * @param $action
165
+     * @param integer $action
166 166
      * @param Route $route
167 167
      * @return null|ResponseObject
168 168
      */
@@ -299,6 +299,9 @@  discard block
 block discarded – undo
299 299
         return new RefSchemaObject("#/definitions/$name");
300 300
     }
301 301
 
302
+    /**
303
+     * @param integer $action
304
+     */
302 305
     public function getParamsSchema(Application $app,
303 306
                                     ControllerContainer $controller,
304 307
                                     $action,
Please login to merge, or discard this patch.
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.
Spacing   +30 added lines, -30 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($res[$status])) {
148 148
                 //$this->warnings[] = "status response $status has been used for $name, $desc";
149 149
                 $res = $res[$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 = 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 = 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;
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.
src/ORM/ModelContainerBuilder.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,6 @@
 block discarded – undo
2 2
 
3 3
 namespace PhpBoot\ORM;
4 4
 
5
-use DI\Container;
6 5
 use DI\FactoryInterface;
7 6
 use Doctrine\Common\Cache\Cache;
8 7
 use PhpBoot\DI\DIContainerBuilder;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
 
17 17
 class ModelContainerBuilder extends EntityContainerBuilder
18 18
 {
19
-    static $DEFAULT_ANNOTATIONS=[
19
+    static $DEFAULT_ANNOTATIONS = [
20 20
         [ClassAnnotationHandler::class, 'class'],
21 21
         [PKAnnotationHandler::class, "class.children[?name=='pk']"],
22 22
         [TableAnnotationHandler::class, "class.children[?name=='table']"],
Please login to merge, or discard this patch.
src/Utils/AnnotationParams.php 3 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -5,6 +5,9 @@  discard block
 block discarded – undo
5 5
  */
6 6
 class AnnotationParams implements \Countable, \ArrayAccess
7 7
 {
8
+    /**
9
+     * @param integer $limit
10
+     */
8 11
     public function __construct($text, $limit)
9 12
     {
10 13
         if($limit == 1){
@@ -142,6 +145,12 @@  discard block
 block discarded – undo
142 145
         }
143 146
     }
144 147
 
148
+    /**
149
+     * @param integer $pos
150
+     * @param string $default
151
+     *
152
+     * @return string
153
+     */
145 154
     public function getRawParam($pos, $default = null)
146 155
     {
147 156
         if(isset($this->rawParams[$pos])){
@@ -151,6 +160,9 @@  discard block
 block discarded – undo
151 160
         }
152 161
     }
153 162
 
163
+    /**
164
+     * @param boolean $ignoreError
165
+     */
154 166
     private function stripSlashes($text, $ignoreError)
155 167
     {
156 168
         if(strlen($text)>=2 && substr($text,0,1) == '"'){
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -7,31 +7,31 @@  discard block
 block discarded – undo
7 7
 {
8 8
     public function __construct($text, $limit)
9 9
     {
10
-        if($limit == 1){
10
+        if ($limit == 1) {
11 11
             $this->rawParams[] = $text;
12 12
             return;
13 13
         }
14
-        if($limit <= 0){
14
+        if ($limit<=0) {
15 15
             return;
16 16
         }
17 17
         $text = ltrim($text);
18 18
         $pos = 0;
19 19
         $state = 'stateNormal';
20 20
         $len = strlen($text);
21
-        if($len == 0){
21
+        if ($len == 0) {
22 22
             return;
23 23
         }
24
-        while (true){
25
-            if($state == 'stateNormal' && count($this->rawParams)+1 == $limit){
24
+        while (true) {
25
+            if ($state == 'stateNormal' && count($this->rawParams) + 1 == $limit) {
26 26
                 break;
27 27
             }
28 28
             $pos = $this->$state($text, $pos, $state);
29
-            if($pos === false || $pos>= $len){
29
+            if ($pos === false || $pos>=$len) {
30 30
                 break;
31 31
             }
32 32
         };
33
-        if($this->prePos != strlen($text)){
34
-            $this->rawParams[] = substr($text,$this->prePos);
33
+        if ($this->prePos != strlen($text)) {
34
+            $this->rawParams[] = substr($text, $this->prePos);
35 35
         }
36 36
     }
37 37
 
@@ -42,16 +42,16 @@  discard block
 block discarded – undo
42 42
     {
43 43
         //查找引号或者空格
44 44
         $found = [];
45
-        $todo = substr($text,$pos);
46
-        if(!preg_match('/[\s"\']/', $todo, $found, PREG_OFFSET_CAPTURE) ||
47
-            count($found)==0){
48
-            $this->rawParams[] = substr($text,$this->prePos);
45
+        $todo = substr($text, $pos);
46
+        if (!preg_match('/[\s"\']/', $todo, $found, PREG_OFFSET_CAPTURE) ||
47
+            count($found) == 0) {
48
+            $this->rawParams[] = substr($text, $this->prePos);
49 49
             $this->prePos = strlen($text);
50 50
             return false;
51 51
         }
52 52
         list($chars, $offset) = $found[0];
53 53
 
54
-        if($chars == '"'){
54
+        if ($chars == '"') {
55 55
             $next = 'stateDoubleQ';
56 56
             return $pos + $offset + 1;
57 57
         }
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 //            $next = 'stateSingleQ';
60 60
 //            return $pos + $offset + 1;
61 61
 //        }
62
-        else{
63
-            $this->rawParams[] = substr($text,$this->prePos, $pos-$this->prePos+$offset);
62
+        else {
63
+            $this->rawParams[] = substr($text, $this->prePos, $pos - $this->prePos + $offset);
64 64
             $next = 'stateSpace';
65 65
             $this->prePos = $pos + $offset + 1;
66 66
             return $this->prePos;
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
     private function stateSpace($text, $pos, &$next)
74 74
     {
75 75
         $found = [];
76
-        $todo = substr($text,$pos);
77
-        if(!preg_match('/\S/', $todo, $found, PREG_OFFSET_CAPTURE) ||
78
-            count($found)==0){
76
+        $todo = substr($text, $pos);
77
+        if (!preg_match('/\S/', $todo, $found, PREG_OFFSET_CAPTURE) ||
78
+            count($found) == 0) {
79 79
             return false;
80 80
         }
81 81
         list($chars, $offset) = $found[0];
@@ -105,20 +105,20 @@  discard block
 block discarded – undo
105 105
     /**
106 106
      * 进入双引号状态
107 107
      */
108
-    private function stateDoubleQ($text, $pos, &$next){
108
+    private function stateDoubleQ($text, $pos, &$next) {
109 109
 
110 110
         $found = [];
111
-        $todo = substr($text,$pos);
112
-        if(!preg_match('/[\\\\"]/', $todo, $found, PREG_OFFSET_CAPTURE) ||
113
-            count($found)==0){
111
+        $todo = substr($text, $pos);
112
+        if (!preg_match('/[\\\\"]/', $todo, $found, PREG_OFFSET_CAPTURE) ||
113
+            count($found) == 0) {
114 114
             return false;
115 115
         }
116 116
         list($chars, $offset) = $found[0];
117
-        if($chars == '\\'){
118
-            return $pos+$offset+2;
119
-        }else{
117
+        if ($chars == '\\') {
118
+            return $pos + $offset + 2;
119
+        }else {
120 120
             $next = 'stateNormal';
121
-            return $pos+$offset+1;
121
+            return $pos + $offset + 1;
122 122
         }
123 123
     }
124 124
 
@@ -127,38 +127,38 @@  discard block
 block discarded – undo
127 127
         return count($this->rawParams);
128 128
     }
129 129
 
130
-    public function getParam($pos, $default = null, $ignoreError=false)
130
+    public function getParam($pos, $default = null, $ignoreError = false)
131 131
     {
132
-        if(isset($this->cachedParams[$pos])){
132
+        if (isset($this->cachedParams[$pos])) {
133 133
             return $this->cachedParams[$pos];
134 134
         }
135
-        if(isset($this->rawParams[$pos])){
135
+        if (isset($this->rawParams[$pos])) {
136 136
             $param = $this->rawParams[$pos];
137 137
             $param = $this->stripSlashes($param, $ignoreError);
138 138
             $this->cachedParams[$pos] = $param;
139 139
             return $param;
140
-        }else{
140
+        }else {
141 141
             return $default;
142 142
         }
143 143
     }
144 144
 
145 145
     public function getRawParam($pos, $default = null)
146 146
     {
147
-        if(isset($this->rawParams[$pos])){
147
+        if (isset($this->rawParams[$pos])) {
148 148
             return $this->rawParams[$pos];
149
-        }else{
149
+        }else {
150 150
             return $default;
151 151
         }
152 152
     }
153 153
 
154 154
     private function stripSlashes($text, $ignoreError)
155 155
     {
156
-        if(strlen($text)>=2 && substr($text,0,1) == '"'){
156
+        if (strlen($text)>=2 && substr($text, 0, 1) == '"') {
157 157
             $decoded = json_decode($text);
158
-            if(json_last_error()){
159
-                if($ignoreError){
158
+            if (json_last_error()) {
159
+                if ($ignoreError) {
160 160
                     return $text;
161
-                }else{
161
+                }else {
162 162
                     \PhpBoot\abort('json_decode failed with '.json_last_error_msg(), [$text]);
163 163
                 }
164 164
             }
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         list($chars, $offset) = $found[0];
117 117
         if($chars == '\\'){
118 118
             return $pos+$offset+2;
119
-        }else{
119
+        } else{
120 120
             $next = 'stateNormal';
121 121
             return $pos+$offset+1;
122 122
         }
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
             $param = $this->stripSlashes($param, $ignoreError);
138 138
             $this->cachedParams[$pos] = $param;
139 139
             return $param;
140
-        }else{
140
+        } else{
141 141
             return $default;
142 142
         }
143 143
     }
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
     {
147 147
         if(isset($this->rawParams[$pos])){
148 148
             return $this->rawParams[$pos];
149
-        }else{
149
+        } else{
150 150
             return $default;
151 151
         }
152 152
     }
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             if(json_last_error()){
159 159
                 if($ignoreError){
160 160
                     return $text;
161
-                }else{
161
+                } else{
162 162
                     \PhpBoot\abort('json_decode failed with '.json_last_error_msg(), [$text]);
163 163
                 }
164 164
             }
Please login to merge, or discard this patch.
src/Utils/SafeFileWriter.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
     /**
13 13
      * 写入文件
14 14
      * @param string $path 路径
15
-     * @param mixed $data 写入的值
15
+     * @param string $data 写入的值
16 16
      * @param boolean $overwrite 是否覆盖已有文件
17 17
      * @return boolean
18 18
      */
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,15 +16,15 @@
 block discarded – undo
16 16
      * @param boolean $overwrite 是否覆盖已有文件
17 17
      * @return boolean
18 18
      */
19
-    static public function write($path, $data, $overwrite = true){
19
+    static public function write($path, $data, $overwrite = true) {
20 20
         $path = str_replace('\\', '/', $path);
21 21
         $fileDir = dirname($path);
22 22
         $tmpFile = tempnam($fileDir);
23 23
         false !== @file_put_contents($tmpFile, $data) or \PhpBoot\abort("write to file: $tmpFile failed");
24
-        if($overwrite){
24
+        if ($overwrite) {
25 25
             @unlink($path); //删除原始文件
26 26
         }
27
-        if(!@rename($tmpFile, $path)){
27
+        if (!@rename($tmpFile, $path)) {
28 28
             @unlink($tmpFile); //删除原始文件
29 29
             \PhpBoot\abort("write to file: $tmpFile failed");
30 30
             return false;
Please login to merge, or discard this patch.
src/Utils/TypeHint.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
 
50 50
     /**
51 51
      * 获取数组的类型
52
-     * @param $type
52
+     * @param string|null $type
53 53
      * @return string|null
54 54
      */
55 55
     static function getArrayType($type){
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,10 +14,10 @@  discard block
 block discarded – undo
14 14
      * @param string $type 需要标准化的字符串
15 15
      * @param  string $contextClass 当前上下文所在的类,一般传__CLASS__, 用于扫描当前文件的use信息, 以便拼上namespace
16 16
      */
17
-    static function normalize($type, $contextClass=null){
17
+    static function normalize($type, $contextClass = null) {
18 18
         $resolver = new TypeResolver();
19 19
         $context = null;
20
-        if($contextClass){
20
+        if ($contextClass) {
21 21
             //TODO 优化性能
22 22
             $contextFactory = new ContextFactory();
23 23
             $context = $contextFactory->createFromReflector(new \ReflectionClass($contextClass));
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      * 是否是基本类型
31 31
      * @param string $type
32 32
      */
33
-    static function isScalarType($type){
33
+    static function isScalarType($type) {
34 34
         return in_array($type, [
35 35
             'bool',
36 36
             'int',
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      * @param $type
44 44
      * @return bool
45 45
      */
46
-    static function isArray($type){
46
+    static function isArray($type) {
47 47
         return ($type == 'array' || substr($type, -2) == '[]');
48 48
     }
49 49
 
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
      * @param $type
53 53
      * @return string|null
54 54
      */
55
-    static function getArrayType($type){
55
+    static function getArrayType($type) {
56 56
         self::isArray($type) or \PhpBoot\abort(new \InvalidArgumentException("$type is not array"));
57
-        if($type == 'array') {
57
+        if ($type == 'array') {
58 58
             return 'mixed';
59
-        }else{
60
-            return substr($type,0,-2);
59
+        }else {
60
+            return substr($type, 0, -2);
61 61
         }
62 62
     }
63 63
 }
64 64
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
         self::isArray($type) or \PhpBoot\abort(new \InvalidArgumentException("$type is not array"));
57 57
         if($type == 'array') {
58 58
             return 'mixed';
59
-        }else{
59
+        } else{
60 60
             return substr($type,0,-2);
61 61
         }
62 62
     }
Please login to merge, or discard this patch.
src/Lock/FileLock.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@
 block discarded – undo
10 10
     {
11 11
         $path = sys_get_temp_dir().'/lock_252a8fdc9b944af99a9bc53d2aea08f1/'.$key;
12 12
         $tmpFile = tempnam($path, 'lock');
13
-        if(SafeFileWriter::write($tmpFile, json_encode(['time'=>time(), 'ttl'=>$ttl]), false)){
13
+        if (SafeFileWriter::write($tmpFile, json_encode(['time'=>time(), 'ttl'=>$ttl]), false)) {
14 14
             $this->locked = true;
15 15
             return true;
16
-        }else{
16
+        }else {
17 17
             return false;
18 18
         }
19 19
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
         if(SafeFileWriter::write($tmpFile, json_encode(['time'=>time(), 'ttl'=>$ttl]), false)){
14 14
             $this->locked = true;
15 15
             return true;
16
-        }else{
16
+        } else{
17 17
             return false;
18 18
         }
19 19
     }
Please login to merge, or discard this patch.
src/Lock/LocalAutoLock.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -8,20 +8,20 @@  discard block
 block discarded – undo
8 8
  */
9 9
 class LocalAutoLock
10 10
 {
11
-    static function lock($key, $seconds, callable $success, callable $error=null){
11
+    static function lock($key, $seconds, callable $success, callable $error = null) {
12 12
         $key = 'lock:'.$key;
13
-        if(function_exists('apc_add')){
13
+        if (function_exists('apc_add')) {
14 14
             $lock = new ApcLock();
15
-        }else{
15
+        }else {
16 16
             $lock = new FileLock();
17 17
         }
18
-        try{
19
-            if(!isset(self::$currentLock[$key])){
18
+        try {
19
+            if (!isset(self::$currentLock[$key])) {
20 20
                 self::$currentLock[$key] = 0;
21 21
             }
22
-            if(self::$currentLock[$key] == 0){  //未加锁
23
-                if(!$lock->lock($key, $seconds)){ //加锁失败
24
-                    if($error){
22
+            if (self::$currentLock[$key] == 0) {  //未加锁
23
+                if (!$lock->lock($key, $seconds)) { //加锁失败
24
+                    if ($error) {
25 25
                         return $error();
26 26
                     }
27 27
                     return;
@@ -29,34 +29,34 @@  discard block
 block discarded – undo
29 29
             }
30 30
             //嵌套加锁
31 31
             self::$currentLock[$key]++;
32
-        }catch (\Exception $e){
32
+        }catch (\Exception $e) {
33 33
             return $error($e);
34 34
         }
35 35
         $res = null;
36
-        try{
36
+        try {
37 37
             $res = $success();
38
-        }catch (\Exception $e){
38
+        }catch (\Exception $e) {
39 39
             self::$currentLock[$key]--;
40
-            if(self::$currentLock[$key] == 0){
41
-                try{
40
+            if (self::$currentLock[$key] == 0) {
41
+                try {
42 42
                     $lock->unlock($key);
43
-                }catch (\Exception $e){
43
+                }catch (\Exception $e) {
44 44
 
45 45
                 }
46 46
             }
47 47
             throw $e;
48 48
         }
49 49
         self::$currentLock[$key]--;
50
-        if(self::$currentLock[$key] == 0){
51
-            try{
50
+        if (self::$currentLock[$key] == 0) {
51
+            try {
52 52
                 $lock->unlock($key);
53
-            }catch (\Exception $e){
53
+            }catch (\Exception $e) {
54 54
 
55 55
             }
56 56
         }
57 57
         return $res;
58 58
     }
59 59
 
60
-    private $cache=[];
61
-    static private $currentLock=[];
60
+    private $cache = [];
61
+    static private $currentLock = [];
62 62
 }
63 63
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
         $key = 'lock:'.$key;
13 13
         if(function_exists('apc_add')){
14 14
             $lock = new ApcLock();
15
-        }else{
15
+        } else{
16 16
             $lock = new FileLock();
17 17
         }
18 18
         try{
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
             }
30 30
             //嵌套加锁
31 31
             self::$currentLock[$key]++;
32
-        }catch (\Exception $e){
32
+        } catch (\Exception $e){
33 33
             return $error($e);
34 34
         }
35 35
         $res = null;
36 36
         try{
37 37
             $res = $success();
38
-        }catch (\Exception $e){
38
+        } catch (\Exception $e){
39 39
             self::$currentLock[$key]--;
40 40
             if(self::$currentLock[$key] == 0){
41 41
                 try{
42 42
                     $lock->unlock($key);
43
-                }catch (\Exception $e){
43
+                } catch (\Exception $e){
44 44
 
45 45
                 }
46 46
             }
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         if(self::$currentLock[$key] == 0){
51 51
             try{
52 52
                 $lock->unlock($key);
53
-            }catch (\Exception $e){
53
+            } catch (\Exception $e){
54 54
 
55 55
             }
56 56
         }
Please login to merge, or discard this patch.
src/Lock/ApcLock.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,10 +6,10 @@  discard block
 block discarded – undo
6 6
 
7 7
     public function lock($key, $ttl)
8 8
     {
9
-        if(apc_add($key, 1, $ttl)){
9
+        if (apc_add($key, 1, $ttl)) {
10 10
             $this->locked = true;
11 11
             return true;
12
-        }else{
12
+        }else {
13 13
             return false;
14 14
         }
15 15
     }
@@ -21,5 +21,5 @@  discard block
 block discarded – undo
21 21
         $this->locked = false;
22 22
         return $res;
23 23
     }
24
-    private $locked=false;
24
+    private $locked = false;
25 25
 }
26 26
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
         if(apc_add($key, 1, $ttl)){
10 10
             $this->locked = true;
11 11
             return true;
12
-        }else{
12
+        } else{
13 13
             return false;
14 14
         }
15 15
     }
Please login to merge, or discard this patch.