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 ( 725689...432516 )
by cao
03:37
created
src/Annotation/AnnotationReader.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 }
46 46
 class AnnotationReader implements \ArrayAccess
47 47
 {
48
-    static public function createDocBlockFactory(){
48
+    static public function createDocBlockFactory() {
49 49
         $fqsenResolver = new FqsenResolver();
50
-        $tagFactory = new StandardTagFactory($fqsenResolver,[]);
50
+        $tagFactory = new StandardTagFactory($fqsenResolver, []);
51 51
         $descriptionFactory = new DescriptionFactory($tagFactory);
52 52
         $tagFactory->addService($descriptionFactory);
53 53
         $tagFactory->addService(new TypeResolver($fqsenResolver));
@@ -72,22 +72,22 @@  discard block
 block discarded – undo
72 72
         self::assertAnnotationEnabled();
73 73
         $rfl = new \ReflectionClass($className) or \PhpBoot\abort("load class $className failed");
74 74
         $fileName = $rfl->getFileName();
75
-        $key = str_replace('\\','.',self::class).md5($fileName.$className);
75
+        $key = str_replace('\\', '.', self::class).md5($fileName.$className);
76 76
         $oldData = null;
77
-        $cache = new CheckableCache($localCache?:new ApcCache());
77
+        $cache = new CheckableCache($localCache ?: new ApcCache());
78 78
         $res = $cache->get('ann:'.$key, null, $oldData, false);
79
-        if($res === null){
80
-            try{
79
+        if ($res === null) {
80
+            try {
81 81
                 $meta = self::readWithoutCache($className);
82
-                $cache->set($key, $meta, 0, $fileName?new ClassModifiedChecker($className):null);
82
+                $cache->set($key, $meta, 0, $fileName ? new ClassModifiedChecker($className) : null);
83 83
                 return $meta;
84
-            }catch (\Exception $e){
85
-                $cache->set($key, $e->getMessage(), 0, $fileName?new ClassModifiedChecker($className):null);
84
+            }catch (\Exception $e) {
85
+                $cache->set($key, $e->getMessage(), 0, $fileName ? new ClassModifiedChecker($className) : null);
86 86
                 throw $e;
87 87
             }
88
-        }elseif(is_string($res)){
88
+        }elseif (is_string($res)) {
89 89
             \PhpBoot\abort($res);
90
-        }else{
90
+        }else {
91 91
             return $res;
92 92
         }
93 93
     }
@@ -104,19 +104,19 @@  discard block
 block discarded – undo
104 104
         $reader->class->name = $className;
105 105
 
106 106
         //method annotations
107
-        foreach ($rfl->getMethods() as $i){
107
+        foreach ($rfl->getMethods() as $i) {
108 108
             $block = self::readAnnotationBlock($i->getDocComment());
109 109
             $block->name = $i->getName();
110
-            $reader->methods[$i->getName()]=$block;
110
+            $reader->methods[$i->getName()] = $block;
111 111
         }
112 112
         //property annotations
113
-        foreach ($rfl->getProperties() as $i){
113
+        foreach ($rfl->getProperties() as $i) {
114 114
             if ($i->isStatic()) {
115 115
                 continue;
116 116
             }
117 117
             $block = self::readAnnotationBlock($i->getDocComment());
118 118
             $block->name = $i->getName();
119
-            $reader->properties[$i->getName()]=$block;
119
+            $reader->properties[$i->getName()] = $block;
120 120
         }
121 121
         while ($rfl = $rfl->getParentClass()) {
122 122
             foreach ($rfl->getProperties(\ReflectionProperty::IS_PRIVATE) as $i) {
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
                 }
126 126
                 $block = self::readAnnotationBlock($i->getDocComment());
127 127
                 $block->name = $i->getName();
128
-                $reader->properties[$i->getName()]=$block;
128
+                $reader->properties[$i->getName()] = $block;
129 129
             }
130 130
         }
131 131
         return $reader;
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     static private function readAnnotationBlock($doc)
135 135
     {
136 136
         $annBlock = new AnnotationBlock();
137
-        if(empty($doc)){
137
+        if (empty($doc)) {
138 138
             return $annBlock;
139 139
         }
140 140
         $docFactory = AnnotationReader::createDocBlockFactory();
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
             $annTag->parent = $annBlock;
150 150
             $annTag->description = strval($desc);
151 151
             $annTag->name = $tag->getName();
152
-            $annTag->children=[];
153
-            if($desc){
152
+            $annTag->children = [];
153
+            if ($desc) {
154 154
                 $output = new AnnotationTagsOutput();
155 155
                 $desc->render($output);
156 156
                 foreach ($output->tags as $child) {
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
      * @var AnnotationBlock[]
175 175
      */
176 176
 
177
-    public $methods=[];
177
+    public $methods = [];
178 178
     /**
179 179
      * @var AnnotationBlock[]
180 180
      */
181
-    public $properties=[];
181
+    public $properties = [];
182 182
 
183 183
     public function offsetExists($offset)
184 184
     {
Please login to merge, or discard this patch.
src/Docgen/Swagger/Swagger.php 1 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.
src/Controller/ResponseRenderer.php 1 patch
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.
src/functions.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use PhpBoot\ORM\ModelWithObject;
6 6
 use PhpBoot\Utils\Logger;
7 7
 
8
-if (! function_exists('PhpBoot\abort')) {
8
+if (!function_exists('PhpBoot\abort')) {
9 9
     /**
10 10
      * 抛出异常, 并记录日志
11 11
      * @param string|\Exception $error
@@ -13,29 +13,29 @@  discard block
 block discarded – undo
13 13
      * @param string $level "error"|"warning"|"info"|"debug"|null
14 14
      * @throws \Exception
15 15
      */
16
-    function abort($error = '', $context=[], $level='warning')
16
+    function abort($error = '', $context = [], $level = 'warning')
17 17
     {
18
-        if(is_object($context)){
18
+        if (is_object($context)) {
19 19
             $context = get_object_vars($context);
20 20
         }
21
-        if($error instanceof \Exception){
21
+        if ($error instanceof \Exception) {
22 22
             $e = $error;
23 23
             $message = "exception '".get_class($error)."' with message {$error->getMessage()}";
24
-        }else{
24
+        }else {
25 25
             $e = new \RuntimeException($error);
26 26
             $message = $error;
27 27
         }
28 28
         $trace = $e->getTrace();
29 29
 
30
-        if($e->getFile() == __FILE__){
30
+        if ($e->getFile() == __FILE__) {
31 31
             $file = $trace[0]['file'];
32 32
             $line = $trace[0]['line'];
33
-        }else{
33
+        }else {
34 34
             $file = $e->getFile();
35 35
             $line = $e->getLine();
36 36
         }
37
-        if($level){
38
-           Logger::$level($message, $context +['@file'=>$file, '@line'=>$line]);
37
+        if ($level) {
38
+           Logger::$level($message, $context + ['@file'=>$file, '@line'=>$line]);
39 39
         }
40 40
         throw $e;
41 41
     }
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
      */
62 62
     function models(DB $db, $entity)
63 63
     {
64
-        if(is_object($entity)){
64
+        if (is_object($entity)) {
65 65
             return $db->getApp()->make(ModelWithObject::class, ['db'=>$db, 'entity'=>$entity]);
66
-        }else{
66
+        }else {
67 67
             return $db->getApp()->make(ModelWithClass::class, ['db'=>$db, 'entityName'=>$entity]);
68 68
         }
69 69
     }
Please login to merge, or discard this patch.
src/DB/impls.php 1 patch
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@  discard block
 block discarded – undo
7 7
 use PhpBoot\DB\rules\basic\BasicRule;
8 8
 use PhpBoot\DB\Context;
9 9
 
10
-class ExecResult{
11
-    public function __construct($success, $pdo, $st){
10
+class ExecResult {
11
+    public function __construct($success, $pdo, $st) {
12 12
         $this->pdo = $pdo;
13 13
         $this->st = $st;
14 14
         $this->success = $success;
15 15
         $this->rows = $this->st->rowCount();
16 16
     }
17
-    public function lastInsertId($name=null){
17
+    public function lastInsertId($name = null) {
18 18
         return $this->pdo->lastInsertId($name);
19 19
     }
20 20
     /**
@@ -41,21 +41,21 @@  discard block
 block discarded – undo
41 41
 
42 42
 class SelectImpl
43 43
 {
44
-    static  public function select($context, $columns){
44
+    static  public function select($context, $columns) {
45 45
         $context->appendSql("SELECT $columns");
46 46
     }
47 47
 }
48 48
 
49 49
 class FromImpl
50 50
 {
51
-    static public function from($context, $tables,$as=null){
52
-        if($tables instanceof BasicRule){
51
+    static public function from($context, $tables, $as = null) {
52
+        if ($tables instanceof BasicRule) {
53 53
             $context->appendSql("FROM (".$tables->context->sql.')');
54
-            $context->params = array_merge($context->params,$tables->context->params);
54
+            $context->params = array_merge($context->params, $tables->context->params);
55 55
         }else {
56 56
             $context->appendSql("FROM ".DB::wrap($tables));
57 57
         }
58
-        if($as){
58
+        if ($as) {
59 59
             $context->appendSql("as ".DB::wrap($as));
60 60
         }
61 61
     }
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 {
74 74
     static public function join($context, $type, $table) {
75 75
         $table = DB::wrap($table);
76
-        if($type){
76
+        if ($type) {
77 77
             $context->appendSql("$type JOIN $table");
78
-        }else{
78
+        }else {
79 79
             $context->appendSql("JOIN $table");
80 80
         }
81 81
     }
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
 
91 91
 class ForUpdateImpl
92 92
 {
93
-    static public function forUpdate($context){
93
+    static public function forUpdate($context) {
94 94
         $context->appendSql("FOR UPDATE");
95 95
     }
96 96
 }
97 97
 
98 98
 class ForUpdateOfImpl
99 99
 {
100
-    static public function of($context, $column){
100
+    static public function of($context, $column) {
101 101
         $column = DB::wrap($column);
102 102
         $context->appendSql("OF $column");
103 103
     }
@@ -119,27 +119,27 @@  discard block
 block discarded – undo
119 119
 }
120 120
 class ValuesImpl
121 121
 {
122
-    static public function values($context, $values){
122
+    static public function values($context, $values) {
123 123
         $params = [];
124 124
         $stubs = [];
125
-        foreach ($values as $v){
126
-            if(is_a($v, Raw::class)){//直接拼接sql,不需要转义
127
-                $stubs[]=$v->get();
128
-            }else{
129
-                $stubs[]='?';
125
+        foreach ($values as $v) {
126
+            if (is_a($v, Raw::class)) {//直接拼接sql,不需要转义
127
+                $stubs[] = $v->get();
128
+            }else {
129
+                $stubs[] = '?';
130 130
                 $params[] = $v;
131 131
             }
132 132
         }
133 133
         $stubs = implode(',', $stubs);
134 134
 
135
-        if(array_keys($values) === range(0, count($values) - 1)){
135
+        if (array_keys($values) === range(0, count($values) - 1)) {
136 136
             //VALUES(val0, val1, val2)
137 137
             $context->appendSql("VALUES($stubs)");
138 138
 
139
-        }else{
139
+        }else {
140 140
             //(col0, col1, col2) VALUES(val0, val1, val2)
141
-            $columns = implode(',', array_map(function($k){return DB::wrap($k);}, array_keys($values)));
142
-            $context->appendSql("($columns) VALUES($stubs)",false);
141
+            $columns = implode(',', array_map(function($k) {return DB::wrap($k); }, array_keys($values)));
142
+            $context->appendSql("($columns) VALUES($stubs)", false);
143 143
         }
144 144
         $context->appendParams($params);
145 145
     }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
 class UpdateImpl
150 150
 {
151
-    static public function update($context, $table){
151
+    static public function update($context, $table) {
152 152
         $table = DB::wrap($table);
153 153
         $context->appendSql("UPDATE $table");
154 154
     }
@@ -156,81 +156,81 @@  discard block
 block discarded – undo
156 156
 
157 157
 class UpdateSetImpl
158 158
 {
159
-    public function set(Context $context, $expr, $args){
160
-        if(is_string($expr)){
159
+    public function set(Context $context, $expr, $args) {
160
+        if (is_string($expr)) {
161 161
             return $this->setExpr($context, $expr, $args);
162
-        }else{
162
+        }else {
163 163
             return $this->setArgs($context, $expr);
164 164
         }
165 165
     }
166 166
 
167
-    public function setExpr(Context $context, $expr, $args){
168
-        if($this->first){
167
+    public function setExpr(Context $context, $expr, $args) {
168
+        if ($this->first) {
169 169
             $this->first = false;
170 170
             $prefix = 'SET ';
171
-        }else{
171
+        }else {
172 172
             $prefix = ',';
173 173
         }
174 174
 
175
-        $context->appendSql("$prefix$expr",$prefix == 'SET ');
175
+        $context->appendSql("$prefix$expr", $prefix == 'SET ');
176 176
         $context->appendParams($args);
177 177
 
178 178
     }
179
-    public function setArgs(Context $context, $values){
179
+    public function setArgs(Context $context, $values) {
180 180
         $set = [];
181 181
         $params = [];
182
-        foreach ($values as $k=>$v){
182
+        foreach ($values as $k=>$v) {
183 183
             $k = DB::wrap($k);
184
-            if(is_a($v, Raw::class)){//直接拼接sql,不需要转义
185
-                $set[]= "$k=".$v->get();
186
-            }else{
187
-                $set[]= "$k=?";
188
-                $params[]=$v;
184
+            if (is_a($v, Raw::class)) {//直接拼接sql,不需要转义
185
+                $set[] = "$k=".$v->get();
186
+            }else {
187
+                $set[] = "$k=?";
188
+                $params[] = $v;
189 189
             }
190 190
         }
191
-        if($this->first){
191
+        if ($this->first) {
192 192
             $this->first = false;
193 193
             $context->appendSql('SET '.implode(',', $set));
194 194
             $context->appendParams($params);
195
-        }else{
196
-            $context->appendSql(','.implode(',', $set),false);
195
+        }else {
196
+            $context->appendSql(','.implode(',', $set), false);
197 197
             $context->appendParams($params);
198 198
         }
199 199
     }
200
-    private $first=true;
200
+    private $first = true;
201 201
 }
202 202
 class OrderByImpl
203 203
 {
204
-    public function orderByArgs(Context $context, $orders){
205
-        if(empty($orders)){
204
+    public function orderByArgs(Context $context, $orders) {
205
+        if (empty($orders)) {
206 206
             return $this;
207 207
         }
208 208
         $params = array();
209
-        foreach ($orders as $k=>$v){
210
-            if(is_integer($k)){
209
+        foreach ($orders as $k=>$v) {
210
+            if (is_integer($k)) {
211 211
                 $params[] = DB::wrap($v);
212
-            }else{
212
+            }else {
213 213
                 $k = DB::wrap($k);
214 214
 
215 215
                 $v = strtoupper($v);
216
-                ($v =='DESC' || $v =='ASC') or \PhpBoot\abort( new \InvalidArgumentException("invalid params for orderBy(".json_encode($orders).")"));
216
+                ($v == 'DESC' || $v == 'ASC') or \PhpBoot\abort(new \InvalidArgumentException("invalid params for orderBy(".json_encode($orders).")"));
217 217
 
218 218
                 $params[] = "$k $v";
219 219
             }
220 220
         }
221
-        if($this->first){
221
+        if ($this->first) {
222 222
             $this->first = false;
223 223
             $context->appendSql('ORDER BY '.implode(',', $params));
224
-        }else{
225
-            $context->appendSql(','.implode(',', $params),false);
224
+        }else {
225
+            $context->appendSql(','.implode(',', $params), false);
226 226
         }
227 227
         return $this;
228 228
     }
229
-    public function orderBy(Context $context, $column, $order=null){
230
-        if(is_string($column)){
231
-            if($order === null){
229
+    public function orderBy(Context $context, $column, $order = null) {
230
+        if (is_string($column)) {
231
+            if ($order === null) {
232 232
                 $column = [$column];
233
-            }else{
233
+            }else {
234 234
                 $column = [$column=>$order];
235 235
             }
236 236
         }
@@ -238,18 +238,18 @@  discard block
 block discarded – undo
238 238
 
239 239
 
240 240
     }
241
-    private $first=true;
241
+    private $first = true;
242 242
 }
243 243
 
244 244
 class LimitImpl
245 245
 {
246
-    static public function limit(Context $context, $size){
246
+    static public function limit(Context $context, $size) {
247 247
         $intSize = intval($size);
248 248
         strval($intSize) == $size or \PhpBoot\abort(
249 249
             new \InvalidArgumentException("invalid params for limit($size)"));
250 250
         $context->appendSql("LIMIT $size");
251 251
     }
252
-    static public function limitWithOffset(Context $context, $start, $size){
252
+    static public function limitWithOffset(Context $context, $start, $size) {
253 253
         $intStart = intval($start);
254 254
         $intSize = intval($size);
255 255
         strval($intStart) == $start && strval($intSize) == $size or \PhpBoot\abort(
@@ -258,31 +258,31 @@  discard block
 block discarded – undo
258 258
     }
259 259
 }
260 260
 
261
-class WhereImpl{
261
+class WhereImpl {
262 262
 
263
-    static private function  findQ($str,$offset = 0,$no=0){
263
+    static private function  findQ($str, $offset = 0, $no = 0) {
264 264
         $found = strpos($str, '?', $offset);
265
-        if($no == 0 || $found === false){
265
+        if ($no == 0 || $found === false) {
266 266
             return $found;
267 267
         }
268
-        return self::findQ($str, $found+1, $no-1);
268
+        return self::findQ($str, $found + 1, $no - 1);
269 269
     }
270
-    static public function having(Context $context, $expr, $args){
271
-        if(is_string($expr)){
270
+    static public function having(Context $context, $expr, $args) {
271
+        if (is_string($expr)) {
272 272
             self::condition($context, 'HAVING', $expr, $args);
273
-        }else{
273
+        }else {
274 274
             self::conditionArgs($context, 'HAVING', $expr);
275 275
         }
276 276
         //TODO 支持 OR 、 闭包
277 277
 
278 278
     }
279
-    static public function where(Context $context, $expr, $args){
280
-        if(empty($expr)){
279
+    static public function where(Context $context, $expr, $args) {
280
+        if (empty($expr)) {
281 281
             return;
282 282
         }
283
-        if (is_string($expr)){
283
+        if (is_string($expr)) {
284 284
             self::condition($context, 'WHERE', $expr, $args);
285
-        }else{
285
+        }else {
286 286
             self::conditionArgs($context, 'WHERE', $expr);
287 287
         }
288 288
         //TODO 支持 OR 、 闭包
@@ -309,15 +309,15 @@  discard block
 block discarded – undo
309 309
      * NOT IN   'id'=>['NOT IN' => [1,2,3]]
310 310
      * @return void
311 311
      */
312
-    static public function conditionArgs(Context $context, $prefix, $args=[]){
313
-        if($args ===null){
314
-            return ;
312
+    static public function conditionArgs(Context $context, $prefix, $args = []) {
313
+        if ($args === null) {
314
+            return;
315 315
         }
316 316
         $exprs = array();
317 317
         $params = array();
318
-        foreach ($args as $k => $v){
318
+        foreach ($args as $k => $v) {
319 319
             $k = DB::wrap($k);
320
-            if(is_array($v)){
320
+            if (is_array($v)) {
321 321
                 $ops = ['=', '>', '<', '<>', '>=', '<=', 'IN', 'NOT IN', 'BETWEEN', 'LIKE'];
322 322
                 $op = array_keys($v)[0];
323 323
                 $op = strtoupper($op);
@@ -326,46 +326,46 @@  discard block
 block discarded – undo
326 326
                     new \InvalidArgumentException("invalid param $op for whereArgs"));
327 327
 
328 328
                 $var = array_values($v)[0];
329
-                if($op == 'IN' || $op == 'NOT IN'){
329
+                if ($op == 'IN' || $op == 'NOT IN') {
330 330
                     $stubs = [];
331
-                    foreach ($var as $i){
332
-                        if(is_a($i, Raw::class)){
333
-                            $stubs[]=strval($i);
334
-                        }else{
335
-                            $stubs[]='?';
331
+                    foreach ($var as $i) {
332
+                        if (is_a($i, Raw::class)) {
333
+                            $stubs[] = strval($i);
334
+                        }else {
335
+                            $stubs[] = '?';
336 336
                             $params[] = $i;
337 337
                         }
338 338
                     }
339 339
                     $stubs = implode(',', $stubs);
340 340
                     $exprs[] = "$k $op ($stubs)";
341
-                }else if($op == 'BETWEEN'){
341
+                }else if ($op == 'BETWEEN') {
342 342
                     $cond = "$k BETWEEN";
343
-                    if(is_a($var[0], Raw::class)){
343
+                    if (is_a($var[0], Raw::class)) {
344 344
                         $cond = "$cond ".strval($var[0]);
345
-                    }else{
345
+                    }else {
346 346
                         $cond = "$cond ?";
347 347
                         $params[] = $var[0];
348 348
                     }
349
-                    if(is_a($var[1], Raw::class)){
349
+                    if (is_a($var[1], Raw::class)) {
350 350
                         $cond = "$cond AND ".strval($var[1]);
351
-                    }else{
351
+                    }else {
352 352
                         $cond = "$cond AND ?";
353 353
                         $params[] = $var[1];
354 354
                     }
355 355
                     $exprs[] = $cond;
356
-                }else{
357
-                    if(is_a($var, Raw::class)){
356
+                }else {
357
+                    if (is_a($var, Raw::class)) {
358 358
                         $exprs[] = "$k $op ".strval($var);
359
-                    }else{
359
+                    }else {
360 360
                         $exprs[] = "$k $op ?";
361 361
                         $params[] = $var;
362 362
                     }
363 363
                 }
364
-            }else{
365
-                if(is_a($v, Raw::class)){
364
+            }else {
365
+                if (is_a($v, Raw::class)) {
366 366
                     $exprs[] = "$k = ".strval($v);
367 367
 
368
-                }else{
368
+                }else {
369 369
                     $exprs[] = "$k = ?";
370 370
                     $params[] = $v;
371 371
                 }
@@ -374,20 +374,20 @@  discard block
 block discarded – undo
374 374
 
375 375
         self::condition($context, $prefix, implode(' AND ', $exprs), $params);
376 376
     }
377
-    static public function condition(Context $context, $prefix, $expr, $args){
378
-        if(!empty($expr)){
379
-            if($args){
377
+    static public function condition(Context $context, $prefix, $expr, $args) {
378
+        if (!empty($expr)) {
379
+            if ($args) {
380 380
                 //因为PDO不支持绑定数组变量, 这里需要手动展开数组
381 381
                 //也就是说把 where("id IN(?)", [1,2])  展开成 where("id IN(?,?)", 1,2)
382 382
                 $cutted = null;
383 383
                 $cut = null;
384 384
                 $toReplace = array();
385 385
 
386
-                $newArgs=array();
386
+                $newArgs = array();
387 387
                 //找到所有数组对应的?符位置
388
-                foreach ($args as $k =>$arg){
389
-                    if(is_array($arg) || is_a($arg, Raw::class)){
390
-                        if(!$cutted){
388
+                foreach ($args as $k =>$arg) {
389
+                    if (is_array($arg) || is_a($arg, Raw::class)) {
390
+                        if (!$cutted) {
391 391
                             $cut = new NestedStringCut($expr);
392 392
                             $cutted = $cut->getText();
393 393
                         }
@@ -397,46 +397,46 @@  discard block
 block discarded – undo
397 397
                         $pos !== false or \PhpBoot\abort(
398 398
                             new \InvalidArgumentException("unmatched params and ? @ $expr"));
399 399
 
400
-                        if(is_array($arg)){
400
+                        if (is_array($arg)) {
401 401
                             $stubs = [];
402
-                            foreach ($arg as $i){
403
-                                if(is_a($i, Raw::class)){
402
+                            foreach ($arg as $i) {
403
+                                if (is_a($i, Raw::class)) {
404 404
                                     $stubs[] = strval($i);
405
-                                }else{
405
+                                }else {
406 406
                                     $stubs[] = '?';
407 407
                                     $newArgs[] = $i;
408 408
                                 }
409 409
                             }
410 410
                             $stubs = implode(',', $stubs);
411
-                        }else{
411
+                        }else {
412 412
                             $stubs = strval($arg);
413 413
                         }
414 414
                         $toReplace[] = [$pos, $stubs];
415 415
 
416
-                    }else{
417
-                        $newArgs[]=$arg;
416
+                    }else {
417
+                        $newArgs[] = $arg;
418 418
                     }
419 419
                 }
420 420
 
421
-                if(count($toReplace)){
421
+                if (count($toReplace)) {
422 422
                     $toReplace = array_reverse($toReplace);
423
-                    foreach ($toReplace as $i){
423
+                    foreach ($toReplace as $i) {
424 424
                         list($pos, $v) = $i;
425
-                        $expr = substr($expr, 0, $pos).$v. substr($expr, $pos+1);
425
+                        $expr = substr($expr, 0, $pos).$v.substr($expr, $pos + 1);
426 426
                     }
427 427
                     $args = $newArgs;
428 428
                 }
429 429
             }
430 430
             $context->appendSql($prefix.' '.$expr);
431
-            if($args){
431
+            if ($args) {
432 432
                 $context->appendParams($args);
433 433
             }
434 434
         }
435 435
     }
436 436
 }
437 437
 
438
-class GroupByImpl{
439
-    static public function groupBy(Context $context, $column){
438
+class GroupByImpl {
439
+    static public function groupBy(Context $context, $column) {
440 440
         $column = DB::wrap($column);
441 441
         $context->appendSql("GROUP BY $column");
442 442
     }
@@ -461,20 +461,20 @@  discard block
 block discarded – undo
461 461
      * @param string|false $asDict return  as dict or array
462 462
      * @return false|array
463 463
      */
464
-    static public function get($context, $dictAs=false){
464
+    static public function get($context, $dictAs = false) {
465 465
 
466 466
         $st = $context->connection->prepare($context->sql);
467
-        if($st->execute($context->params)){
467
+        if ($st->execute($context->params)) {
468 468
             $res = $st->fetchAll(\PDO::FETCH_ASSOC);
469
-            if ($dictAs){
470
-                $dict= [];
471
-                foreach ($res as $i){
472
-                    $dict[$i[$dictAs]]=$i;
469
+            if ($dictAs) {
470
+                $dict = [];
471
+                foreach ($res as $i) {
472
+                    $dict[$i[$dictAs]] = $i;
473 473
                 }
474 474
                 return $context->handleResult($dict);
475 475
             }
476 476
             return $context->handleResult($res);
477
-        }else{
477
+        }else {
478 478
             return false;
479 479
         }
480 480
     }
@@ -483,22 +483,22 @@  discard block
 block discarded – undo
483 483
      * @param Context $context
484 484
      * @return int|false
485 485
      */
486
-    static public function count($context){
486
+    static public function count($context) {
487 487
 
488 488
         $found = [];
489
-        if(!preg_match('/\bselect\b/i', $context->sql, $found, PREG_OFFSET_CAPTURE) ||
490
-            count($found)==0){
489
+        if (!preg_match('/\bselect\b/i', $context->sql, $found, PREG_OFFSET_CAPTURE) ||
490
+            count($found) == 0) {
491 491
             \PhpBoot\abort(new \PDOException("can not use count(*) without select"));
492 492
         }
493 493
         list($chars, $columnBegin) = $found[0];
494
-        $columnBegin = $columnBegin + strlen('select')+1;
494
+        $columnBegin = $columnBegin + strlen('select') + 1;
495 495
 
496 496
         $columnEnd = 0;
497 497
         $found = [];
498
-        if(!preg_match('/\bfrom\b/i', $context->sql, $found, PREG_OFFSET_CAPTURE) ||
499
-            count($found)==0){
498
+        if (!preg_match('/\bfrom\b/i', $context->sql, $found, PREG_OFFSET_CAPTURE) ||
499
+            count($found) == 0) {
500 500
             $columnEnd = strlen($context->sql);
501
-        }else{
501
+        }else {
502 502
             list($chars, $columnEnd) = $found[0];
503 503
         }
504 504
         $sql = substr($context->sql, 0, $columnBegin);
@@ -506,10 +506,10 @@  discard block
 block discarded – undo
506 506
         $sql .= substr($context->sql, $columnEnd);
507 507
 
508 508
         $st = $context->connection->prepare($sql);
509
-        if($st->execute($context->params)){
509
+        if ($st->execute($context->params)) {
510 510
             $res = $st->fetchAll(\PDO::FETCH_ASSOC);
511 511
             return $res[0]['count'];
512
-        }else{
512
+        }else {
513 513
             return false;
514 514
         }
515 515
 
@@ -517,47 +517,47 @@  discard block
 block discarded – undo
517 517
 }
518 518
 class OnDuplicateKeyUpdateImpl
519 519
 {
520
-    public function set($context, $column, $value){
521
-        if(is_string($column)){
520
+    public function set($context, $column, $value) {
521
+        if (is_string($column)) {
522 522
             $this->setExpr($context, $column, $value);
523
-        }else{
523
+        }else {
524 524
             $this->setArgs($context, $column);
525 525
         }
526 526
     }
527 527
 
528
-    public function setExpr($context, $expr, $args){
528
+    public function setExpr($context, $expr, $args) {
529 529
         $prefix = '';
530
-        if($this->first){
530
+        if ($this->first) {
531 531
             $this->first = false;
532 532
             $prefix = 'ON DUPLICATE KEY UPDATE ';
533
-        }else{
533
+        }else {
534 534
             $prefix = ',';
535 535
         }
536 536
 
537
-        $context->appendSql("$prefix$expr",$prefix == 'ON DUPLICATE KEY UPDATE ');
537
+        $context->appendSql("$prefix$expr", $prefix == 'ON DUPLICATE KEY UPDATE ');
538 538
         $context->appendParams($args);
539 539
 
540 540
     }
541
-    public function setArgs($context, $values){
541
+    public function setArgs($context, $values) {
542 542
         $set = [];
543 543
         $params = [];
544
-        foreach ($values as $k=>$v){
544
+        foreach ($values as $k=>$v) {
545 545
             $k = DB::wrap($k);
546
-            if(is_a($v, Raw::class)){//直接拼接sql,不需要转义
547
-                $set[]= "$k=".$v->get();
548
-            }else{
549
-                $set[]= "$k=?";
550
-                $params[]=$v;
546
+            if (is_a($v, Raw::class)) {//直接拼接sql,不需要转义
547
+                $set[] = "$k=".$v->get();
548
+            }else {
549
+                $set[] = "$k=?";
550
+                $params[] = $v;
551 551
             }
552 552
         }
553
-        if($this->first){
553
+        if ($this->first) {
554 554
             $this->first = false;
555 555
             $context->appendSql('ON DUPLICATE KEY UPDATE '.implode(',', $set));
556 556
             $context->appendParams($params);
557
-        }else{
558
-            $context->appendSql(','.implode(',', $set),false);
557
+        }else {
558
+            $context->appendSql(','.implode(',', $set), false);
559 559
             $context->appendParams($params);
560 560
         }
561 561
     }
562
-    private $first=true;
562
+    private $first = true;
563 563
 }
Please login to merge, or discard this patch.
src/DB/rules/insert.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@
 block discarded – undo
95 95
      * @param mixed $value
96 96
      * @return \PhpBoot\DB\rules\basic\ExecRule
97 97
      */
98
-    public function onDuplicateKeyUpdate($expr, $_=null) {
98
+    public function onDuplicateKeyUpdate($expr, $_ = null) {
99 99
         $this->impl->set($this->context, $expr, array_slice(func_get_args(), 1));
100 100
         return new ExecRule($this->context);
101 101
     }
Please login to merge, or discard this patch.
src/DB/rules/update.php 1 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
     }
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      * @param mixed $_
38 38
      * @return \PhpBoot\DB\rules\update\UpdateSetRule
39 39
      */
40
-    public function set($expr, $_=null) {
40
+    public function set($expr, $_ = null) {
41 41
         $this->impl->set($this->context, $expr, array_slice(func_get_args(), 1));
42 42
         return $this;
43 43
     }
Please login to merge, or discard this patch.
src/DB/rules/select.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      * @param string|false $asDict
38 38
      * @return array
39 39
      */
40
-    public function get($asDict=false) {
40
+    public function get($asDict = false) {
41 41
         return ExecImpl::get($this->context, $asDict);
42 42
     }
43 43
 
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
      * Execute sql and get one response
52 52
      * @return null
53 53
      */
54
-    public function getFirst(){
54
+    public function getFirst() {
55 55
         $res = ExecImpl::get($this->context);
56
-        if(count($res)){
56
+        if (count($res)) {
57 57
             return $res[0];
58 58
         }
59 59
         return null;
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
      * @param string $table
67 67
      * @return \PhpBoot\DB\rules\select\JoinRule
68 68
      */
69
-    public function from($table, $as=null){
70
-        FromImpl::from($this->context, $table,$as);
69
+    public function from($table, $as = null) {
70
+        FromImpl::from($this->context, $table, $as);
71 71
         return new JoinRule($this->context);
72 72
     }
73 73
 }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      * @param string $column
79 79
      * @return \PhpBoot\DB\rules\select\GetRule
80 80
      */
81
-    public function of($column){
81
+    public function of($column) {
82 82
         ForUpdateOfImpl::of($this->context, $column);
83 83
         return new GetRule($this->context);
84 84
     }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      * forUpdate() => 'FOR UPDATE'
90 90
      * @return \PhpBoot\DB\rules\select\ForUpdateOfRule
91 91
      */
92
-    public function forUpdate(){
92
+    public function forUpdate() {
93 93
         ForUpdateImpl::forUpdate($this->context);
94 94
         return new ForUpdateOfRule($this->context);
95 95
     }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 
112 112
 class OrderByRule extends LimitRule
113 113
 {
114
-    public function __construct($context){
114
+    public function __construct($context) {
115 115
         parent::__construct($context);
116 116
         $this->order = new OrderByImpl();
117 117
     }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      * @param string $order Sql::ORDER_BY_ASC or Sql::ORDER_BY_DESC
127 127
      * @return \PhpBoot\DB\rules\select\OrderByRule
128 128
      */
129
-    public function orderBy($column, $order=null) {
129
+    public function orderBy($column, $order = null) {
130 130
         $this->order->orderBy($this->context, $column, $order);
131 131
         return $this;
132 132
     }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
      * @param string $_
168 168
      * @return \PhpBoot\DB\rules\select\OrderByRule
169 169
      */
170
-    public function having($expr, $_=null) {
170
+    public function having($expr, $_ = null) {
171 171
         WhereImpl::having($this->context, $expr, array_slice(func_get_args(), 1));
172 172
         return new OrderByRule($this->context);
173 173
     }
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
      * @param mixed $_
215 215
      * @return \PhpBoot\DB\rules\select\GroupByRule
216 216
      */
217
-    public function where($conditions=null, $_=null) {
217
+    public function where($conditions = null, $_ = null) {
218 218
         WhereImpl::where($this->context, $conditions, array_slice(func_get_args(), 1));
219 219
         return new GroupByRule($this->context);
220 220
     }
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
      * @param string $table
228 228
      * @return \PhpBoot\DB\rules\select\JoinOnRule
229 229
      */
230
-    public function join($table){
231
-        JoinImpl::join($this->context,null, $table);
230
+    public function join($table) {
231
+        JoinImpl::join($this->context, null, $table);
232 232
         return new JoinOnRule($this->context);
233 233
     }
234 234
     /**
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
      * @param string $table
237 237
      * @return \PhpBoot\DB\rules\select\JoinOnRule
238 238
      */
239
-    public function leftJoin($table){
240
-        JoinImpl::join($this->context,'LEFT', $table);
239
+    public function leftJoin($table) {
240
+        JoinImpl::join($this->context, 'LEFT', $table);
241 241
         return new JoinOnRule($this->context);
242 242
     }
243 243
     /**
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
      * @return \PhpBoot\DB\rules\select\JoinOnRule
247 247
      */
248 248
     public function rightJoin($table) {
249
-        JoinImpl::join($this->context,'RIGHT', $table);
249
+        JoinImpl::join($this->context, 'RIGHT', $table);
250 250
         return new JoinOnRule($this->context);
251 251
     }
252 252
     /**
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
      * @return \PhpBoot\DB\rules\select\JoinOnRule
256 256
      */
257 257
     public function innerJoin($table) {
258
-        JoinImpl::join($this->context,'INNER', $table);
258
+        JoinImpl::join($this->context, 'INNER', $table);
259 259
         return new JoinOnRule($this->context);
260 260
     }
261 261
 }
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
      * @param string $condition
268 268
      * @return \PhpBoot\DB\rules\select\JoinRule
269 269
      */
270
-    public function on($condition){
270
+    public function on($condition) {
271 271
         JoinOnImpl::on($this->context, $condition);
272 272
         return new JoinRule($this->context);
273 273
     }
Please login to merge, or discard this patch.
src/ORM/ModelWithObject.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@  discard block
 block discarded – undo
28 28
     public function create()
29 29
     {
30 30
         $data = [];
31
-        foreach ($this->getColumns() as $column){
32
-            if(isset($this->object->$column)){
33
-                if(is_array($this->object->$column) || is_object($this->object->$column)){
31
+        foreach ($this->getColumns() as $column) {
32
+            if (isset($this->object->$column)) {
33
+                if (is_array($this->object->$column) || is_object($this->object->$column)) {
34 34
                     $data[$column] = json_encode($this->object->$column);
35
-                }else{
35
+                }else {
36 36
                     $data[$column] = $this->object->$column;
37 37
                 }
38 38
 
@@ -48,18 +48,18 @@  discard block
 block discarded – undo
48 48
      * @param array $columns columns to update. if columns is empty array, update all of the columns
49 49
      * @return int rows updated
50 50
      */
51
-    public function update(array $columns=[])
51
+    public function update(array $columns = [])
52 52
     {
53 53
         $data = [];
54 54
         $pk = $this->entity->getPK();
55
-        foreach ($this->getColumns() as $column){
56
-            if(count($columns) && !in_array($column, $columns)){
55
+        foreach ($this->getColumns() as $column) {
56
+            if (count($columns) && !in_array($column, $columns)) {
57 57
                 continue;
58 58
             }
59
-            if($pk != $column && isset($this->object->$column)){
60
-                if(is_array($this->object->$column) || is_object($this->object->$column)){
59
+            if ($pk != $column && isset($this->object->$column)) {
60
+                if (is_array($this->object->$column) || is_object($this->object->$column)) {
61 61
                     $data[$column] = json_encode($this->object->$column);
62
-                }else{
62
+                }else {
63 63
                     $data[$column] = $this->object->$column;
64 64
                 }
65 65
             }
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     protected function getColumns()
86 86
     {
87 87
         $columns = [];
88
-        foreach ($this->entity->getProperties() as $p){
88
+        foreach ($this->entity->getProperties() as $p) {
89 89
             $columns[] = $p->name;
90 90
         }
91 91
         return $columns;
Please login to merge, or discard this patch.