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 ( abbfb3...f4d474 )
by Tarun
03:08
created
console/components/Formatter.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
     public function getTableName($table)
45 45
     {
46
-        return '{{%' . str_replace($this->db->tablePrefix, '', $table->name) . '}}';
46
+        return '{{%'.str_replace($this->db->tablePrefix, '', $table->name).'}}';
47 47
     }
48 48
 
49 49
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     {
53 53
 
54 54
         
55
-        return '$this->batchInsert("{{%test}}", ' . $rows . ', ' . $columns . ');';
55
+        return '$this->batchInsert("{{%test}}", '.$rows.', '.$columns.');';
56 56
     }
57 57
 
58 58
     /**
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
         foreach ($data as $row) {
77 77
             $rows = '';
78 78
             foreach ($row as $value) {
79
-                $rows .= "'" . addslashes($value) . "',";
79
+                $rows .= "'".addslashes($value)."',";
80 80
             }
81
-            self::$rows .= "\n\t\t\t" . self::dataFormat($rows) . ",";
81
+            self::$rows .= "\n\t\t\t".self::dataFormat($rows).",";
82 82
         }
83 83
         if (!empty(self::$rows)) {
84 84
             return self::dataFormat(self::$rows);
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
         if (null !== $trim) {
97 97
             $data = rtrim($data, $trim);
98 98
         }
99
-        return self::$dataEncloser[0] . $data . self::$dataEncloser[1];
99
+        return self::$dataEncloser[0].$data.self::$dataEncloser[1];
100 100
     }
101 101
 
102 102
     /**
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
             $data = rtrim($data, $trim);
111 111
         }
112 112
 
113
-        return self::$columnEncloser[0] . rtrim($data, $trim) . self::$columnEncloser[1];
113
+        return self::$columnEncloser[0].rtrim($data, $trim).self::$columnEncloser[1];
114 114
     }
115 115
 
116 116
     /**
Please login to merge, or discard this patch.
Braces   +23 added lines, -25 removed lines patch added patch discarded remove patch
@@ -5,8 +5,7 @@  discard block
 block discarded – undo
5 5
 /**
6 6
  * Table class
7 7
  */
