@@ -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 | } |
@@ -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 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | $this->expectException(Exception::class); |
| 73 | 73 | |
| 74 | - $db->transaction(function () use ($db) { |
|
| 74 | + $db->transaction(function() use ($db) { |
|
| 75 | 75 | $db->createCommand()->insert('profile', ['description' => 'test transaction shortcut'])->execute(); |
| 76 | 76 | throw new Exception('Exception in transaction shortcut'); |
| 77 | 77 | }); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | $db = $this->getConnection(true); |
| 87 | 87 | |
| 88 | - $result = $db->transaction(static function () use ($db) { |
|
| 88 | + $result = $db->transaction(static function() use ($db) { |
|
| 89 | 89 | $db->createCommand()->insert('profile', ['description' => 'test transaction shortcut'])->execute(); |
| 90 | 90 | return true; |
| 91 | 91 | }); |
@@ -108,10 +108,10 @@ discard block |
||
| 108 | 108 | { |
| 109 | 109 | $db = $this->getConnection(); |
| 110 | 110 | |
| 111 | - $db->transaction(function (ConnectionInterface $db) { |
|
| 111 | + $db->transaction(function(ConnectionInterface $db) { |
|
| 112 | 112 | $this->assertNotNull($db->getTransaction()); |
| 113 | 113 | |
| 114 | - $db->transaction(function (ConnectionInterface $db) { |
|
| 114 | + $db->transaction(function(ConnectionInterface $db) { |
|
| 115 | 115 | $this->assertNotNull($db->getTransaction()); |
| 116 | 116 | $db->getTransaction()->rollBack(); |
| 117 | 117 | }); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | $db->setEnableSavepoint(false); |
| 128 | 128 | |
| 129 | - $db->transaction(function (ConnectionInterface $db) { |
|
| 129 | + $db->transaction(function(ConnectionInterface $db) { |
|
| 130 | 130 | $this->assertNotNull($db->getTransaction()); |
| 131 | 131 | $this->expectException(NotSupportedException::class); |
| 132 | 132 | $db->beginTransaction(); |
@@ -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); |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | $row = $rows[2]; |
| 211 | 211 | $this->assertEquals(3, $row['id']); |
| 212 | 212 | $this->assertEquals('user3', $row['name']); |
| 213 | - $this->assertTrue(is_array($rows) && count($rows)>1 && count($rows[0]) === 2); |
|
| 213 | + $this->assertTrue(is_array($rows) && count($rows) > 1 && count($rows[0]) === 2); |
|
| 214 | 214 | |
| 215 | 215 | $rows = $db->createCommand('SELECT * FROM {{customer}} WHERE [[id]] = 10')->queryAll(); |
| 216 | 216 | $this->assertEquals([], $rows); |
@@ -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 | } |
@@ -827,14 +827,14 @@ discard block |
||
| 827 | 827 | $update->bindValues([':id' => 1, ':name' => 'user11'])->execute(); |
| 828 | 828 | $this->assertEquals('user11', $command->bindValue(':id', 1)->queryScalar()); |
| 829 | 829 | |
| 830 | - $db->cache(function (ConnectionInterface $db) use ($command, $update) { |
|
| 830 | + $db->cache(function(ConnectionInterface $db) use ($command, $update) { |
|
| 831 | 831 | $this->assertEquals('user2', $command->bindValue(':id', 2)->queryScalar()); |
| 832 | 832 | |
| 833 | 833 | $update->bindValues([':id' => 2, ':name' => 'user22'])->execute(); |
| 834 | 834 | |
| 835 | 835 | $this->assertEquals('user2', $command->bindValue(':id', 2)->queryScalar()); |
| 836 | 836 | |
| 837 | - $db->noCache(function () use ($command) { |
|
| 837 | + $db->noCache(function() use ($command) { |
|
| 838 | 838 | $this->assertEquals('user22', $command->bindValue(':id', 2)->queryScalar()); |
| 839 | 839 | }); |
| 840 | 840 | |
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | |
| 844 | 844 | $this->queryCache->setEnable(false); |
| 845 | 845 | |
| 846 | - $db->cache(function () use ($command, $update) { |
|
| 846 | + $db->cache(function() use ($command, $update) { |
|
| 847 | 847 | $this->assertEquals('user22', $command->bindValue(':id', 2)->queryScalar()); |
| 848 | 848 | $update->bindValues([':id' => 2, ':name' => 'user2'])->execute(); |
| 849 | 849 | $this->assertEquals('user2', $command->bindValue(':id', 2)->queryScalar()); |
@@ -859,7 +859,7 @@ discard block |
||
| 859 | 859 | |
| 860 | 860 | $command = $db->createCommand('SELECT [[name]] FROM {{customer}} WHERE [[id]] = :id'); |
| 861 | 861 | |
| 862 | - $db->cache(function () use ($command) { |
|
| 862 | + $db->cache(function() use ($command) { |
|
| 863 | 863 | $this->assertEquals('user11', $command->bindValue(':id', 1)->queryScalar()); |
| 864 | 864 | $this->assertEquals('user1', $command->noCache()->bindValue(':id', 1)->queryScalar()); |
| 865 | 865 | }, 10); |
@@ -933,7 +933,7 @@ discard block |
||
| 933 | 933 | $this->invokeMethod( |
| 934 | 934 | $command, |
| 935 | 935 | 'setRetryHandler', |
| 936 | - [static function ($exception, $attempt) use (&$attempts, &$hitHandler) { |
|
| 936 | + [static function($exception, $attempt) use (&$attempts, &$hitHandler) { |
|
| 937 | 937 | $attempts = $attempt; |
| 938 | 938 | $hitHandler = true; |
| 939 | 939 | |
@@ -32,14 +32,14 @@ discard block |
||
| 32 | 32 | return [ |
| 33 | 33 | 'drop' => [ |
| 34 | 34 | "ALTER TABLE {{{$tableName}}} DROP CONSTRAINT [[$name]]", |
| 35 | - static function (QueryBuilderInterface $qb) use ($tableName, $name) { |
|
| 35 | + static function(QueryBuilderInterface $qb) use ($tableName, $name) { |
|
| 36 | 36 | return $qb->dropForeignKey($name, $tableName); |
| 37 | 37 | }, |
| 38 | 38 | ], |
| 39 | 39 | 'add' => [ |
| 40 | 40 | "ALTER TABLE {{{$tableName}}} ADD CONSTRAINT [[$name]] FOREIGN KEY ([[C_fk_id_1]])" |
| 41 | 41 | . " REFERENCES {{{$pkTableName}}} ([[C_id_1]]) ON DELETE CASCADE ON UPDATE CASCADE", |
| 42 | - static function (QueryBuilderInterface $qb) use ($tableName, $name, $pkTableName) { |
|
| 42 | + static function(QueryBuilderInterface $qb) use ($tableName, $name, $pkTableName) { |
|
| 43 | 43 | return $qb->addForeignKey( |
| 44 | 44 | $name, |
| 45 | 45 | $tableName, |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | 'add (2 columns)' => [ |
| 55 | 55 | "ALTER TABLE {{{$tableName}}} ADD CONSTRAINT [[$name]] FOREIGN KEY ([[C_fk_id_1]], [[C_fk_id_2]])" |
| 56 | 56 | . " REFERENCES {{{$pkTableName}}} ([[C_id_1]], [[C_id_2]]) ON DELETE CASCADE ON UPDATE CASCADE", |
| 57 | - static function (QueryBuilderInterface $qb) use ($tableName, $name, $pkTableName) { |
|
| 57 | + static function(QueryBuilderInterface $qb) use ($tableName, $name, $pkTableName) { |
|
| 58 | 58 | return $qb->addForeignKey( |
| 59 | 59 | $name, |
| 60 | 60 | $tableName, |
@@ -77,19 +77,19 @@ discard block |
||
| 77 | 77 | return [ |
| 78 | 78 | 'drop' => [ |
| 79 | 79 | "ALTER TABLE {{{$tableName}}} DROP CONSTRAINT [[$name]]", |
| 80 | - static function (QueryBuilderInterface $qb) use ($tableName, $name) { |
|
| 80 | + static function(QueryBuilderInterface $qb) use ($tableName, $name) { |
|
| 81 | 81 | return $qb->dropPrimaryKey($name, $tableName); |
| 82 | 82 | }, |
| 83 | 83 | ], |
| 84 | 84 | 'add' => [ |
| 85 | 85 | "ALTER TABLE {{{$tableName}}} ADD CONSTRAINT [[$name]] PRIMARY KEY ([[C_id_1]])", |
| 86 | - static function (QueryBuilderInterface $qb) use ($tableName, $name) { |
|
| 86 | + static function(QueryBuilderInterface $qb) use ($tableName, $name) { |
|
| 87 | 87 | return $qb->addPrimaryKey($name, $tableName, 'C_id_1'); |
| 88 | 88 | }, |
| 89 | 89 | ], |
| 90 | 90 | 'add (2 columns)' => [ |
| 91 | 91 | "ALTER TABLE {{{$tableName}}} ADD CONSTRAINT [[$name]] PRIMARY KEY ([[C_id_1]], [[C_id_2]])", |
| 92 | - static function (QueryBuilderInterface $qb) use ($tableName, $name) { |
|
| 92 | + static function(QueryBuilderInterface $qb) use ($tableName, $name) { |
|
| 93 | 93 | return $qb->addPrimaryKey($name, $tableName, 'C_id_1, C_id_2'); |
| 94 | 94 | }, |
| 95 | 95 | ], |
@@ -106,19 +106,19 @@ discard block |
||
| 106 | 106 | return [ |
| 107 | 107 | 'drop' => [ |
| 108 | 108 | "ALTER TABLE {{{$tableName1}}} DROP CONSTRAINT [[$name1]]", |
| 109 | - static function (QueryBuilderInterface $qb) use ($tableName1, $name1) { |
|
| 109 | + static function(QueryBuilderInterface $qb) use ($tableName1, $name1) { |
|
| 110 | 110 | return $qb->dropUnique($name1, $tableName1); |
| 111 | 111 | }, |
| 112 | 112 | ], |
| 113 | 113 | 'add' => [ |
| 114 | 114 | "ALTER TABLE {{{$tableName1}}} ADD CONSTRAINT [[$name1]] UNIQUE ([[C_unique]])", |
| 115 | - static function (QueryBuilderInterface $qb) use ($tableName1, $name1) { |
|
| 115 | + static function(QueryBuilderInterface $qb) use ($tableName1, $name1) { |
|
| 116 | 116 | return $qb->addUnique($name1, $tableName1, 'C_unique'); |
| 117 | 117 | }, |
| 118 | 118 | ], |
| 119 | 119 | 'add (2 columns)' => [ |
| 120 | 120 | "ALTER TABLE {{{$tableName2}}} ADD CONSTRAINT [[$name2]] UNIQUE ([[C_index_2_1]], [[C_index_2_2]])", |
| 121 | - static function (QueryBuilderInterface $qb) use ($tableName2, $name2) { |
|
| 121 | + static function(QueryBuilderInterface $qb) use ($tableName2, $name2) { |
|
| 122 | 122 | return $qb->addUnique($name2, $tableName2, 'C_index_2_1, C_index_2_2'); |
| 123 | 123 | }, |
| 124 | 124 | ], |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | [':qp0' => 1, |
| 503 | 503 | ':qp1' => 'foo', |
| 504 | 504 | ':qp2' => 2, |
| 505 | - ':qp3' => 'bar',], |
|
| 505 | + ':qp3' => 'bar', ], |
|
| 506 | 506 | ], |
| 507 | 507 | [ |
| 508 | 508 | ['not in', ['id', 'name'], [['id' => 1, 'name' => 'foo'], ['id' => 2, 'name' => 'bar']]], |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | [':qp0' => 1, |
| 511 | 511 | ':qp1' => 'foo', |
| 512 | 512 | ':qp2' => 2, |
| 513 | - ':qp3' => 'bar',], |
|
| 513 | + ':qp3' => 'bar', ], |
|
| 514 | 514 | ], |
| 515 | 515 | //[['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] ], |
| 516 | 516 | //[ ['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] ], |
@@ -797,31 +797,31 @@ discard block |
||
| 797 | 797 | return [ |
| 798 | 798 | 'drop' => [ |
| 799 | 799 | "DROP INDEX [[$name1]] ON {{{$tableName}}}", |
| 800 | - static function (QueryBuilderInterface $qb) use ($tableName, $name1) { |
|
| 800 | + static function(QueryBuilderInterface $qb) use ($tableName, $name1) { |
|
| 801 | 801 | return $qb->dropIndex($name1, $tableName); |
| 802 | 802 | }, |
| 803 | 803 | ], |
| 804 | 804 | 'create' => [ |
| 805 | 805 | "CREATE INDEX [[$name1]] ON {{{$tableName}}} ([[C_index_1]])", |
| 806 | - static function (QueryBuilderInterface $qb) use ($tableName, $name1) { |
|
| 806 | + static function(QueryBuilderInterface $qb) use ($tableName, $name1) { |
|
| 807 | 807 | return $qb->createIndex($name1, $tableName, 'C_index_1'); |
| 808 | 808 | }, |
| 809 | 809 | ], |
| 810 | 810 | 'create (2 columns)' => [ |
| 811 | 811 | "CREATE INDEX [[$name2]] ON {{{$tableName}}} ([[C_index_2_1]], [[C_index_2_2]])", |
| 812 | - static function (QueryBuilderInterface $qb) use ($tableName, $name2) { |
|
| 812 | + static function(QueryBuilderInterface $qb) use ($tableName, $name2) { |
|
| 813 | 813 | return $qb->createIndex($name2, $tableName, 'C_index_2_1, C_index_2_2'); |
| 814 | 814 | }, |
| 815 | 815 | ], |
| 816 | 816 | 'create unique' => [ |
| 817 | 817 | "CREATE UNIQUE INDEX [[$name1]] ON {{{$tableName}}} ([[C_index_1]])", |
| 818 | - static function (QueryBuilderInterface $qb) use ($tableName, $name1) { |
|
| 818 | + static function(QueryBuilderInterface $qb) use ($tableName, $name1) { |
|
| 819 | 819 | return $qb->createIndex($name1, $tableName, 'C_index_1', true); |
| 820 | 820 | }, |
| 821 | 821 | ], |
| 822 | 822 | 'create unique (2 columns)' => [ |
| 823 | 823 | "CREATE UNIQUE INDEX [[$name2]] ON {{{$tableName}}} ([[C_index_2_1]], [[C_index_2_2]])", |
| 824 | - static function (QueryBuilderInterface $qb) use ($tableName, $name2) { |
|
| 824 | + static function(QueryBuilderInterface $qb) use ($tableName, $name2) { |
|
| 825 | 825 | return $qb->createIndex($name2, $tableName, 'C_index_2_1, C_index_2_2', true); |
| 826 | 826 | }, |
| 827 | 827 | ], |
@@ -890,7 +890,7 @@ discard block |
||
| 890 | 890 | */ |
| 891 | 891 | protected function hasOffset(mixed $offset): bool |
| 892 | 892 | { |
| 893 | - return ($offset instanceof ExpressionInterface) || (ctype_digit((string)$offset) && (string)$offset !== '0'); |
|
| 893 | + return ($offset instanceof ExpressionInterface) || (ctype_digit((string) $offset) && (string) $offset !== '0'); |
|
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | /** |
@@ -1103,7 +1103,7 @@ discard block |
||
| 1103 | 1103 | /** Remove duplicates */ |
| 1104 | 1104 | $constraints = array_combine( |
| 1105 | 1105 | array_map( |
| 1106 | - static function (Constraint $constraint) { |
|
| 1106 | + static function(Constraint $constraint) { |
|
| 1107 | 1107 | $columns = $constraint->getColumnNames() ?? []; |
| 1108 | 1108 | $columns = is_array($columns) ? $columns : [$columns]; |
| 1109 | 1109 | sort($columns, SORT_STRING); |
@@ -1121,7 +1121,7 @@ discard block |
||
| 1121 | 1121 | $constraints = array_values( |
| 1122 | 1122 | array_filter( |
| 1123 | 1123 | $constraints, |
| 1124 | - static function (Constraint $constraint) use ($quoter, $columns, &$columnNames) { |
|
| 1124 | + static function(Constraint $constraint) use ($quoter, $columns, &$columnNames) { |
|
| 1125 | 1125 | /** @psalm-var string[]|string */ |
| 1126 | 1126 | $getColumnNames = $constraint->getColumnNames() ?? []; |
| 1127 | 1127 | $constraintColumnNames = []; |
@@ -224,8 +224,8 @@ |
||
| 224 | 224 | public function dropCommentFromTable(string $table): string |
| 225 | 225 | { |
| 226 | 226 | return 'COMMENT ON TABLE ' |
| 227 | - . $this->queryBuilder->quoter()->quoteTableName($table) |
|
| 228 | - . ' IS NULL'; |
|
| 227 | + . $this->queryBuilder->quoter()->quoteTableName($table) |
|
| 228 | + . ' IS NULL'; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -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 | }; |