Passed
Push — dev ( 6277c8...732a36 )
by 世昌
02:37
created
suda/src/application/database/TableCreator.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 abstract class TableCreator
13 13
 {
14 14
     protected static $map = [
15
-      'mysql' => MySQLTableCreator::class,
15
+        'mysql' => MySQLTableCreator::class,
16 16
     ];
17 17
 
18 18
     abstract function create(Connection $connection, TableStruct $fields);
Please login to merge, or discard this patch.
suda/src/application/database/creator/MySQLTableCreator.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
         $table = $this->fields->getRealTableName($this->connection);
99 99
         $sql = "CREATE TABLE IF NOT EXISTS `{$table}` (\r\n\t";
100 100
         $sql .= implode(",\r\n\t", array_filter($content, 'strlen'));
101
-        $auto = null === $this->auto?'':'AUTO_INCREMENT='.$this->auto;
102
-        $collate = null === $this->collate?'':'COLLATE '.$this->collate;
101
+        $auto = null === $this->auto ? '' : 'AUTO_INCREMENT='.$this->auto;
102
+        $collate = null === $this->collate ? '' : 'COLLATE '.$this->collate;
103 103
         $sql .= "\r\n) ENGINE={$this->engine} {$collate} {$auto} DEFAULT CHARSET={$this->charset};";
104 104
         return $sql;
105 105
     }
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
             }
118 118
         }
119 119
         if (count($primary)) {
120
-            return 'PRIMARY KEY ('. implode(',', $primary).')';
120
+            return 'PRIMARY KEY ('.implode(',', $primary).')';
121 121
         }
122 122
         return  '';
123 123
     }
@@ -210,10 +210,10 @@  discard block
 block discarded – undo
210 210
     protected function createField(Field $field)
