@@ -1136,20 +1136,20 @@ |
||
| 1136 | 1136 | $secondQuery = new Query($db); |
| 1137 | 1137 | |
| 1138 | 1138 | $secondQuery->select('id') |
| 1139 | - ->from('TotalTotalExample t2') |
|
| 1140 | - ->where('w > 5'); |
|
| 1139 | + ->from('TotalTotalExample t2') |
|
| 1140 | + ->where('w > 5'); |
|
| 1141 | 1141 | |
| 1142 | 1142 | $thirdQuery = new Query($db); |
| 1143 | 1143 | |
| 1144 | 1144 | $thirdQuery->select('id') |
| 1145 | - ->from('TotalTotalExample t3') |
|
| 1146 | - ->where('w = 3'); |
|
| 1145 | + ->from('TotalTotalExample t3') |
|
| 1146 | + ->where('w = 3'); |
|
| 1147 | 1147 | |
| 1148 | 1148 | $query->select('id') |
| 1149 | - ->from('TotalExample t1') |
|
| 1150 | - ->where(['and', 'w > 0', 'x < 2']) |
|
| 1151 | - ->union($secondQuery) |
|
| 1152 | - ->union($thirdQuery, true); |
|
| 1149 | + ->from('TotalExample t1') |
|
| 1150 | + ->where(['and', 'w > 0', 'x < 2']) |
|
| 1151 | + ->union($secondQuery) |
|
| 1152 | + ->union($thirdQuery, true); |
|
| 1153 | 1153 | |
| 1154 | 1154 | [$actualQuerySql, $queryParams] = $db->getQueryBuilder()->build($query); |
| 1155 | 1155 | |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | $result = (new Query($db))->from('customer') |
| 551 | 551 | ->select(['name', 'id']) |
| 552 | 552 | ->orderBy(['id' => SORT_DESC]) |
| 553 | - ->indexBy(function ($row) { |
|
| 553 | + ->indexBy(function($row) { |
|
| 554 | 554 | return $row['id'] * 2; |
| 555 | 555 | }) |
| 556 | 556 | ->column(); |
@@ -814,7 +814,7 @@ discard block |
||
| 814 | 814 | ); |
| 815 | 815 | |
| 816 | 816 | /* Connection cache */ |
| 817 | - $db->cache(function (ConnectionInterface $db) use ($query, $update) { |
|
| 817 | + $db->cache(function(ConnectionInterface $db) use ($query, $update) { |
|
| 818 | 818 | $this->assertEquals( |
| 819 | 819 | 'user2', |
| 820 | 820 | $query->where(['id' => 2])->scalar(), |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | 'Query does NOT reflect DB changes when wrapped in connection caching' |
| 830 | 830 | ); |
| 831 | 831 | |
| 832 | - $db->noCache(function () use ($query) { |
|
| 832 | + $db->noCache(function() use ($query) { |
|
| 833 | 833 | $this->assertEquals( |
| 834 | 834 | 'user22', |
| 835 | 835 | $query->where(['id' => 2])->scalar(), |
@@ -846,7 +846,7 @@ discard block |
||
| 846 | 846 | |
| 847 | 847 | $this->queryCache->setEnable(false); |
| 848 | 848 | |
| 849 | - $db->cache(function () use ($query, $update) { |
|
| 849 | + $db->cache(function() use ($query, $update) { |
|
| 850 | 850 | $this->assertEquals( |
| 851 | 851 | 'user22', |
| 852 | 852 | $query->where(['id' => 2])->scalar(), |
@@ -877,7 +877,7 @@ discard block |
||
| 877 | 877 | 'When Query has disabled cache, we get actual data' |
| 878 | 878 | ); |
| 879 | 879 | |
| 880 | - $db->cache(function () use ($query) { |
|
| 880 | + $db->cache(function() use ($query) { |
|
| 881 | 881 | $this->assertEquals('user1', $query->noCache()->where(['id' => 1])->scalar()); |
| 882 | 882 | $this->assertEquals('user11', $query->cache()->where(['id' => 1])->scalar()); |
| 883 | 883 | }, 10); |
@@ -310,8 +310,8 @@ |
||
| 310 | 310 | $string = ' DEFAULT '; |
| 311 | 311 | |
| 312 | 312 | $string .= match (gettype($this->default)) { |
| 313 | - 'object', 'integer' => (string)$this->default, |
|
| 314 | - 'double' => NumericHelper::normalize((string)$this->default), |
|
| 313 | + 'object', 'integer' => (string) $this->default, |
|
| 314 | + 'double' => NumericHelper::normalize((string) $this->default), |
|
| 315 | 315 | 'boolean' => $this->default ? 'TRUE' : 'FALSE', |
| 316 | 316 | default => "'{$this->default}'", |
| 317 | 317 | }; |
@@ -235,8 +235,8 @@ |
||
| 235 | 235 | public function dropCommentFromTable(string $table): string |
| 236 | 236 | { |
| 237 | 237 | return 'COMMENT ON TABLE ' |
| 238 | - . $this->quoter->quoteTableName($table) |
|
| 239 | - . ' IS NULL'; |
|
| 238 | + . $this->quoter->quoteTableName($table) |
|
| 239 | + . ' IS NULL'; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -325,7 +325,7 @@ |
||
| 325 | 325 | * |
| 326 | 326 | * @return array column list. |
| 327 | 327 | * @psalm-suppress ReferenceConstraintViolation |
| 328 | - */ |
|
| 328 | + */ |
|
| 329 | 329 | private function getTableUniqueColumnNames(string $name, array $columns, array &$constraints = []): array |
| 330 | 330 | { |
| 331 | 331 | $constraints = []; |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | /** Remove duplicates */ |
| 350 | 350 | $constraints = array_combine( |
| 351 | 351 | array_map( |
| 352 | - static function (Constraint $constraint) { |
|
| 352 | + static function(Constraint $constraint) { |
|
| 353 | 353 | $columns = $constraint->getColumnNames() ?? []; |
| 354 | 354 | $columns = is_array($columns) ? $columns : [$columns]; |
| 355 | 355 | sort($columns, SORT_STRING); |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | $constraints = array_values( |
| 368 | 368 | array_filter( |
| 369 | 369 | $constraints, |
| 370 | - static function (Constraint $constraint) use ($quoter, $columns, &$columnNames) { |
|
| 370 | + static function(Constraint $constraint) use ($quoter, $columns, &$columnNames) { |
|
| 371 | 371 | /** @psalm-var string[]|string */ |
| 372 | 372 | $getColumnNames = $constraint->getColumnNames() ?? []; |
| 373 | 373 | $constraintColumnNames = []; |
@@ -585,7 +585,7 @@ |
||
| 585 | 585 | */ |
| 586 | 586 | protected function hasOffset(mixed $offset): bool |
| 587 | 587 | { |
| 588 | - return ($offset instanceof ExpressionInterface) || (ctype_digit((string)$offset) && (string)$offset !== '0'); |
|
| 588 | + return ($offset instanceof ExpressionInterface) || (ctype_digit((string) $offset) && (string) $offset !== '0'); |
|
| 589 | 589 | } |
| 590 | 590 | |
| 591 | 591 | /** |
@@ -142,7 +142,7 @@ |
||
| 142 | 142 | |
| 143 | 143 | protected function getCacheKey(int $queryMode, string $rawSql): array |
| 144 | 144 | { |
| 145 | - return array_merge([static::class , $queryMode], $this->db->getCacheKey(), [$rawSql]); |
|
| 145 | + return array_merge([static::class, $queryMode], $this->db->getCacheKey(), [$rawSql]); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | |
| 203 | 203 | $this->expectException(Exception::class); |
| 204 | 204 | |
| 205 | - $db->transaction(function () use ($db) { |
|
| 205 | + $db->transaction(function() use ($db) { |
|
| 206 | 206 | $db->createCommand()->insert('profile', ['description' => 'test transaction shortcut'])->execute(); |
| 207 | 207 | throw new Exception('Exception in transaction shortcut'); |
| 208 | 208 | }); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | { |
| 217 | 217 | $db = $this->getConnection(true); |
| 218 | 218 | |
| 219 | - $result = $db->transaction(static function () use ($db) { |
|
| 219 | + $result = $db->transaction(static function() use ($db) { |
|
| 220 | 220 | $db->createCommand()->insert('profile', ['description' => 'test transaction shortcut'])->execute(); |
| 221 | 221 | return true; |
| 222 | 222 | }); |
@@ -239,10 +239,10 @@ discard block |
||
| 239 | 239 | { |
| 240 | 240 | $db = $this->getConnection(); |
| 241 | 241 | |
| 242 | - $db->transaction(function (ConnectionInterface $db) { |
|
| 242 | + $db->transaction(function(ConnectionInterface $db) { |
|
| 243 | 243 | $this->assertNotNull($db->getTransaction()); |
| 244 | 244 | |
| 245 | - $db->transaction(function (ConnectionInterface $db) { |
|
| 245 | + $db->transaction(function(ConnectionInterface $db) { |
|
| 246 | 246 | $transaction = $db->getTransaction(); |
| 247 | 247 | $this->assertNotNull($transaction); |
| 248 | 248 | $transaction->rollBack(); |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | |
| 259 | 259 | $db->setEnableSavepoint(false); |
| 260 | 260 | |
| 261 | - $db->transaction(function (ConnectionInterface $db) { |
|
| 261 | + $db->transaction(function(ConnectionInterface $db) { |
|
| 262 | 262 | $this->assertNotNull($db->getTransaction()); |
| 263 | 263 | $this->expectException(NotSupportedException::class); |
| 264 | 264 | $db->beginTransaction(); |
@@ -33,14 +33,14 @@ discard block |
||
| 33 | 33 | return [ |
| 34 | 34 | 'drop' => [ |
| 35 | 35 | "ALTER TABLE {{{$tableName}}} DROP CONSTRAINT [[$name]]", |
| 36 | - static function (QueryBuilderInterface $qb) use ($tableName, $name) { |
|
| 36 | + static function(QueryBuilderInterface $qb) use ($tableName, $name) { |
|
| 37 | 37 | return $qb->dropForeignKey($name, $tableName); |
| 38 | 38 | }, |
| 39 | 39 | ], |
| 40 | 40 | 'add' => [ |
| 41 | 41 | "ALTER TABLE {{{$tableName}}} ADD CONSTRAINT [[$name]] FOREIGN KEY ([[C_fk_id_1]])" |
| 42 | 42 | . " REFERENCES {{{$pkTableName}}} ([[C_id_1]]) ON DELETE CASCADE ON UPDATE CASCADE", |
| 43 | - static function (QueryBuilderInterface $qb) use ($tableName, $name, $pkTableName) { |
|
| 43 | + static function(QueryBuilderInterface $qb) use ($tableName, $name, $pkTableName) { |
|
| 44 | 44 | return $qb->addForeignKey( |
| 45 | 45 | $name, |
| 46 | 46 | $tableName, |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | 'add (2 columns)' => [ |
| 56 | 56 | "ALTER TABLE {{{$tableName}}} ADD CONSTRAINT [[$name]] FOREIGN KEY ([[C_fk_id_1]], [[C_fk_id_2]])" |
| 57 | 57 | . " REFERENCES {{{$pkTableName}}} ([[C_id_1]], [[C_id_2]]) ON DELETE CASCADE ON UPDATE CASCADE", |
| 58 | - static function (QueryBuilderInterface $qb) use ($tableName, $name, $pkTableName) { |
|
| 58 | + static function(QueryBuilderInterface $qb) use ($tableName, $name, $pkTableName) { |
|
| 59 | 59 | return $qb->addForeignKey( |
| 60 | 60 | $name, |
| 61 | 61 | $tableName, |
@@ -78,19 +78,19 @@ discard block |
||
| 78 | 78 | return [ |
| 79 | 79 | 'drop' => [ |
| 80 | 80 | "ALTER TABLE {{{$tableName}}} DROP CONSTRAINT [[$name]]", |
| 81 | - static function (QueryBuilderInterface $qb) use ($tableName, $name) { |
|
| 81 | + static function(QueryBuilderInterface $qb) use ($tableName, $name) { |
|
| 82 | 82 | return $qb->dropPrimaryKey($name, $tableName); |
| 83 | 83 | }, |
| 84 | 84 | ], |
| 85 | 85 | 'add' => [ |
| 86 | 86 | "ALTER TABLE {{{$tableName}}} ADD CONSTRAINT [[$name]] PRIMARY KEY ([[C_id_1]])", |
| 87 | - static function (QueryBuilderInterface $qb) use ($tableName, $name) { |
|
| 87 | + static function(QueryBuilderInterface $qb) use ($tableName, $name) { |
|
| 88 | 88 | return $qb->addPrimaryKey($name, $tableName, 'C_id_1'); |
| 89 | 89 | }, |
| 90 | 90 | ], |
| 91 | 91 | 'add (2 columns)' => [ |
| 92 | 92 | "ALTER TABLE {{{$tableName}}} ADD CONSTRAINT [[$name]] PRIMARY KEY ([[C_id_1]], [[C_id_2]])", |
| 93 | - static function (QueryBuilderInterface $qb) use ($tableName, $name) { |
|
| 93 | + static function(QueryBuilderInterface $qb) use ($tableName, $name) { |
|
| 94 | 94 | return $qb->addPrimaryKey($name, $tableName, 'C_id_1, C_id_2'); |
| 95 | 95 | }, |
| 96 | 96 | ], |
@@ -107,19 +107,19 @@ discard block |
||
| 107 | 107 | return [ |
| 108 | 108 | 'drop' => [ |
| 109 | 109 | "ALTER TABLE {{{$tableName1}}} DROP CONSTRAINT [[$name1]]", |
| 110 | - static function (QueryBuilderInterface $qb) use ($tableName1, $name1) { |
|
| 110 | + static function(QueryBuilderInterface $qb) use ($tableName1, $name1) { |
|
| 111 | 111 | return $qb->dropUnique($name1, $tableName1); |
| 112 | 112 | }, |
| 113 | 113 | ], |
| 114 | 114 | 'add' => [ |
| 115 | 115 | "ALTER TABLE {{{$tableName1}}} ADD CONSTRAINT [[$name1]] UNIQUE ([[C_unique]])", |
| 116 | - static function (QueryBuilderInterface $qb) use ($tableName1, $name1) { |
|
| 116 | + static function(QueryBuilderInterface $qb) use ($tableName1, $name1) { |
|
| 117 | 117 | return $qb->addUnique($name1, $tableName1, 'C_unique'); |
| 118 | 118 | }, |
| 119 | 119 | ], |
| 120 | 120 | 'add (2 columns)' => [ |
| 121 | 121 | "ALTER TABLE {{{$tableName2}}} ADD CONSTRAINT [[$name2]] UNIQUE ([[C_index_2_1]], [[C_index_2_2]])", |
| 122 | - static function (QueryBuilderInterface $qb) use ($tableName2, $name2) { |
|
| 122 | + static function(QueryBuilderInterface $qb) use ($tableName2, $name2) { |
|
| 123 | 123 | return $qb->addUnique($name2, $tableName2, 'C_index_2_1, C_index_2_2'); |
| 124 | 124 | }, |
| 125 | 125 | ], |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | [':qp0' => 1, |
| 504 | 504 | ':qp1' => 'foo', |
| 505 | 505 | ':qp2' => 2, |
| 506 | - ':qp3' => 'bar',], |
|
| 506 | + ':qp3' => 'bar', ], |
|
| 507 | 507 | ], |
| 508 | 508 | [ |
| 509 | 509 | ['not in', ['id', 'name'], [['id' => 1, 'name' => 'foo'], ['id' => 2, 'name' => 'bar']]], |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | [':qp0' => 1, |
| 512 | 512 | ':qp1' => 'foo', |
| 513 | 513 | ':qp2' => 2, |
| 514 | - ':qp3' => 'bar',], |
|
| 514 | + ':qp3' => 'bar', ], |
|
| 515 | 515 | ], |
| 516 | 516 | //[['in', ['id', 'name'], (new Query())->select(['id', 'name'])->from('users')->where(['active' => 1])], 'EXISTS (SELECT 1 FROM (SELECT [[id]], [[name]] FROM [[users]] WHERE [[active]]=:qp0) AS a WHERE a.[[id]] = [[id AND a.]]name[[ = ]]name`)', [':qp0' => 1] ], |
| 517 | 517 | //[ ['not in', ['id', 'name'], (new Query())->select(['id', 'name'])->from('users')->where(['active' => 1])], 'NOT EXISTS (SELECT 1 FROM (SELECT [[id]], [[name]] FROM [[users]] WHERE [[active]]=:qp0) AS a WHERE a.[[id]] = [[id]] AND a.[[name = ]]name`)', [':qp0' => 1] ], |
@@ -798,31 +798,31 @@ discard block |
||
| 798 | 798 | return [ |
| 799 | 799 | 'drop' => [ |
| 800 | 800 | "DROP INDEX [[$name1]] ON {{{$tableName}}}", |
| 801 | - static function (QueryBuilderInterface $qb) use ($tableName, $name1) { |
|
| 801 | + static function(QueryBuilderInterface $qb) use ($tableName, $name1) { |
|
| 802 | 802 | return $qb->dropIndex($name1, $tableName); |
| 803 | 803 | }, |
| 804 | 804 | ], |
| 805 | 805 | 'create' => [ |
| 806 | 806 | "CREATE INDEX [[$name1]] ON {{{$tableName}}} ([[C_index_1]])", |
| 807 | - static function (QueryBuilderInterface $qb) use ($tableName, $name1) { |
|
| 807 | + static function(QueryBuilderInterface $qb) use ($tableName, $name1) { |
|
| 808 | 808 | return $qb->createIndex($name1, $tableName, 'C_index_1'); |
| 809 | 809 | }, |
| 810 | 810 | ], |
| 811 | 811 | 'create (2 columns)' => [ |
| 812 | 812 | "CREATE INDEX [[$name2]] ON {{{$tableName}}} ([[C_index_2_1]], [[C_index_2_2]])", |
| 813 | - static function (QueryBuilderInterface $qb) use ($tableName, $name2) { |
|
| 813 | + static function(QueryBuilderInterface $qb) use ($tableName, $name2) { |
|
| 814 | 814 | return $qb->createIndex($name2, $tableName, 'C_index_2_1, C_index_2_2'); |
| 815 | 815 | }, |
| 816 | 816 | ], |
| 817 | 817 | 'create unique' => [ |
| 818 | 818 | "CREATE UNIQUE INDEX [[$name1]] ON {{{$tableName}}} ([[C_index_1]])", |
| 819 | - static function (QueryBuilderInterface $qb) use ($tableName, $name1) { |
|
| 819 | + static function(QueryBuilderInterface $qb) use ($tableName, $name1) { |
|
| 820 | 820 | return $qb->createIndex($name1, $tableName, 'C_index_1', QueryBuilder::INDEX_UNIQUE); |
| 821 | 821 | }, |
| 822 | 822 | ], |
| 823 | 823 | 'create unique (2 columns)' => [ |
| 824 | 824 | "CREATE UNIQUE INDEX [[$name2]] ON {{{$tableName}}} ([[C_index_2_1]], [[C_index_2_2]])", |
| 825 | - static function (QueryBuilderInterface $qb) use ($tableName, $name2) { |
|
| 825 | + static function(QueryBuilderInterface $qb) use ($tableName, $name2) { |
|
| 826 | 826 | return $qb->createIndex($name2, $tableName, 'C_index_2_1, C_index_2_2', QueryBuilder::INDEX_UNIQUE); |
| 827 | 827 | }, |
| 828 | 828 | ], |