@@ -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 | }; |
@@ -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 | ], |
@@ -398,7 +398,7 @@ |
||
| 398 | 398 | for ($symbol1 = 1; $symbol1 <= 127; $symbol1++) { |
| 399 | 399 | for ($symbol2 = 1; $symbol2 <= 127; $symbol2++) { |
| 400 | 400 | $quotedName = $quoter->quoteValue('test_' . $symbol1 . '_' . $symbol2); |
| 401 | - $testString = str_replace(['{1}', '{2}',], [chr($symbol1), chr($symbol2)], $template); |
|
| 401 | + $testString = str_replace(['{1}', '{2}', ], [chr($symbol1), chr($symbol2)], $template); |
|
| 402 | 402 | |
| 403 | 403 | $quoteValue = $quoter->quoteValue($testString); |
| 404 | 404 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | public function getTableNameParts(string $name): array |
| 35 | 35 | { |
| 36 | 36 | $parts = array_slice(explode('.', $name), -2, 2); |
| 37 | - return array_map(function ($part) { |
|
| 37 | + return array_map(function($part) { |
|
| 38 | 38 | return $this->unquoteSimpleTableName($part); |
| 39 | 39 | }, $parts); |
| 40 | 40 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | { |
| 55 | 55 | if (strrpos($name, '.') !== false) { |
| 56 | 56 | $parts = explode('.', $name); |
| 57 | - $name = $parts[count($parts)-1]; |
|
| 57 | + $name = $parts[count($parts) - 1]; |
|
| 58 | 58 | } |
| 59 | 59 | return preg_replace('|^\[\[([_\w\-. ]+)\]\]$|', '\1', $name); |
| 60 | 60 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | { |
| 107 | 107 | return preg_replace_callback( |
| 108 | 108 | '/({{(%?[\w\-. ]+%?)}}|\\[\\[([\w\-. ]+)]])/', |
| 109 | - function ($matches) { |
|
| 109 | + function($matches) { |
|
| 110 | 110 | if (isset($matches[3])) { |
| 111 | 111 | return $this->quoteColumnName($matches[3]); |
| 112 | 112 | } |