8
-trait Formatter
9
-{
8
+trait Formatter {
10 9
 
11 10
     /**
12 11
      * @var array column enclosing literal
@@ -41,15 +40,13 @@  discard block
 block discarded – undo
41 40
      * @author Tarun Mukherjee (https://github.com/tmukherjee13)
42 41
      */
43 42
 
44
-    public function getTableName($table)
45
-    {
43
+    public function getTableName($table) {
46 44
         return '{{%' . str_replace($this->db->tablePrefix, '', $table->name) . '}}';
47 45
     }
48 46
 
49 47
 
50 48
     
51
-    public function prepareInsert($rows, $columns)
52
-    {
49
+    public function prepareInsert($rows, $columns) {
53 50
 
54 51
         
55 52
         return '$this->batchInsert("{{%test}}", ' . $rows . ', ' . $columns . ');';
@@ -60,8 +57,7 @@  discard block
 block discarded – undo
60 57
      * @param string $data the column string|$trim the literal to trim
61 58
      * @return string
62 59
      */
63
-    public function prepareColumns($data, $trim = ',')
64
-    {
60
+    public function prepareColumns($data, $trim = ',') {
65 61
         return self::columnFormat($data, $trim);
66 62
     }
67 63
 
@@ -70,8 +66,7 @@  discard block
 block discarded – undo
70 66
      * @param array $data the data array
71 67
      * @return string
72 68
      */
73
-    public function prepareData($data = [])
74
-    {
69
+    public function prepareData($data = []) {
75 70
         self::$rows = '';
76 71
         foreach ($data as $row) {
77 72
             $rows = '';
@@ -91,8 +86,7 @@  discard block
 block discarded – undo
91 86
      * @param string $data the column string|$trim the literal to trim
92 87
      * @return string
93 88
      */
94
-    public function dataFormat($data, $trim = ',')
95
-    {
89
+    public function dataFormat($data, $trim = ',') {
96 90
         if (null !== $trim) {
97 91
             $data = rtrim($data, $trim);
98 92
         }
@@ -104,8 +98,7 @@  discard block
 block discarded – undo
104 98
      * @param string $data the column string|$trim the literal to trim
105 99
      * @return string
106 100
      */
107
-    public function columnFormat($data, $trim = ',')
108
-    {
101
+    public function columnFormat($data, $trim = ',') {
109 102
         if (null !== $trim) {
110 103
             $data = rtrim($data, $trim);
111 104
         }
@@ -122,8 +115,7 @@  discard block
 block discarded – undo
122 115
      * @author Tarun Mukherjee (https://github.com/tmukherjee13)
123 116
      */
124 117
 
125
-    public function getColType($col)
126
-    {
118
+    public function getColType($col) {
127 119
 
128 120
         if ($col->isPrimaryKey && $col->autoIncrement) {
129 121
             return 'pk';
@@ -135,11 +127,14 @@  discard block
 block discarded – undo
135 127
         }
136 128
         if ($col->defaultValue != null && 'timestamp' != $col->dbType) {
137 129
             $result .= " DEFAULT '{$col->defaultValue}'";
138
-        } elseif ($col->defaultValue == 'CURRENT_TIMESTAMP' && 'timestamp' == $col->dbType) {
130
+        }
131
+        elseif ($col->defaultValue == 'CURRENT_TIMESTAMP' && 'timestamp' == $col->dbType) {
139 132
             $result .= " DEFAULT {$col->defaultValue}";
140
-        } elseif ($col->defaultValue != null && 'timestamp' == $col->dbType) {
133
+        }
134
+        elseif ($col->defaultValue != null && 'timestamp' == $col->dbType) {
141 135
             $result .= " DEFAULT '{$col->defaultValue}'";
142
-        } elseif ($col->allowNull) {
136
+        }
137
+        elseif ($col->allowNull) {
143 138
             $result .= ' DEFAULT NULL';
144 139
         }
145 140
         return $result;
@@ -154,19 +149,22 @@  discard block
 block discarded – undo
154 149
      * @author Tarun Mukherjee (https://github.com/tmukherjee13)
155 150
      */
156 151
 
157
-    public function formatCol($col)
158
-    {
152
+    public function formatCol($col) {
159 153
         $decorator = [];
160 154
         if ($col->isPrimaryKey && $col->autoIncrement) {
161 155
             $decorator[] = 'primaryKey';
162
-        } elseif (in_array($col->type, self::$colTypes)) {
156
+        }
157
+        elseif (in_array($col->type, self::$colTypes)) {
163 158
             $decorator[] = "{$col->phpType}";
164
-        } elseif ($col->type == 'decimal') {
159
+        }
160
+        elseif ($col->type == 'decimal') {
165 161
             $decorator[] = "{$col->dbType}";
166
-        } else {
162
+        }
163
+        else {
167 164
             if (!empty($col->size) && $col->size == 1 && $col->type != 'char') {
168 165
                 $column = "boolean";
169
-            } else {
166
+            }
167
+            else {
170 168
                 $column = "{$col->type}";
171 169
                 if (!empty($col->size)) {
172 170
                     $column .= "({$col->size})";
Please login to merge, or discard this patch.
console/controllers/MigrationController.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
                 throw new Exception("The 'db' option must refer to the application component ID of a DB connection.");
79 79
             }
80 80
 
81
-            $path = (string)Yii::getAlias($this->migrationPath);
81
+            $path = (string) Yii::getAlias($this->migrationPath);
82 82
 
83 83
 
84 84
             if (!is_dir($path)) {
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
      */
174 174
     protected function getCreateTableSql($table)
175 175
     {
176
-        $row = $this->db->createCommand('SHOW CREATE TABLE ' . $this->quoteTableName($table->fullName))->queryOne();
176
+        $row = $this->db->createCommand('SHOW CREATE TABLE '.$this->quoteTableName($table->fullName))->queryOne();
177 177
         if (isset($row['Create Table'])) {
178 178
             $sql = $row['Create Table'];
179 179
         } else {
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
     public function actionTable(array $tables)
200 200
     {
201 201
 
202
-        if ($this->confirm('Create the migration ' . "?")) {
202
+        if ($this->confirm('Create the migration '."?")) {
203 203
 
204 204
             foreach ($tables as $key => $tableName) {
205 205
 
206
-                $this->class = 'create_table_' . $tableName;
206
+                $this->class = 'create_table_'.$tableName;
207 207
 
208 208
                 try {
209 209
 
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
                 $this->table = $this->getTableName($table);
229 229
 
230 230
                 foreach ($table->columns as $col) {
231
-                    $up .= "\t\t\t" . '\'' . $col->name . '\'=>"' . $this->getColType($col) . '",' . "\n";
231
+                    $up .= "\t\t\t".'\''.$col->name.'\'=>"'.$this->getColType($col).'",'."\n";
232 232
                     if ($col->isPrimaryKey) {
233 233
                         // Add column to composite primary key array
234 234
                         $compositePrimaryKeyCols[] = $col->name;
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
                 $ukeys = $this->db->schema->findUniqueIndexes($table);
239 239
                 if (!empty($ukeys)) {
240
-                    $indexArr =[];
240
+                    $indexArr = [];
241 241
                     foreach ($ukeys as $key => $value) {
242 242
                         $indexKey = $key;
243 243
                         foreach ($value as $id => $field) {
@@ -245,15 +245,15 @@  discard block
 block discarded – undo
245 245
                         }
246 246
                     }
247 247
                     $indexStr = implode(',', $indexArr);
248
-                    $up .= "\t\t" . '$this->createIndex(\'idx_' . $indexKey . "', '" . $this->getTableName($table) . "', '$indexStr', TRUE);\n";
248
+                    $up .= "\t\t".'$this->createIndex(\'idx_'.$indexKey."', '".$this->getTableName($table)."', '$indexStr', TRUE);\n";
249 249
 
250 250
                 }
251 251
 
252 252
                 if (!empty($table->foreignKeys)):
253 253
 
254 254
                     foreach ($table->foreignKeys as $fkName => $fk) {
255
-                        $addForeignKeys .= "\t\t" . '$this->addForeignKey("' . $fkName . '", "' . $table->name . '", "' . $fk['column'] . '","' . $fk['table'] . '","' . $fk['ref_column'] . '", "' . $fk['delete'] . '", "' . $fk['update'] . '");' . "\n";
256
-                        $dropForeignKeys .= '$this->dropForeignKey(' . "'$fkName', '$table->name');";
255
+                        $addForeignKeys .= "\t\t".'$this->addForeignKey("'.$fkName.'", "'.$table->name.'", "'.$fk['column'].'","'.$fk['table'].'","'.$fk['ref_column'].'", "'.$fk['delete'].'", "'.$fk['update'].'");'."\n";
256
+                        $dropForeignKeys .= '$this->dropForeignKey('."'$fkName', '$table->name');";
257 257
                     }
258 258
 
259 259
                 endif;
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 
263 263
                 $fields = $this->parseFields();
264 264
 
265
-                $this->prepareFile(['up' => '', 'down' => '', 'foreignKeys' => $table->foreignKeys, 'fields' => $fields]) . "\n\n";
265
+                $this->prepareFile(['up' => '', 'down' => '', 'foreignKeys' => $table->foreignKeys, 'fields' => $fields])."\n\n";
266 266
 
267 267
             }
268 268
 
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
     public function actionData(array $tables)
279 279
     {
280 280
 
281
-        if ($this->confirm('Create the migration ' . "?", true)) {
281
+        if ($this->confirm('Create the migration '."?", true)) {
282 282
             foreach ($tables as $key => $args) {
283 283
 
284 284
                 $table              = $args;
285
-                $this->class        = 'insert_data_into_' . $table;
285
+                $this->class        = 'insert_data_into_'.$table;
286 286
                 $this->table        = $table;
287 287
                 $this->templateFile = '@tmukherjee13/migration/views/dataTemplate.php';
288 288
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 
311 311
                     $pcolumns = '';
312 312
                     foreach ($columns->columns as $column) {
313
-                        $pcolumns .= "'" . $column->name . "',";
313
+                        $pcolumns .= "'".$column->name."',";
314 314
                     }
315 315
                     foreach ($data as $row) {
316 316
                         array_push($prepared_data, $row);
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
     {
343 343
 
344 344
         $schema      = $args;
345
-        $this->class = 'dump_database_' . $schema;
345
+        $this->class = 'dump_database_'.$schema;
346 346
 
347 347
         // $tables = $this->db->schema->getTableNames($schema);
348 348
 
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
         $generateTables  = [];
358 358
 
359 359
         foreach ($tables as $table) {
360
-            if ($table->name === $this->db->tablePrefix . $this->migrationTable) {
360
+            if ($table->name === $this->db->tablePrefix.$this->migrationTable) {
361 361
                 continue;
362 362
             }
363 363
             $generateTables[] = $table->name;
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 
370 370
     public function getFileName()
371 371
     {
372
-        return 'm' . gmdate('ymd_His') . '_' . $this->class;
372
+        return 'm'.gmdate('ymd_His').'_'.$this->class;
373 373
     }
374 374
 
375 375
     public function setFileName()
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 
380 380
     public function prepareFile($data)
381 381
     {
382
-        $file = $this->migrationPath . DIRECTORY_SEPARATOR . $this->getFileName() . '.php';
382
+        $file = $this->migrationPath.DIRECTORY_SEPARATOR.$this->getFileName().'.php';
383 383
         try {
384 384
 
385 385
             $data['table']     = $this->table;
Please login to merge, or discard this patch.
Braces   +20 added lines, -34 removed lines patch added patch discarded remove patch
@@ -9,8 +9,7 @@  discard block
 block discarded – undo
9 9
 use yii\helpers\Console;
10 10
 use yii\helpers\FileHelper;
11 11
 
12
-class MigrationController extends BaseMigrateController
13
-{
12
+class MigrationController extends BaseMigrateController {
14 13
     use \tmukherjee13\migration\console\components\Formatter;
15 14
 
16 15
     /**
@@ -59,16 +58,14 @@  discard block
 block discarded – undo
59 58
     /**
60 59
      * @inheritdoc
61 60
      */
62
-    public function options($actionID)
63
-    {
61
+    public function options($actionID) {
64 62
         return array_merge(parent::options($actionID), ['migrationTable', 'db']);
65 63
     }
66 64
 
67 65
     /**
68 66
      * @inheritdoc
69 67
      */
70
-    public function beforeAction($action)
71
-    {
68
+    public function beforeAction($action) {
72 69
 
73 70
         if (parent::beforeAction($action)) {
74 71
             if (is_string($this->db)) {
@@ -102,8 +99,7 @@  discard block
 block discarded – undo
102 99
      * Collects the foreign key column details for the given table.
103 100
      * @param TableSchema $table the table metadata
104 101
      */
105
-    protected function findConstraints($table)
106
-    {
102
+    protected function findConstraints($table) {
107 103
         $sql = <<<SQL
108 104
             SELECT
109 105
                 kcu.constraint_name,
@@ -171,20 +167,19 @@  discard block
 block discarded – undo
171 167
      * @param TableSchema $table the table metadata
172 168
      * @return string $sql the result of 'SHOW CREATE TABLE'
173 169
      */
174
-    protected function getCreateTableSql($table)
175
-    {
170
+    protected function getCreateTableSql($table) {
176 171
         $row = $this->db->createCommand('SHOW CREATE TABLE ' . $this->quoteTableName($table->fullName))->queryOne();
177 172
         if (isset($row['Create Table'])) {
178 173
             $sql = $row['Create Table'];
179
-        } else {
174
+        }
175
+        else {
180 176
             $row = array_values($row);
181 177
             $sql = $row[1];
182 178
         }
183 179
         return $sql;
184 180
     }
185 181
 
186
-    public function quoteTableName($name)
187
-    {
182
+    public function quoteTableName($name) {
188 183
         return strpos($name, '`') !== false ? $name : "`$name`";
189 184
     }
190 185
 
@@ -196,8 +191,7 @@  discard block
 block discarded – undo
196 191
      * @author Tarun Mukherjee (https://github.com/tmukherjee13)
197 192
      */
198 193
 
199
-    public function actionTable(array $tables)
200
-    {
194
+    public function actionTable(array $tables) {
201 195
 
202 196
         if ($this->confirm('Create the migration ' . "?")) {
203 197
 
@@ -275,8 +269,7 @@  discard block
 block discarded – undo
275 269
      * @param array $tables the list of tables
276 270
      * @return integer|null
277 271
      */
278
-    public function actionData(array $tables)
279
-    {
272
+    public function actionData(array $tables) {
280 273
 
281 274
         if ($this->confirm('Create the migration ' . "?", true)) {
282 275
             foreach ($tables as $key => $args) {
@@ -318,7 +311,8 @@  discard block
 block discarded – undo
318 311
 
319 312
                     if (empty($prepared_data)) {
320 313
                         $this->stdout("\nTable '{$table->name}' doesn't contain any data.\n\n", Console::FG_RED);
321
-                    } else {
314
+                    }
315
+                    else {
322 316
                         $pcolumns = $this->prepareColumns($pcolumns);
323 317
                         $prows    = $this->prepareData($prepared_data);
324 318
 
@@ -338,8 +332,7 @@  discard block
 block discarded – undo
338 332
      * @param string $args the schema name
339 333
      * @return integer
340 334
      */
341
-    public function actionSchema($args)
342
-    {
335
+    public function actionSchema($args) {
343 336
 
344 337
         $schema      = $args;
345 338
         $this->class = 'dump_database_' . $schema;
@@ -367,18 +360,15 @@  discard block
 block discarded – undo
367 360
 
368 361
     }
369 362
 
370
-    public function getFileName()
371
-    {
363
+    public function getFileName() {
372 364
         return 'm' . gmdate('ymd_His') . '_' . $this->class;
373 365
     }
374 366
 
375
-    public function setFileName()
376
-    {
367
+    public function setFileName() {
377 368
         $this->fileName = $this->getFileName();
378 369
     }
379 370
 
380
-    public function prepareFile($data)
381
-    {
371
+    public function prepareFile($data) {
382 372
         $file = $this->migrationPath . DIRECTORY_SEPARATOR . $this->getFileName() . '.php';
383 373
         try {
384 374
 
@@ -398,8 +388,7 @@  discard block
 block discarded – undo
398 388
     /**
399 389
      * @inheritdoc
400 390
      */
401
-    protected function getMigrationHistory($limit)
402
-    {
391
+    protected function getMigrationHistory($limit) {
403 392
         if ($this->db->schema->getTableSchema($this->migrationTable, true) === null) {
404 393
             $this->createMigrationHistoryTable();
405 394
         }
@@ -419,8 +408,7 @@  discard block
 block discarded – undo
419 408
     /**
420 409
      * @inheritdoc
421 410
      */
422
-    protected function addMigrationHistory($version)
423
-    {
411
+    protected function addMigrationHistory($version) {
424 412
         $command = $this->db->createCommand();
425 413
         $command->insert($this->migrationTable, [
426 414
             'version'    => $version,
@@ -431,8 +419,7 @@  discard block
 block discarded – undo
431 419
     /**
432 420
      * @inheritdoc
433 421
      */
434
-    protected function removeMigrationHistory($version)
435
-    {
422
+    protected function removeMigrationHistory($version) {
436 423
         $command = $this->db->createCommand();
437 424
         $command->delete($this->migrationTable, [
438 425
             'version' => $version,
@@ -442,8 +429,7 @@  discard block
 block discarded – undo
442 429
     /**
443 430
      * @inheritdoc
444 431
      */
445
-    protected function parseFields()
446
-    {
432
+    protected function parseFields() {
447 433
         $fields = [];
448 434
 
449 435
         foreach ($this->fields as $column => $schema) {
Please login to merge, or discard this patch.
views/_createTable.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,9 +13,11 @@
 block discarded – undo
13 13
     if (empty($field['decorators'])): ?>
14 14
             '<?= $field['property'] ?>',
15 15
 
16
-<?php else: ?>
16
+<?php else {
17
+    : ?>
17 18
             <?= "'{$field['property']}' => \$this->{$field['decorators']}" ?>,
18 19
 <?php endif;
20
+}
19 21
 
20 22
 endforeach; ?>
21 23
 
Please login to merge, or discard this patch.