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
Branch master (eecfea)
by cao
03:46
created
src/Application.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,6 @@
 block discarded – undo
24 24
 use PhpBoot\DB\DB;
25 25
 use PhpBoot\DI\DIContainerBuilder;
26 26
 use PhpBoot\DI\Traits\EnableDIAnnotations;
27
-use PhpBoot\Lock\LocalAutoLock;
28 27
 use PhpBoot\Utils\Logger;
29 28
 use Psr\Container\ContainerExceptionInterface;
30 29
 use Psr\Container\ContainerInterface;
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -83,11 +83,11 @@  discard block
 block discarded – undo
83 83
 
84 84
             Request::class => \DI\factory([Application::class, 'createRequestFromGlobals']),
85 85
         ];
86
-        if(function_exists('apc_fetch')){
86
+        if (function_exists('apc_fetch')) {
87 87
             $default += [
88 88
                 Cache::class => \DI\object(ApcCache::class)
89 89
             ];
90
-        }else{
90
+        }else {
91 91
             $default += [
92 92
                 Cache::class => \DI\object(FilesystemCache::class)
93 93
                     ->constructorParameter('directory', sys_get_temp_dir())
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
      * @param string[] $hooks hook class names
130 130
      * @return void
131 131
      */
132
-    public function loadRoutesFromClass($className, $hooks=[])
132
+    public function loadRoutesFromClass($className, $hooks = [])
133 133
     {
134 134
         $cache = new CheckableCache($this->cache);
135 135
 
136
-        $key = 'loadRoutesFromClass:' . md5(__CLASS__ . ':' . $className);
136
+        $key = 'loadRoutesFromClass:'.md5(__CLASS__.':'.$className);
137 137
         $routes = $cache->get($key, $this);
138 138
 
139 139
         $controller = null;
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
             $this->routes[] = [
151 151
                 $method,
152 152
                 $uri,
153
-                function (Application $app, Request $request) use ($cache, $className, $actionName, $controller) {
153
+                function(Application $app, Request $request) use ($cache, $className, $actionName, $controller) {
154 154
 
155
-                    $key = 'loadRoutesFromClass:route:' . md5(__CLASS__ . ':' . $className . ':' . $actionName);
155
+                    $key = 'loadRoutesFromClass:route:'.md5(__CLASS__.':'.$className.':'.$actionName);
156 156
 
157 157
                     $routeInstance = $cache->get($key, $this);
158 158
                     if ($routeInstance == $this) {
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
      * @param string[] $hooks
181 181
      * @return void
182 182
      */
183
-    public function loadRoutesFromPath($fromPath, $namespace = '', $hooks=[])
183
+    public function loadRoutesFromPath($fromPath, $namespace = '', $hooks = [])
184 184
     {
185 185
         $dir = @dir($fromPath);
186 186
 
187
-        $getEach = function () use ($dir) {
187
+        $getEach = function() use ($dir) {
188 188
             $name = $dir->read();
189 189
             if (!$name) {
190 190
                 return $name;
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
             if ($entry == '.' || $entry == '..') {
197 197
                 continue;
198 198
             }
199
-            $path = $fromPath . '/' . str_replace('\\', '/', $entry);
199
+            $path = $fromPath.'/'.str_replace('\\', '/', $entry);
200 200
             if (is_file($path) && substr_compare($entry, '.php', strlen($entry) - 4, 4, true) == 0) {
201
-                $class_name = $namespace . '\\' . substr($entry, 0, strlen($entry) - 4);
201
+                $class_name = $namespace.'\\'.substr($entry, 0, strlen($entry) - 4);
202 202
                 $this->loadRoutesFromClass($class_name, $hooks);
203
-            } else {
203
+            }else {
204 204
                 //\Log::debug($path.' ignored');
205 205
             }
206 206
         }
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      * @param callable $handler function(Application $app, Request $request):Response
214 214
      * @param string[] $hooks
215 215
      */
216
-    public function addRoute($method, $uri, callable $handler, $hooks=[])
216
+    public function addRoute($method, $uri, callable $handler, $hooks = [])
217 217
     {
218 218
         $this->routes[] = [$method, $uri, $handler, $hooks];
219 219
     }
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
     {
240 240
         //  TODO 把 Route里的异常处理 ExceptionRenderer 移到这里更妥?
241 241
         $renderer = $this->get(ExceptionRenderer::class);
242
-        try{
242
+        try {
243 243
             if ($request == null) {
244 244
                 $request = $this->make(Request::class);
245 245
             }
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
             }
250 250
             $uri = rawurldecode($uri);
251 251
 
252
-            $next = function (Request $request)use($uri){
252
+            $next = function(Request $request)use($uri){
253 253
                 $dispatcher = $this->getDispatcher();
254 254
                 $res = $dispatcher->dispatch($request->getMethod(), $uri);
255 255
                 if ($res[0] == Dispatcher::FOUND) {
@@ -258,10 +258,10 @@  discard block
 block discarded – undo
258 258
                         $request->attributes->add($res[2]);
259 259
                     }
260 260
                     list($handler, $hooks) = $res[1];
261
-                    $next = function (Request $request)use($handler){
261
+                    $next = function(Request $request)use($handler){
262 262
                         return $handler($this, $request);
263 263
                     };
264
-                    foreach (array_reverse($hooks) as $hookName){
264
+                    foreach (array_reverse($hooks) as $hookName) {
265 265
                         $next = function($request)use($hookName, $next){
266 266
                             $hook = $this->get($hookName);
267 267
                             /**@var $hook HookInterface*/
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
                     \PhpBoot\abort(new NotFoundHttpException(), [$request->getMethod(), $uri]);
275 275
                 } elseif ($res[0] == Dispatcher::METHOD_NOT_ALLOWED) {
276 276
                     \PhpBoot\abort(new MethodNotAllowedHttpException($res[1]), [$request->getMethod(), $uri]);
277
-                } else {
277
+                }else {
278 278
                     \PhpBoot\abort("unknown dispatch return {$res[0]}");
279 279
                 }
280 280
             };
281 281
 
282
-            foreach (array_reverse($this->getGlobalHooks()) as $hookName){
282
+            foreach (array_reverse($this->getGlobalHooks()) as $hookName) {
283 283
                 $next = function($request)use($hookName, $next){
284 284
                     $hook = $this->get($hookName);
285 285
                     /**@var $hook HookInterface*/
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
             }
295 295
             return $response;
296 296
 
297
-        }catch (\Exception $e){
297
+        }catch (\Exception $e) {
298 298
             $renderer->render($e);
299 299
         }
300 300
 
Please login to merge, or discard this patch.
src/Controller/ControllerContainerBuilder.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,6 @@
 block discarded – undo
5 5
 use DI\FactoryInterface;
6 6
 use \DI\InvokerInterface as DIInvokerInterface;
7 7
 use Doctrine\Common\Cache\Cache;
8
-use PhpBoot\Cache\LocalCacheInterface;
9 8
 use PhpBoot\Controller\Annotations\BindAnnotationHandler;
10 9
 use PhpBoot\Controller\Annotations\ClassAnnotationHandler;
11 10
 use PhpBoot\Controller\Annotations\HookAnnotationHandler;
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 
20 20
 class ControllerContainerBuilder extends ContainerBuilder
21 21
 {
22
-    static $DEFAULT_ANNOTATIONS=[
22
+    static $DEFAULT_ANNOTATIONS = [
23 23
         [ClassAnnotationHandler::class, 'class'],
24 24
         [PathAnnotationHandler::class, "class.children[?name=='path']"],
25 25
         [RouteAnnotationHandler::class, "methods.*.children[?name=='route'][]"],
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
                                 Cache $cache,
44 44
                                 array $annotations = null)
45 45
     {
46
-        if($annotations){
46
+        if ($annotations) {
47 47
             parent::__construct($annotations, $cache);
48
-        }else{
48
+        }else {
49 49
             parent::__construct(self::$DEFAULT_ANNOTATIONS, $cache);
50 50
         }
51 51
 
Please login to merge, or discard this patch.
src/Docgen/Swagger/Swagger.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,6 @@
 block discarded – undo
21 21
 use PhpBoot\Metas\ParamMeta;
22 22
 use PhpBoot\Metas\ReturnMeta;
23 23
 use PhpBoot\Utils\ArrayHelper;
24
-use PhpBoot\Validator\Validator;
25 24
 use Symfony\Component\HttpKernel\Exception\HttpException;
26 25
 
27 26
 class Swagger extends SwaggerObject
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
             }
104 104
             if (is_array($v) || is_object($v)) {
105 105
                 $res[$k] = self::objectToArray($v);
106
-            } else {
106
+            }else {
107 107
                 $res[$k] = $v;
108 108
             }
109 109
         }
@@ -135,21 +135,21 @@  discard block
 block discarded – undo
135 135
             //TODO status 重复怎么办
136 136
             if ($ins instanceof HttpException) {
137 137
                 $status = $ins->getStatusCode();
138
-            } else {
138
+            }else {
139 139
 
140 140
                 $status = 500;
141 141
             }
142 142
             if (isset($res[$status])) {
143 143
                 //$this->warnings[] = "status response $status has been used for $name, $desc";
144 144
                 $res = $res[$status];
145
-            } else {
145
+            }else {
146 146
                 $res = new ResponseObject();
147 147
             }
148 148
             $shortName = self::getShortClassName($name);
149 149
             $desc = "$shortName: $desc";
150 150
             $res->description = implode("\n", [$res->description, $desc]);
151 151
             $error = $app->get(ExceptionRenderer::class)->render($ins)->getContent();
152
-            if($error){
152
+            if ($error) {
153 153
                 $res->examples = [$shortName => $error];
154 154
             }
155 155
             //$res->schema = new RefSchemaObject("#/definitions/$name");
@@ -208,9 +208,9 @@  discard block
 block discarded – undo
208 208
     {
209 209
         if ($content instanceof ReturnMeta || $content instanceof ParamMeta) {
210 210
             return $this->makeExample($content->container);
211
-        }elseif ($content instanceof TypeContainerInterface){
211
+        }elseif ($content instanceof TypeContainerInterface) {
212 212
             return $content->makeExample();
213
-        }elseif(is_array($content)) {
213
+        }elseif (is_array($content)) {
214 214
             $res = [];
215 215
             foreach ($content as $k => $v) {
216 216
                 $res[$k] = $this->makeExample($v);
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
                                    array $arr)
235 235
     {
236 236
         $className = self::getShortClassName($controller->getClassName());
237
-        $name = $className . ucfirst($action) . 'Res';
237
+        $name = $className.ucfirst($action).'Res';
238 238
 
239 239
         $schema = new SimpleModelSchemaObject();
240 240
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
                 } elseif ($v->container instanceof EntityContainer) {
253 253
                     $sub = $this->getRefSchema($app, $controller, $action, $route, $v->container);
254 254
                     //TODO array for validation
255
-                } else {
255
+                }else {
256 256
                     $sub = new PrimitiveSchemaObject();
257 257
                     $sub->type = self::mapType($v->type);
258 258
                     self::mapValidation($v->validation, $sub);
@@ -264,14 +264,14 @@  discard block
 block discarded – undo
264 264
                     $schema->required[] = $k;
265 265
                 }
266 266
                 $schema->properties[$k] = $sub;
267
-            } else {
267
+            }else {
268 268
                 //TODO how to do?
269 269
             }
270 270
         }
271 271
         $unused = $name;
272 272
         $tempId = 0;
273 273
         while (isset($this->definitions[$unused])) {
274
-            $unused = $name . $tempId;
274
+            $unused = $name.$tempId;
275 275
             $tempId++;
276 276
         }
277 277
         $this->definitions[$unused] = $schema;
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
                     || $route->getMethod() == 'PATCH'
342 342
                 ) {
343 343
                     $in = 'body';
344
-                } else {
344
+                }else {
345 345
                     $in = 'query';
346 346
                 }
347 347
             }
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
                 } elseif ($param->container instanceof EntityContainer) {
353 353
                     $paramSchema = $this->getRefSchema($app, $controller, $action, $route, $param->container);
354 354
                     //TODO array for validation
355
-                } else {
355
+                }else {
356 356
                     $paramSchema = new PrimitiveSchemaObject();
357 357
                     $paramSchema->type = self::mapType($param->type);
358 358
                     self::mapValidation($param->validation, $paramSchema);
@@ -363,10 +363,10 @@  discard block
 block discarded – undo
363 363
                 $paramSchema->default = $param->default;
364 364
                 $paramSchema->required = !$param->isOptional;
365 365
                 $parameters[] = $paramSchema;
366
-            } else {
366
+            }else {
367 367
                 if (!$name) {
368 368
                     $body = $param;
369
-                } else {
369
+                }else {
370 370
                     ArrayHelper::set($body, $name, $param);
371 371
                 }
372 372
 
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
             $paramSchema->in = 'body';
379 379
             if (is_array($body)) {
380 380
                 $paramSchema->schema = $this->makeTempSchema($app, $controller, $action, $route, $body);
381
-            } else {
381
+            }else {
382 382
                 $paramSchema->schema = $this->getAnySchema($app, $controller, $action, $route, $body->container);
383 383
             }
384 384
 
@@ -405,8 +405,8 @@  discard block
 block discarded – undo
405 405
         } elseif ($container instanceof ScalarTypeContainer) {
406 406
             $schema = new PrimitiveSchemaObject();
407 407
             $schema->type = self::mapType($container->getType());
408
-        } elseif($container == null){
409
-            $schema = null ;//new PrimitiveSchemaObject();
408
+        } elseif ($container == null) {
409
+            $schema = null; //new PrimitiveSchemaObject();
410 410
             //$schema->type = null;
411 411
         }else {
412 412
             $schema = new PrimitiveSchemaObject();
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
         } elseif ($itemContainer instanceof ScalarTypeContainer) {
439 439
             $itemSchema = new PrimitiveSchemaObject();
440 440
             $itemSchema->type = self::mapType($itemContainer->getType());
441
-        } else {
441
+        }else {
442 442
             $itemSchema = new PrimitiveSchemaObject();
443 443
             //$itemSchema->type = 'mixed';
444 444
         }
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
                 $propertySchema = $this->getRefSchema($app, $controller, $action, $route, $property->container);
465 465
             } elseif ($property->container instanceof ArrayContainer) {
466 466
                 $propertySchema = $this->getArraySchema($app, $controller, $action, $route, $property->container);
467
-            } else {
467
+            }else {
468 468
                 $propertySchema = new PrimitiveSchemaObject();
469 469
                 $propertySchema->type = self::mapType($property->type);
470 470
                 $propertySchema->description = implode("\n", [$property->summary, $property->description]);
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
      */
485 485
     static public function mapValidation($v, PrimitiveSchemaObject $schemaObject)
486 486
     {
487
-        if(!$v){
487
+        if (!$v) {
488 488
             return $schemaObject;
489 489
         }
490 490
         $rules = explode('|', $v);
@@ -500,15 +500,15 @@  discard block
 block discarded – undo
500 500
             } elseif ($rule == 'lengthBetween' && isset($params[0]) && isset($params[1])) {
501 501
                 $schemaObject->minLength = intval($params[0]);
502 502
                 $schemaObject->maxLength = intval($params[1]);
503
-            } elseif ($rule == 'lengthMin'&& isset($params[0])) {
503
+            } elseif ($rule == 'lengthMin' && isset($params[0])) {
504 504
                 $schemaObject->minLength = intval($params[0]);
505
-            } elseif ($rule == 'lengthMax'&& isset($params[0])) {
505
+            } elseif ($rule == 'lengthMax' && isset($params[0])) {
506 506
                 $schemaObject->maxLength = intval($params[0]);
507
-            } elseif ($rule == 'min'&& isset($params[0])) {
507
+            } elseif ($rule == 'min' && isset($params[0])) {
508 508
                 $schemaObject->minimum = floatval($params[0]);
509
-            } elseif ($rule == 'max'&& isset($params[0])) {
509
+            } elseif ($rule == 'max' && isset($params[0])) {
510 510
                 $schemaObject->maximum = floatval($params[0]);
511
-            } elseif ($rule == 'regex'&& isset($params[0])) {
511
+            } elseif ($rule == 'regex' && isset($params[0])) {
512 512
                 $schemaObject->pattern = $params[0];
513 513
             } elseif ($rule == 'optional') {
514 514
                 $schemaObject->required = false;
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/Lock/FileLock.php 1 patch
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.
src/Lock/LocalAutoLock.php 1 patch
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.
src/Lock/ApcLock.php 1 patch
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.
src/Entity/EntityContainer.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -14,21 +14,21 @@  discard block
 block discarded – undo
14 14
 
15 15
     public function make($data, $validate = true)
16 16
     {
17
-        if($data === null){
17
+        if ($data === null) {
18 18
             return null;
19 19
         }
20 20
         $data instanceof \ArrayAccess || is_array($data) or \PhpBoot\abort(new \InvalidArgumentException("array is required by make {$this->className}, $data given"));
21 21
         $className = $this->getClassName();
22 22
         $obj = new $className();
23 23
         $vld = new Validator();
24
-        foreach ($this->properties as $p){
25
-            if($p->container && isset($data[$p->name])){
24
+        foreach ($this->properties as $p) {
25
+            if ($p->container && isset($data[$p->name])) {
26 26
                 $var = $data[$p->name];
27
-                if($p->container instanceof EntityContainer
28
-                    || $p->container instanceof ArrayContainer){
29
-                    if(!$var){
27
+                if ($p->container instanceof EntityContainer
28
+                    || $p->container instanceof ArrayContainer) {
29
+                    if (!$var) {
30 30
                         $var = [];
31
-                    }elseif(is_string($var)){
31
+                    }elseif (is_string($var)) {
32 32
                         $var = json_decode($var, true);
33 33
                         !json_last_error() or \PhpBoot\abort(new \InvalidArgumentException(__METHOD__.' failed while json_decode with '.json_last_error_msg()));
34 34
                     }
@@ -36,18 +36,18 @@  discard block
 block discarded – undo
36 36
                 $data[$p->name] = $p->container->make($var, $validate);
37 37
             }
38 38
 
39
-            if($p->validation){
40
-                if(is_array($p->validation)){
39
+            if ($p->validation) {
40
+                if (is_array($p->validation)) {
41 41
                     $vld->rule($p->validation[0], $p->name.'.'.$p->validation[1]);
42
-                }else{
42
+                }else {
43 43
                     $vld->rule($p->validation, $p->name);
44 44
                 }
45 45
             }
46
-            if(!$p->isOptional && !$vld->hasRule('optional', $p->name)){
46
+            if (!$p->isOptional && !$vld->hasRule('optional', $p->name)) {
47 47
                 $vld->rule('required', $p->name);
48 48
             }
49 49
         }
50
-        if($validate){
50
+        if ($validate) {
51 51
             $vld = $vld->withData($data);
52 52
             $vld->validate() or \PhpBoot\abort(
53 53
                 new \InvalidArgumentException(
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
             );
60 60
         }
61 61
 
62
-        foreach ($this->properties as $p){
63
-            if(isset($data[$p->name])){
62
+        foreach ($this->properties as $p) {
63
+            if (isset($data[$p->name])) {
64 64
                 $obj->{$p->name} = $data[$p->name];
65 65
             }
66 66
         }
@@ -72,32 +72,32 @@  discard block
 block discarded – undo
72 72
     {
73 73
         $className = $this->getClassName();
74 74
         $obj = new $className();
75
-        foreach ($this->properties as $p){
76
-            if($p->isOptional){
75
+        foreach ($this->properties as $p) {
76
+            if ($p->isOptional) {
77 77
                 $obj->{$p->name} = $p->default;
78
-            }elseif($p->container){
78
+            }elseif ($p->container) {
79 79
                 $var = $p->container->makeExample();
80 80
                 $obj->{$p->name} = $var;
81
-            }else{
81
+            }else {
82 82
                 $obj->{$p->name} = null;
83 83
             }
84 84
 
85 85
         }
86 86
         return $obj;
87 87
     }
88
-    public function getProperty($target){
89
-        if(array_key_exists($target, $this->properties)){
88
+    public function getProperty($target) {
89
+        if (array_key_exists($target, $this->properties)) {
90 90
             return $this->properties[$target];
91 91
         }
92 92
         return null;
93 93
     }
94
-    public function setProperty($target, PropertyMeta $meta){
94
+    public function setProperty($target, PropertyMeta $meta) {
95 95
         $this->properties[$target] = $meta;
96 96
     }
97 97
     /**
98 98
      * @return PropertyMeta[]
99 99
      */
100
-    public function getProperties(){
100
+    public function getProperties() {
101 101
         return $this->properties;
102 102
     }
103 103
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     /**
158 158
      * @var PropertyMeta[]
159 159
      */
160
-    private $properties=[];
160
+    private $properties = [];
161 161
 
162 162
     /**
163 163
      * @var string
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
     /**
168 168
      * @var string
169 169
      */
170
-    private $description='';
170
+    private $description = '';
171 171
     /**
172 172
      * @var string
173 173
      */
174
-    private $summary='';
174
+    private $summary = '';
175 175
 
176 176
     /**
177 177
      * @var string
Please login to merge, or discard this patch.
src/Entity/EntityContainerBuilder.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 class EntityContainerBuilder extends ContainerBuilder
15 15
 {
16
-    static $DEFAULT_ANNOTATIONS=[
16
+    static $DEFAULT_ANNOTATIONS = [
17 17
         [ClassAnnotationHandler::class, 'class'],
18 18
         [PropertyAnnotationHandler::class, 'properties'],
19 19
         [VarAnnotationHandler::class, "properties.*.children[?name=='var'][]"],
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
                                 array $annotations = null
35 35
                                 )
36 36
     {
37
-        if($annotations){
37
+        if ($annotations) {
38 38
             parent::__construct($annotations, $cache);
39
-        }else{
39
+        }else {
40 40
             parent::__construct(self::$DEFAULT_ANNOTATIONS, $cache);
41 41
         }
42 42
         $this->factory = $factory;
Please login to merge, or discard this patch.