@@ -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); |
@@ -1146,20 +1146,20 @@ |
||
1146 | 1146 | $secondQuery = new Query($db); |
1147 | 1147 | |
1148 | 1148 | $secondQuery->select('id') |
1149 | - ->from('TotalTotalExample t2') |
|
1150 | - ->where('w > 5'); |
|
1149 | + ->from('TotalTotalExample t2') |
|
1150 | + ->where('w > 5'); |
|
1151 | 1151 | |
1152 | 1152 | $thirdQuery = new Query($db); |
1153 | 1153 | |
1154 | 1154 | $thirdQuery->select('id') |
1155 | - ->from('TotalTotalExample t3') |
|
1156 | - ->where('w = 3'); |
|
1155 | + ->from('TotalTotalExample t3') |
|
1156 | + ->where('w = 3'); |
|
1157 | 1157 | |
1158 | 1158 | $query->select('id') |
1159 | - ->from('TotalExample t1') |
|
1160 | - ->where(['and', 'w > 0', 'x < 2']) |
|
1161 | - ->union($secondQuery) |
|
1162 | - ->union($thirdQuery, true); |
|
1159 | + ->from('TotalExample t1') |
|
1160 | + ->where(['and', 'w > 0', 'x < 2']) |
|
1161 | + ->union($secondQuery) |
|
1162 | + ->union($thirdQuery, true); |
|
1163 | 1163 | |
1164 | 1164 | [$actualQuerySql, $queryParams] = $this->getQueryBuilder()->build($query); |
1165 | 1165 |
@@ -1562,13 +1562,13 @@ discard block |
||
1562 | 1562 | return [ |
1563 | 1563 | 'drop' => [ |
1564 | 1564 | "ALTER TABLE {{{$tableName}}} DROP CONSTRAINT [[$name]]", |
1565 | - static function (QueryBuilder $qb) use ($tableName, $name) { |
|
1565 | + static function(QueryBuilder $qb) use ($tableName, $name) { |
|
1566 | 1566 | return $qb->dropCheck($name, $tableName); |
1567 | 1567 | }, |
1568 | 1568 | ], |
1569 | 1569 | 'add' => [ |
1570 | 1570 | "ALTER TABLE {{{$tableName}}} ADD CONSTRAINT [[$name]] CHECK ([[C_not_null]] > 100)", |
1571 | - static function (QueryBuilder $qb) use ($tableName, $name) { |
|
1571 | + static function(QueryBuilder $qb) use ($tableName, $name) { |
|
1572 | 1572 | return $qb->addCheck($name, $tableName, '[[C_not_null]] > 100'); |
1573 | 1573 | }, |
1574 | 1574 | ], |
@@ -1584,14 +1584,14 @@ discard block |
||
1584 | 1584 | return [ |
1585 | 1585 | 'drop' => [ |
1586 | 1586 | "ALTER TABLE {{{$tableName}}} DROP CONSTRAINT [[$name]]", |
1587 | - static function (QueryBuilder $qb) use ($tableName, $name) { |
|
1587 | + static function(QueryBuilder $qb) use ($tableName, $name) { |
|
1588 | 1588 | return $qb->dropForeignKey($name, $tableName); |
1589 | 1589 | }, |
1590 | 1590 | ], |
1591 | 1591 | 'add' => [ |
1592 | 1592 | "ALTER TABLE {{{$tableName}}} ADD CONSTRAINT [[$name]] FOREIGN KEY ([[C_fk_id_1]])" |
1593 | 1593 | . " REFERENCES {{{$pkTableName}}} ([[C_id_1]]) ON DELETE CASCADE ON UPDATE CASCADE", |
1594 | - static function (QueryBuilder $qb) use ($tableName, $name, $pkTableName) { |
|
1594 | + static function(QueryBuilder $qb) use ($tableName, $name, $pkTableName) { |
|
1595 | 1595 | return $qb->addForeignKey( |
1596 | 1596 | $name, |
1597 | 1597 | $tableName, |
@@ -1606,7 +1606,7 @@ discard block |
||
1606 | 1606 | 'add (2 columns)' => [ |
1607 | 1607 | "ALTER TABLE {{{$tableName}}} ADD CONSTRAINT [[$name]] FOREIGN KEY ([[C_fk_id_1]], [[C_fk_id_2]])" |
1608 | 1608 | . " REFERENCES {{{$pkTableName}}} ([[C_id_1]], [[C_id_2]]) ON DELETE CASCADE ON UPDATE CASCADE", |
1609 | - static function (QueryBuilder $qb) use ($tableName, $name, $pkTableName) { |
|
1609 | + static function(QueryBuilder $qb) use ($tableName, $name, $pkTableName) { |
|
1610 | 1610 | return $qb->addForeignKey( |
1611 | 1611 | $name, |
1612 | 1612 | $tableName, |
@@ -1629,19 +1629,19 @@ discard block |
||
1629 | 1629 | return [ |
1630 | 1630 | 'drop' => [ |
1631 | 1631 | "ALTER TABLE {{{$tableName}}} DROP CONSTRAINT [[$name]]", |
1632 | - static function (QueryBuilder $qb) use ($tableName, $name) { |
|
1632 | + static function(QueryBuilder $qb) use ($tableName, $name) { |
|
1633 | 1633 | return $qb->dropPrimaryKey($name, $tableName); |
1634 | 1634 | }, |
1635 | 1635 | ], |
1636 | 1636 | 'add' => [ |
1637 | 1637 | "ALTER TABLE {{{$tableName}}} ADD CONSTRAINT [[$name]] PRIMARY KEY ([[C_id_1]])", |
1638 | - static function (QueryBuilder $qb) use ($tableName, $name) { |
|
1638 | + static function(QueryBuilder $qb) use ($tableName, $name) { |
|
1639 | 1639 | return $qb->addPrimaryKey($name, $tableName, 'C_id_1'); |
1640 | 1640 | }, |
1641 | 1641 | ], |
1642 | 1642 | 'add (2 columns)' => [ |
1643 | 1643 | "ALTER TABLE {{{$tableName}}} ADD CONSTRAINT [[$name]] PRIMARY KEY ([[C_id_1]], [[C_id_2]])", |
1644 | - static function (QueryBuilder $qb) use ($tableName, $name) { |
|
1644 | + static function(QueryBuilder $qb) use ($tableName, $name) { |
|
1645 | 1645 | return $qb->addPrimaryKey($name, $tableName, 'C_id_1, C_id_2'); |
1646 | 1646 | }, |
1647 | 1647 | ], |
@@ -1658,19 +1658,19 @@ discard block |
||
1658 | 1658 | return [ |
1659 | 1659 | 'drop' => [ |
1660 | 1660 | "ALTER TABLE {{{$tableName1}}} DROP CONSTRAINT [[$name1]]", |
1661 | - static function (QueryBuilder $qb) use ($tableName1, $name1) { |
|
1661 | + static function(QueryBuilder $qb) use ($tableName1, $name1) { |
|
1662 | 1662 | return $qb->dropUnique($name1, $tableName1); |
1663 | 1663 | }, |
1664 | 1664 | ], |
1665 | 1665 | 'add' => [ |
1666 | 1666 | "ALTER TABLE {{{$tableName1}}} ADD CONSTRAINT [[$name1]] UNIQUE ([[C_unique]])", |
1667 | - static function (QueryBuilder $qb) use ($tableName1, $name1) { |
|
1667 | + static function(QueryBuilder $qb) use ($tableName1, $name1) { |
|
1668 | 1668 | return $qb->addUnique($name1, $tableName1, 'C_unique'); |
1669 | 1669 | }, |
1670 | 1670 | ], |
1671 | 1671 | 'add (2 columns)' => [ |
1672 | 1672 | "ALTER TABLE {{{$tableName2}}} ADD CONSTRAINT [[$name2]] UNIQUE ([[C_index_2_1]], [[C_index_2_2]])", |
1673 | - static function (QueryBuilder $qb) use ($tableName2, $name2) { |
|
1673 | + static function(QueryBuilder $qb) use ($tableName2, $name2) { |
|
1674 | 1674 | return $qb->addUnique($name2, $tableName2, 'C_index_2_1, C_index_2_2'); |
1675 | 1675 | }, |
1676 | 1676 | ], |
@@ -2348,31 +2348,31 @@ discard block |
||
2348 | 2348 | return [ |
2349 | 2349 | 'drop' => [ |
2350 | 2350 | "DROP INDEX [[$name1]] ON {{{$tableName}}}", |
2351 | - static function (QueryBuilder $qb) use ($tableName, $name1) { |
|
2351 | + static function(QueryBuilder $qb) use ($tableName, $name1) { |
|
2352 | 2352 | return $qb->dropIndex($name1, $tableName); |
2353 | 2353 | }, |
2354 | 2354 | ], |
2355 | 2355 | 'create' => [ |
2356 | 2356 | "CREATE INDEX [[$name1]] ON {{{$tableName}}} ([[C_index_1]])", |
2357 | - static function (QueryBuilder $qb) use ($tableName, $name1) { |
|
2357 | + static function(QueryBuilder $qb) use ($tableName, $name1) { |
|
2358 | 2358 | return $qb->createIndex($name1, $tableName, 'C_index_1'); |
2359 | 2359 | }, |
2360 | 2360 | ], |
2361 | 2361 | 'create (2 columns)' => [ |
2362 | 2362 | "CREATE INDEX [[$name2]] ON {{{$tableName}}} ([[C_index_2_1]], [[C_index_2_2]])", |
2363 | - static function (QueryBuilder $qb) use ($tableName, $name2) { |
|
2363 | + static function(QueryBuilder $qb) use ($tableName, $name2) { |
|
2364 | 2364 | return $qb->createIndex($name2, $tableName, 'C_index_2_1, C_index_2_2'); |
2365 | 2365 | }, |
2366 | 2366 | ], |
2367 | 2367 | 'create unique' => [ |
2368 | 2368 | "CREATE UNIQUE INDEX [[$name1]] ON {{{$tableName}}} ([[C_index_1]])", |
2369 | - static function (QueryBuilder $qb) use ($tableName, $name1) { |
|
2369 | + static function(QueryBuilder $qb) use ($tableName, $name1) { |
|
2370 | 2370 | return $qb->createIndex($name1, $tableName, 'C_index_1', true); |
2371 | 2371 | }, |
2372 | 2372 | ], |
2373 | 2373 | 'create unique (2 columns)' => [ |
2374 | 2374 | "CREATE UNIQUE INDEX [[$name2]] ON {{{$tableName}}} ([[C_index_2_1]], [[C_index_2_2]])", |
2375 | - static function (QueryBuilder $qb) use ($tableName, $name2) { |
|
2375 | + static function(QueryBuilder $qb) use ($tableName, $name2) { |
|
2376 | 2376 | return $qb->createIndex($name2, $tableName, 'C_index_2_1, C_index_2_2', true); |
2377 | 2377 | }, |
2378 | 2378 | ], |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | $this->expectException(Exception::class); |
97 | 97 | |
98 | - $db->transaction(function () use ($db) { |
|
98 | + $db->transaction(function() use ($db) { |
|
99 | 99 | $db->createCommand()->insert('profile', ['description' => 'test transaction shortcut'])->execute(); |
100 | 100 | throw new Exception('Exception in transaction shortcut'); |
101 | 101 | }); |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | { |
110 | 110 | $db = $this->getConnection(true); |
111 | 111 | |
112 | - $result = $db->transaction(static function () use ($db) { |
|
112 | + $result = $db->transaction(static function() use ($db) { |
|
113 | 113 | $db->createCommand()->insert('profile', ['description' => 'test transaction shortcut'])->execute(); |
114 | 114 | return true; |
115 | 115 | }); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | { |
128 | 128 | $db = $this->getConnection(true); |
129 | 129 | |
130 | - $result = $db->transaction(static function (ConnectionInterface $db) { |
|
130 | + $result = $db->transaction(static function(ConnectionInterface $db) { |
|
131 | 131 | $db->createCommand()->insert('profile', ['description' => 'test transaction shortcut'])->execute(); |
132 | 132 | return true; |
133 | 133 | }, Transaction::READ_UNCOMMITTED); |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | { |
151 | 151 | $db = $this->getConnection(); |
152 | 152 | |
153 | - $db->transaction(function (ConnectionInterface $db) { |
|
153 | + $db->transaction(function(ConnectionInterface $db) { |
|
154 | 154 | $this->assertNotNull($db->getTransaction()); |
155 | 155 | |
156 | - $db->transaction(function (ConnectionInterface $db) { |
|
156 | + $db->transaction(function(ConnectionInterface $db) { |
|
157 | 157 | $this->assertNotNull($db->getTransaction()); |
158 | 158 | $db->getTransaction()->rollBack(); |
159 | 159 | }); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | |
169 | 169 | $db->setEnableSavepoint(false); |
170 | 170 | |
171 | - $db->transaction(function (ConnectionInterface $db) { |
|
171 | + $db->transaction(function(ConnectionInterface $db) { |
|
172 | 172 | $this->assertNotNull($db->getTransaction()); |
173 | 173 | $this->expectException(NotSupportedException::class); |
174 | 174 | $db->beginTransaction(); |
@@ -30,7 +30,7 @@ |
||
30 | 30 | */ |
31 | 31 | public function toString(): string |
32 | 32 | { |
33 | - $allowedValues = array_map(static function ($value) { |
|
33 | + $allowedValues = array_map(static function($value) { |
|
34 | 34 | return VarDumper::create($value)->asString(); |
35 | 35 | }, $this->allowedValues); |
36 | 36 |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | |
252 | 252 | public function testBatchInsertWithYield(): void |
253 | 253 | { |
254 | - $rows = (static function () { |
|
254 | + $rows = (static function() { |
|
255 | 255 | if (false) { |
256 | 256 | yield []; |
257 | 257 | } |
@@ -894,14 +894,14 @@ discard block |
||
894 | 894 | |
895 | 895 | $this->assertEquals('user11', $command->bindValue(':id', 1)->queryScalar()); |
896 | 896 | |
897 | - $db->cache(function (ConnectionInterface $db) use ($command, $update) { |
|
897 | + $db->cache(function(ConnectionInterface $db) use ($command, $update) { |
|
898 | 898 | $this->assertEquals('user2', $command->bindValue(':id', 2)->queryScalar()); |
899 | 899 | |
900 | 900 | $update->bindValues([':id' => 2, ':name' => 'user22'])->execute(); |
901 | 901 | |
902 | 902 | $this->assertEquals('user2', $command->bindValue(':id', 2)->queryScalar()); |
903 | 903 | |
904 | - $db->noCache(function () use ($command) { |
|
904 | + $db->noCache(function() use ($command) { |
|
905 | 905 | $this->assertEquals('user22', $command->bindValue(':id', 2)->queryScalar()); |
906 | 906 | }); |
907 | 907 | |
@@ -910,7 +910,7 @@ discard block |
||
910 | 910 | |
911 | 911 | $this->queryCache->setEnable(false); |
912 | 912 | |
913 | - $db->cache(function () use ($command, $update) { |
|
913 | + $db->cache(function() use ($command, $update) { |
|
914 | 914 | $this->assertEquals('user22', $command->bindValue(':id', 2)->queryScalar()); |
915 | 915 | $update->bindValues([':id' => 2, ':name' => 'user2'])->execute(); |
916 | 916 | $this->assertEquals('user2', $command->bindValue(':id', 2)->queryScalar()); |
@@ -929,7 +929,7 @@ discard block |
||
929 | 929 | |
930 | 930 | $command = $db->createCommand('SELECT [[name]] FROM {{customer}} WHERE [[id]] = :id'); |
931 | 931 | |
932 | - $db->cache(function () use ($command) { |
|
932 | + $db->cache(function() use ($command) { |
|
933 | 933 | $this->assertEquals('user11', $command->bindValue(':id', 1)->queryScalar()); |
934 | 934 | $this->assertEquals('user1', $command->noCache()->bindValue(':id', 1)->queryScalar()); |
935 | 935 | }, 10); |
@@ -1014,7 +1014,7 @@ discard block |
||
1014 | 1014 | $this->invokeMethod( |
1015 | 1015 | $command, |
1016 | 1016 | 'setRetryHandler', |
1017 | - [static function ($exception, $attempt) use (&$attempts, &$hitHandler) { |
|
1017 | + [static function($exception, $attempt) use (&$attempts, &$hitHandler) { |
|
1018 | 1018 | $attempts = $attempt; |
1019 | 1019 | $hitHandler = true; |
1020 | 1020 |
@@ -37,7 +37,7 @@ |
||
37 | 37 | { |
38 | 38 | return $this->cache->getOrSet( |
39 | 39 | $key, |
40 | - static fn () => $value, |
|
40 | + static fn() => $value, |
|
41 | 41 | $ttl, |
42 | 42 | $dependency, |
43 | 43 | ); |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | /** Remove duplicates */ |
647 | 647 | $constraints = array_combine( |
648 | 648 | array_map( |
649 | - static function ($constraint) { |
|
649 | + static function($constraint) { |
|
650 | 650 | $columns = $constraint->getColumnNames(); |
651 | 651 | sort($columns, SORT_STRING); |
652 | 652 | |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | $constraints = array_values( |
664 | 664 | array_filter( |
665 | 665 | $constraints, |
666 | - static function ($constraint) use ($schema, $columns, &$columnNames) { |
|
666 | + static function($constraint) use ($schema, $columns, &$columnNames) { |
|
667 | 667 | /** @psalm-suppress UndefinedClass, UndefinedMethod */ |
668 | 668 | $constraintColumnNames = array_map([$schema, 'quoteColumnName'], $constraint->getColumnNames()); |
669 | 669 | $result = !array_diff($constraintColumnNames, $columns); |
@@ -1746,7 +1746,7 @@ discard block |
||
1746 | 1746 | */ |
1747 | 1747 | protected function hasOffset($offset): bool |
1748 | 1748 | { |
1749 | - return ($offset instanceof ExpressionInterface) || (ctype_digit((string)$offset) && (string)$offset !== '0'); |
|
1749 | + return ($offset instanceof ExpressionInterface) || (ctype_digit((string) $offset) && (string) $offset !== '0'); |
|
1750 | 1750 | } |
1751 | 1751 | |
1752 | 1752 | /** |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | { |
582 | 582 | $table = $this->db->quoteSql($table); |
583 | 583 | |
584 | - $columns = array_map(fn ($column) => $this->db->quoteSql($column), $columns); |
|
584 | + $columns = array_map(fn($column) => $this->db->quoteSql($column), $columns); |
|
585 | 585 | |
586 | 586 | $params = []; |
587 | 587 | |
@@ -1288,7 +1288,7 @@ discard block |
||
1288 | 1288 | $cacheKey = $this->getCacheKey($method, $fetchMode, $rawSql); |
1289 | 1289 | $result = $cache->getOrSet( |
1290 | 1290 | $cacheKey, |
1291 | - static fn () => null, |
|
1291 | + static fn() => null, |
|
1292 | 1292 | ); |
1293 | 1293 | |
1294 | 1294 | if (is_array($result) && isset($result[0])) { |
@@ -1340,7 +1340,7 @@ discard block |
||
1340 | 1340 | if (isset($cache, $cacheKey, $info)) { |
1341 | 1341 | $cache->getOrSet( |
1342 | 1342 | $cacheKey, |
1343 | - static fn (): array => [$result], |
|
1343 | + static fn(): array => [$result], |
|
1344 | 1344 | $info[1], |
1345 | 1345 | $info[2] |
1346 | 1346 | ); |
@@ -1464,7 +1464,7 @@ discard block |
||
1464 | 1464 | && $this->isolationLevel !== null |
1465 | 1465 | && $this->db->getTransaction() === null |
1466 | 1466 | ) { |
1467 | - $this->db->transaction(fn ($rawSql) => $this->internalExecute($rawSql), $this->isolationLevel); |
|
1467 | + $this->db->transaction(fn($rawSql) => $this->internalExecute($rawSql), $this->isolationLevel); |
|
1468 | 1468 | } else { |
1469 | 1469 | $this->pdoStatement->execute(); |
1470 | 1470 | } |
@@ -73,7 +73,7 @@ |
||
73 | 73 | { |
74 | 74 | return preg_replace_callback( |
75 | 75 | '/({{(%?[\w\-. ]+%?)}}|\\[\\[([\w\-. ]+)]])/', |
76 | - function ($matches) { |
|
76 | + function($matches) { |
|
77 | 77 | if (isset($matches[3])) { |
78 | 78 | return $this->quoteColumnName($matches[3]); |
79 | 79 | } |