211 211
     {
212 212
         $type = strtoupper($field->getValueType()).$this->parseLength($field->getLength());
213
-        $auto = $field->getAuto() ?'AUTO_INCREMENT':'';
214
-        $null = $field->isNullable() === null? '': $field->isNullable() === true ? 'NULL':'NOT NULL';
215
-        $attr = $field->getAttribute() ?strtoupper($field->getAttribute()):'';
216
-        $comment = $field->getComment() ?('COMMENT \''.addcslashes($field->getComment(), '\'').'\''):'';
213
+        $auto = $field->getAuto() ? 'AUTO_INCREMENT' : '';
214
+        $null = $field->isNullable() === null ? '' : $field->isNullable() === true ? 'NULL' : 'NOT NULL';
215
+        $attr = $field->getAttribute() ?strtoupper($field->getAttribute()) : '';
216
+        $comment = $field->getComment() ? ('COMMENT \''.addcslashes($field->getComment(), '\'').'\'') : '';
217 217
         // default设置
218 218
         if ($field->hasDefault()) {
219 219
             if (null === $field->getDefault()) {
Please login to merge, or discard this patch.
suda/src/database/statement/ReadStatement.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
     protected function whereStringArray(string $where, array $whereBinder)
198 198
     {
199 199
         [$where, $whereBinder] = $this->prepareWhereString($where, $whereBinder);
200
-        $this->where = 'WHERE ' . $where;
200
+        $this->where = 'WHERE '.$where;
201 201
         $this->binder = $this->mergeBinder($this->binder, $whereBinder);
202 202
     }
203 203
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
     public function groupBy(string $what)
211 211
     {
212 212
         $what = $this->middleware->inputName($what);
213
-        $this->groupBy = 'GROUP BY `' . $what . '`';
213
+        $this->groupBy = 'GROUP BY `'.$what.'`';
214 214
         return $this;
215 215
     }
216 216
 
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
     protected function havingStringArray(string $having, array $havingBinder)
254 254
     {
255 255
         [$having, $havingBinder] = $this->prepareWhereString($having, $havingBinder);
256
-        $this->having = 'HAVING ' . $having;
256
+        $this->having = 'HAVING '.$having;
257 257
         $this->binder = $this->mergeBinder($this->binder, $havingBinder);
258 258
     }
259 259
 
@@ -269,9 +269,9 @@  discard block
 block discarded – undo
269 269
         $what = $this->middleware->inputName($what);
270 270
         $order = strtoupper($order);
271 271
         if (strlen($this->orderBy) > 0) {
272
-            $this->orderBy .= ',`' . $what . '` ' . $order;
272
+            $this->orderBy .= ',`'.$what.'` '.$order;
273 273
         } else {
274
-            $this->orderBy = 'ORDER BY `' . $what . '` ' . $order;
274
+            $this->orderBy = 'ORDER BY `'.$what.'` '.$order;
275 275
         }
276 276
         return $this;
277 277
     }
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
      */
294 294
     public function limit(int $start, int $length = null)
295 295
     {
296
-        $this->limit = 'LIMIT ' . $start . ($length !== null ? ',' . $length : '');
296
+        $this->limit = 'LIMIT '.$start.($length !== null ? ','.$length : '');
297 297
         return $this;
298 298
     }
299 299
 
Please login to merge, or discard this patch.
suda/src/database/statement/WherePrepareTrait.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     public function prepareQueryMark(string $sql, array $parameter)
22 22
     {
23 23
         $binders = [];
24
-        $query = preg_replace_callback('/\?/', function ($match) use (&$binders, $parameter) {
24
+        $query = preg_replace_callback('/\?/', function($match) use (&$binders, $parameter) {
25 25
             $index = count($binders);
26 26
             if (array_key_exists($index, $parameter)) {
27 27
                 $name = Binder::index($index);
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
                 } else {
33 33
                     $binder = new Binder($name, $parameter[$index]);
34 34
                     $binders[] = $binder;
35
-                    return ':' . $binder->getName();
35
+                    return ':'.$binder->getName();
36 36
                 }
37 37
             }
38 38
             return $match[0];
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
     public function prepareInParameter($values, string $name)
51 51
     {
52 52
         if ($this->countObject($values) <= 0) {
53
-            throw new SQLException('on field ' . $name . ' value can\'t be empty array');
53
+            throw new SQLException('on field '.$name.' value can\'t be empty array');
54 54
         }
55 55
         $names = [];
56 56
         $binders = [];
57 57
         foreach ($values as $value) {
58 58
             $_name = Binder::index($name);
59 59
             $binders[] = new Binder($_name, $value);
60
-            $names[] = ':' . $_name;
60
+            $names[] = ':'.$_name;
61 61
         }
62 62
         return [implode(',', $names), $binders];
63 63
     }
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
     public function createQueryOperation(string $name, string $operator, $value, string $indexName = '')
86 86
     {
87 87
         if ($value instanceof Query) {
88
-            return new Query("`{$name}` {$operator} " . $value, $value->getBinder());
88
+            return new Query("`{$name}` {$operator} ".$value, $value->getBinder());
89 89
         }
90 90
         if ($value instanceof Statement) {
91
-            return new Query("`{$name}` {$operator} (" . $value->getQuery() . ')', $value->getBinder());
91
+            return new Query("`{$name}` {$operator} (".$value->getQuery().')', $value->getBinder());
92 92
         }
93 93
         if ($value instanceof IteratorAggregate || is_array($value)) {
94 94
             return $this->prepareIn($name, $operator, $value);
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
             return $this->createQueryOperation($name, 'in', $values);
230 230
         }
231 231
         [$inSQL, $binders] = $this->prepareInParameter($values, $name);
232
-        $sql = '`' . $name . '` ' . strtoupper($operation) . ' (' . $inSQL . ')';
232
+        $sql = '`'.$name.'` '.strtoupper($operation).' ('.$inSQL.')';
233 233
         return new Query($sql, $binders);
234 234
     }
235 235
 
@@ -244,6 +244,6 @@  discard block
 block discarded – undo
244 244
     public function replaceQuote(string $name, string $replace, string $target)
245 245
     {
246 246
         $name = ltrim($name, ':');
247
-        return preg_replace('/(?<!_):' . preg_quote($name) . '/', $replace, $target);
247
+        return preg_replace('/(?<!_):'.preg_quote($name).'/', $replace, $target);
248 248
     }
249 249
 }
Please login to merge, or discard this patch.
suda/src/application/database/Database.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@
 block discarded – undo
81 81
         if (array_key_exists($groupName, static::$dataSource)) {
82 82
             return static::$dataSource[$groupName];
83 83
         }
84
-        $group = $groupName === 'default' ? '': '-'. $groupName;
84
+        $group = $groupName === 'default' ? '' : '-'.$groupName;
85 85
         $dataSourceConfigPath = $resource->getConfigResourcePath('config/data-source'.$group);
86 86
         $dataSource = new DataSource;
87 87
         if ($dataSourceConfigPath !== null) {
Please login to merge, or discard this patch.