Completed
Push — master ( 29a552...19e08f )
by Edgard
33:14 queued 31:36
created
src/DataReader.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
     /**
33 33
      * Returns a single column from the next row of a result set.
34 34
      * @param integer $columnIndex zero-based column index
35
-     * @return mixed the column of the current row, false if no more rows available
35
+     * @return string|false the column of the current row, false if no more rows available
36 36
      */
37 37
     public function readColumn($columnIndex)
38 38
     {
Please login to merge, or discard this patch.
src/QueryBuilder.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@
 block discarded – undo
146 146
             $orderByStatment = $this->buildOrderBy($newOrderBy);
147 147
 
148 148
             $sql = str_replace(':order', $orderByStatment,$sql);
149
-        }else{
149
+        } else{
150 150
             $orderByStatment = $this->buildOrderBy($orderBy);
151 151
             if ($orderByStatment !== '') {
152 152
                 $sql .= $this->separator . $orderByStatment;
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
     {
59 59
         $table = $this->db->getTableSchema($tableName);
60 60
 
61
-        if ($table !== null && isset($table->columns[$table->sequenceName])) {
61
+        if ($table !== null && isset($table->columns[ $table->sequenceName ])) {
62 62
             if ($value === null) {
63
-                $sql = 'SELECT MAX("'. $table->sequenceName .'") FROM "'. $tableName . '"';
63
+                $sql = 'SELECT MAX("' . $table->sequenceName . '") FROM "' . $tableName . '"';
64 64
                 $value = $this->db->createCommand($sql)->queryScalar() + 1;
65 65
             } else {
66 66
                 $value = (int) $value;
67 67
             }
68
-            return 'ALTER TABLE "' . $tableName . '" ALTER COLUMN "'.$table->sequenceName.'" RESTART WITH ' . $value;
68
+            return 'ALTER TABLE "' . $tableName . '" ALTER COLUMN "' . $table->sequenceName . '" RESTART WITH ' . $value;
69 69
         } elseif ($table === null) {
70 70
             throw new InvalidParamException("Table not found: $tableName");
71 71
         } else {
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     public function checkIntegrity($check = true, $schema = '', $table = '')
86 86
     {
87 87
         if ($table) {
88
-            $tableNames = [$table];
88
+            $tableNames = [ $table ];
89 89
         } else {
90 90
             if (!$schema) {
91 91
                 $schema = $this->db->defaultSchema;
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
             return '';
119 119
         }
120 120
 
121
-        $quotedTableNames = [];
121
+        $quotedTableNames = [ ];
122 122
         foreach ($tableNames as $tableName) {
123
-            $quotedTableNames[] = $this->db->quoteTableName($tableName) . ($check? '' : ' ALL');
123
+            $quotedTableNames[ ] = $this->db->quoteTableName($tableName) . ($check ? '' : ' ALL');
124 124
         }
125 125
 
126 126
         $enable = $check ? 'CHECKED' : 'UNCHECKED';
127
-        return 'SET INTEGRITY FOR ' . implode(', ', $quotedTableNames) . ' IMMEDIATE ' . $enable. ';';
127
+        return 'SET INTEGRITY FOR ' . implode(', ', $quotedTableNames) . ' IMMEDIATE ' . $enable . ';';
128 128
     }
129 129
 
130 130
     /**
@@ -137,22 +137,22 @@  discard block
 block discarded – undo
137 137
             $sql = str_replace(':query', $sql, $limitOffsetStatment);
138 138
 
139 139
             //convert "item"."id" to "id" to use in OVER()
140
-            $newOrderBy = [];
140
+            $newOrderBy = [ ];
141 141
 
142
-            if(!empty($orderBy)){
142
+            if (!empty($orderBy)) {
143 143
                 foreach ($orderBy as $name => $direction) {
144
-                    if(is_string($name)){
144
+                    if (is_string($name)) {
145 145
                         $e = explode('.', $name);
146 146
                         $name = array_pop($e);
147 147
                     }
148
-                    $newOrderBy[$name] = $direction;
148
+                    $newOrderBy[ $name ] = $direction;
149 149
                 }
150 150
             }
151 151
 
152 152
             $orderByStatment = $this->buildOrderBy($newOrderBy);
153 153
 
154
-            $sql = str_replace(':order', $orderByStatment,$sql);
155
-        }else{
154
+            $sql = str_replace(':order', $orderByStatment, $sql);
155
+        } else {
156 156
             $orderByStatment = $this->buildOrderBy($orderBy);
157 157
             if ($orderByStatment !== '') {
158 158
                 $sql .= $this->separator . $orderByStatment;
@@ -196,24 +196,24 @@  discard block
 block discarded – undo
196 196
      */
197 197
     protected function buildCompositeInCondition($operator, $columns, $values, &$params)
198 198
     {
199
-        $vss = [];
199
+        $vss = [ ];
200 200
         foreach ($values as $value) {
201
-            $vs = [];
201
+            $vs = [ ];
202 202
             foreach ($columns as $column) {
203
-                if (isset($value[$column])) {
203
+                if (isset($value[ $column ])) {
204 204
                     $phName = self::PARAM_PREFIX . count($params);
205
-                    $params[$phName] = $value[$column];
206
-                    $vs[] = $phName;
205
+                    $params[ $phName ] = $value[ $column ];
206
+                    $vs[ ] = $phName;
207 207
                 } else {
208
-                    $vs[] = 'NULL';
208
+                    $vs[ ] = 'NULL';
209 209
                 }
210 210
             }
211
-            $vss[] = 'select ' . implode(', ', $vs) . ' from SYSIBM.SYSDUMMY1';
211
+            $vss[ ] = 'select ' . implode(', ', $vs) . ' from SYSIBM.SYSDUMMY1';
212 212
         }
213 213
 
214
-        $sqlColumns = [];
214
+        $sqlColumns = [ ];
215 215
         foreach ($columns as $i => $column) {
216
-            $sqlColumns[] = strpos($column, '(') === false ? $this->db->quoteColumnName($column) : $column;
216
+            $sqlColumns[ ] = strpos($column, '(') === false ? $this->db->quoteColumnName($column) : $column;
217 217
         }
218 218
 
219 219
         return '(' . implode(', ', $sqlColumns) . ") $operator (" . implode(' UNION ', $vss) . ')';
@@ -228,21 +228,21 @@  discard block
 block discarded – undo
228 228
         if (($tableSchema = $schema->getTableSchema($table)) !== null) {
229 229
             $columnSchemas = $tableSchema->columns;
230 230
         } else {
231
-            $columnSchemas = [];
231
+            $columnSchemas = [ ];
232 232
         }
233
-        $names = [];
234
-        $placeholders = [];
233
+        $names = [ ];
234
+        $placeholders = [ ];
235 235
         foreach ($columns as $name => $value) {
236
-            $names[] = $schema->quoteColumnName($name);
236
+            $names[ ] = $schema->quoteColumnName($name);
237 237
             if ($value instanceof Expression) {
238
-                $placeholders[] = $value->expression;
238
+                $placeholders[ ] = $value->expression;
239 239
                 foreach ($value->params as $n => $v) {
240
-                    $params[$n] = $v;
240
+                    $params[ $n ] = $v;
241 241
                 }
242 242
             } else {
243 243
                 $phName = self::PARAM_PREFIX . count($params);
244
-                $placeholders[] = $phName;
245
-                $params[$phName] = !is_array($value) && isset($columnSchemas[$name]) ? $columnSchemas[$name]->dbTypecast($value) : $value;
244
+                $placeholders[ ] = $phName;
245
+                $params[ $phName ] = !is_array($value) && isset($columnSchemas[ $name ]) ? $columnSchemas[ $name ]->dbTypecast($value) : $value;
246 246
             }
247 247
         }
248 248
 
Please login to merge, or discard this patch.
src/Schema.php 4 patches
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
     protected function resolveTableNames($table, $name)
147 147
     {
148 148
         $parts = explode('.', str_replace('"', '', $name));
149
-        if (isset($parts[1])) {
150
-            $table->schemaName = $parts[0];
151
-            $table->name = $parts[1];
149
+        if (isset($parts[ 1 ])) {
150
+            $table->schemaName = $parts[ 0 ];
151
+            $table->name = $parts[ 1 ];
152 152
             $table->fullName = $table->schemaName . '.' . $table->name;
153 153
         } else {
154
-            $table->fullName = $table->name = $parts[0];
154
+            $table->fullName = $table->name = $parts[ 0 ];
155 155
         }
156 156
     }
157 157
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         ];
174 174
         $type = gettype($data);
175 175
 
176
-        return isset($typeMap[$type]) ? $typeMap[$type] : PDO::PARAM_STR;
176
+        return isset($typeMap[ $type ]) ? $typeMap[ $type ] : PDO::PARAM_STR;
177 177
     }
178 178
 
179 179
     /**
@@ -183,24 +183,24 @@  discard block
 block discarded – undo
183 183
     {
184 184
         $column = $this->createColumnSchema();
185 185
 
186
-        $column->name = $info['name'];
187
-        $column->dbType = $info['dbtype'];
188
-        $column->defaultValue = isset($info['defaultvalue']) ? trim($info['defaultvalue'], "''") : null;
189
-        $column->scale = (int) $info['scale'];
190
-        $column->size = (int) $info['size'];
191
-        $column->precision = (int) $info['size'];
192
-        $column->allowNull = $info['allownull'] === '1';
193
-        $column->isPrimaryKey = $info['isprimarykey'] === '1';
194
-        $column->autoIncrement = $info['autoincrement'] === '1';
186
+        $column->name = $info[ 'name' ];
187
+        $column->dbType = $info[ 'dbtype' ];
188
+        $column->defaultValue = isset($info[ 'defaultvalue' ]) ? trim($info[ 'defaultvalue' ], "''") : null;
189
+        $column->scale = (int) $info[ 'scale' ];
190
+        $column->size = (int) $info[ 'size' ];
191
+        $column->precision = (int) $info[ 'size' ];
192
+        $column->allowNull = $info[ 'allownull' ] === '1';
193
+        $column->isPrimaryKey = $info[ 'isprimarykey' ] === '1';
194
+        $column->autoIncrement = $info[ 'autoincrement' ] === '1';
195 195
         $column->unsigned = false;
196
-        $column->type = $this->typeMap[strtolower($info['dbtype'])];
196
+        $column->type = $this->typeMap[ strtolower($info[ 'dbtype' ]) ];
197 197
         $column->enumValues = null;
198
-        $column->comment = isset($info['comment']) ? $info['comment'] : null;
198
+        $column->comment = isset($info[ 'comment' ]) ? $info[ 'comment' ] : null;
199 199
 
200
-        if (preg_match('/(varchar|character|clob|graphic|binary|blob)/i', $info['dbtype'])) {
201
-            $column->dbType .= '(' . $info['size'] . ')';
202
-        } elseif (preg_match('/(decimal|double|real)/i', $info['dbtype'])) {
203
-            $column->dbType .= '(' . $info['size'] . ',' . $info['scale'] . ')';
200
+        if (preg_match('/(varchar|character|clob|graphic|binary|blob)/i', $info[ 'dbtype' ])) {
201
+            $column->dbType .= '(' . $info[ 'size' ] . ')';
202
+        } elseif (preg_match('/(decimal|double|real)/i', $info[ 'dbtype' ])) {
203
+            $column->dbType .= '(' . $info[ 'size' ] . ',' . $info[ 'scale' ] . ')';
204 204
         }
205 205
 
206 206
         if ($column->defaultValue) {
@@ -274,11 +274,11 @@  discard block
 block discarded – undo
274 274
 
275 275
         $command = $this->db->createCommand($sql);
276 276
         $command->bindValue(':table', $table->name);
277
-        if($this->db->isISeries){
277
+        if ($this->db->isISeries) {
278 278
             $command->bindValue(':schema', $this->db->defaultSchema);
279 279
             $command->bindValue(':table1', $table->name);
280 280
 
281
-        }else {
281
+        } else {
282 282
             if (isset($table->schemaName)) {
283 283
                 $command->bindValue(':schema', $table->schemaName);
284 284
             }
@@ -293,9 +293,9 @@  discard block
 block discarded – undo
293 293
                 $info = array_change_key_case($info, CASE_LOWER);
294 294
             }
295 295
             $column = $this->loadColumnSchema($info);
296
-            $table->columns[$column->name] = $column;
296
+            $table->columns[ $column->name ] = $column;
297 297
             if ($column->isPrimaryKey) {
298
-                $table->primaryKey[] = $column->name;
298
+                $table->primaryKey[ ] = $column->name;
299 299
                 if ($column->autoIncrement) {
300 300
                     $table->sequenceName = $column->name;
301 301
                 }
@@ -351,31 +351,31 @@  discard block
 block discarded – undo
351 351
         }
352 352
         $command = $this->db->createCommand($sql);
353 353
         $command->bindValue(':table', $table->name);
354
-        if($this->db->isISeries){
354
+        if ($this->db->isISeries) {
355 355
             $command->bindValue(':schema', $this->db->defaultSchema);
356
-        }else {
356
+        } else {
357 357
             if (isset($table->schemaName)) {
358 358
                 $command->bindValue(':schema', $table->schemaName);
359 359
             }
360 360
         }
361 361
 
362 362
         $results = $command->queryAll();
363
-        $foreignKeys = [];
363
+        $foreignKeys = [ ];
364 364
         foreach ($results as $result) {
365 365
             if ($this->db->slavePdo->getAttribute(PDO::ATTR_CASE) !== PDO::CASE_LOWER) {
366 366
                 $result = array_change_key_case($result, CASE_LOWER);
367 367
             }
368
-            $tablename = $result['tablename'];
369
-            $fk = $result['fk'];
370
-            $pk = $result['pk'];
371
-            $foreignKeys[$tablename][$fk] = $pk;
368
+            $tablename = $result[ 'tablename' ];
369
+            $fk = $result[ 'fk' ];
370
+            $pk = $result[ 'pk' ];
371
+            $foreignKeys[ $tablename ][ $fk ] = $pk;
372 372
         }
373 373
         foreach ($foreignKeys as $tablename => $keymap) {
374
-            $constraint = [$tablename];
374
+            $constraint = [ $tablename ];
375 375
             foreach ($keymap as $fk => $pk) {
376
-                $constraint[$fk] = $pk;
376
+                $constraint[ $fk ] = $pk;
377 377
             }
378
-            $table->foreignKeys[] = $constraint;
378
+            $table->foreignKeys[ ] = $constraint;
379 379
         }
380 380
     }
381 381
 
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
                   AND qsys2.syscst.table_schema = :schema
401 401
                   ORDER BY qsys2.syskeycst.column_position
402 402
 SQL;
403
-        }else {
403
+        } else {
404 404
             $sql = <<<SQL
405 405
             SELECT
406 406
                 i.indname AS indexname,
@@ -422,20 +422,20 @@  discard block
 block discarded – undo
422 422
         $command = $this->db->createCommand($sql);
423 423
         $command->bindValue(':table', $table->name);
424 424
 
425
-        if($this->db->isISeries){
425
+        if ($this->db->isISeries) {
426 426
             $command->bindValue(':schema', $this->db->defaultSchema);
427
-        }else{
427
+        } else {
428 428
             if (isset($table->schemaName)) {
429 429
                 $command->bindValue(':schema', $table->schemaName);
430 430
             }
431 431
         }
432 432
         $results = $command->queryAll();
433
-        $indexes = [];
433
+        $indexes = [ ];
434 434
         foreach ($results as $result) {
435 435
             if ($this->db->slavePdo->getAttribute(PDO::ATTR_CASE) !== PDO::CASE_LOWER) {
436 436
                 $result = array_change_key_case($result, CASE_LOWER);
437 437
             }
438
-            $indexes[$result['indexname']][] = $result['column'];
438
+            $indexes[ $result[ 'indexname' ] ][ ] = $result[ 'column' ];
439 439
         }
440 440
         return $indexes;
441 441
     }
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
     {
448 448
 
449 449
         if ($schema === '' && $this->db->isISeries) {
450
-                $schema= $this->db->defaultSchema;
450
+                $schema = $this->db->defaultSchema;
451 451
         }
452 452
 
453 453
         if ($this->db->isISeries) {
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
                   AND TABLE_SCHEMA = :schema
460 460
                 ORDER BY TABLE_NAME
461 461
 SQL;
462
-        }else {
462
+        } else {
463 463
 
464 464
             $sql = <<<SQL
465 465
             SELECT
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
             $this->db->createCommand($sql)->execute();
539 539
         } catch (\Exception $ex) {
540 540
             // Do not throw error on table which doesn't exist
541
-            if (!(isset($ex->errorInfo[1]) && $ex->errorInfo[1] === -2211)) {
541
+            if (!(isset($ex->errorInfo[ 1 ]) && $ex->errorInfo[ 1 ] === -2211)) {
542 542
                 throw new \Exception($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
543 543
             }
544 544
         }
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
             $command->bindValue(':schema', $this->db->defaultSchema);
279 279
             $command->bindValue(':table1', $table->name);
280 280
 
281
-        }else {
281
+        } else {
282 282
             if (isset($table->schemaName)) {
283 283
                 $command->bindValue(':schema', $table->schemaName);
284 284
             }
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
         $command->bindValue(':table', $table->name);
354 354
         if($this->db->isISeries){
355 355
             $command->bindValue(':schema', $this->db->defaultSchema);
356
-        }else {
356
+        } else {
357 357
             if (isset($table->schemaName)) {
358 358
                 $command->bindValue(':schema', $table->schemaName);
359 359
             }
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
                   AND qsys2.syscst.table_schema = :schema
401 401
                   ORDER BY qsys2.syskeycst.column_position
402 402
 SQL;
403
-        }else {
403
+        } else {
404 404
             $sql = <<<SQL
405 405
             SELECT
406 406
                 i.indname AS indexname,
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 
425 425
         if($this->db->isISeries){
426 426
             $command->bindValue(':schema', $this->db->defaultSchema);
427
-        }else{
427
+        } else{
428 428
             if (isset($table->schemaName)) {
429 429
                 $command->bindValue(':schema', $table->schemaName);
430 430
             }
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
                   AND TABLE_SCHEMA = :schema
460 460
                 ORDER BY TABLE_NAME
461 461
 SQL;
462
-        }else {
462
+        } else {
463 463
 
464 464
             $sql = <<<SQL
465 465
             SELECT
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
         'timestmp'   => self::TYPE_TIMESTAMP
55 55
     ];
56 56
 
57
-   /**
57
+    /**
58 58
      * @inheritdoc
59 59
      */
60 60
     public function createQueryBuilder()
Please login to merge, or discard this patch.
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -96,6 +96,8 @@  discard block
 block discarded – undo
96 96
 
97 97
     /**
98 98
      * @inheritdoc
99
+     * @param TableSchema $table
100
+     * @param string $name
99 101
      */
100 102
     protected function resolveTableNames($table, $name)
101 103
     {
@@ -170,6 +172,7 @@  discard block
 block discarded – undo
170 172
 
171 173
     /**
172 174
      * @inheritdoc
175
+     * @param TableSchema $table
173 176
      */
174 177
     protected function findColumns($table)
175 178
     {
@@ -260,6 +263,7 @@  discard block
 block discarded – undo
260 263
 
261 264
     /**
262 265
      * @inheritdoc
266
+     * @param TableSchema $table
263 267
      */
264 268
     protected function findConstraints($table)
265 269
     {
Please login to merge, or discard this patch.
src/Connection.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     {
74 74
         parent::initConnection();
75 75
 
76
-        if($this->isISeries === null){
76
+        if ($this->isISeries === null) {
77 77
             try {
78 78
                 $stmt = $this->pdo->query('SELECT * FROM QSYS2.SYSTABLES FETCH FIRST 1 ROW ONLY');
79 79
                 $this->isISeries = boolval($stmt);
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             }
83 83
         }
84 84
 
85
-        if($this->defaultSchema && !$this->isISeries){
85
+        if ($this->defaultSchema && !$this->isISeries) {
86 86
             $this->pdo->exec('SET CURRENT SCHEMA ' . $this->pdo->quote($this->defaultSchema));
87 87
         }
88 88
         
Please login to merge, or discard this patch.