Passed
Pull Request — master (#266)
by Wilmer
11:36 queued 08:56
created
src/Schema/Quoter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@
 block discarded – undo
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
                 }
Please login to merge, or discard this patch.
src/Schema/Schema.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -497,7 +497,7 @@
 block discarded – undo
497 497
         string $name,
498 498
         bool $refresh = false
499 499
     ): Constraint|array|null|TableSchema {
500
-        return match ($type) {
500
+        return match($type) {
501 501
             self::SCHEMA => $this->getTableSchema($name, $refresh),
502 502
             self::PRIMARY_KEY => $this->getTablePrimaryKey($name, $refresh),
503 503
             self::UNIQUES => $this->getTableUniques($name, $refresh),
Please login to merge, or discard this patch.
src/Query/DDLQueryBuilder.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -203,8 +203,8 @@
 block discarded – undo
203 203
     public function dropCommentFromTable(string $table): string
204 204
     {
205 205
         return 'COMMENT ON TABLE '
206
-             . $this->queryBuilder->quoter()->quoteTableName($table)
207
-             . ' IS NULL';
206
+                . $this->queryBuilder->quoter()->quoteTableName($table)
207
+                . ' IS NULL';
208 208
     }
209 209
 
210 210
     public function dropDefaultValue(string $name, string $table): string
Please login to merge, or discard this patch.
src/Query/QueryBuilder.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
      */
855 855
     protected function hasOffset(mixed $offset): bool
856 856
     {
857
-        return ($offset instanceof ExpressionInterface) || (ctype_digit((string)$offset) && (string)$offset !== '0');
857
+        return ($offset instanceof ExpressionInterface) || (ctype_digit((string) $offset) && (string) $offset !== '0');
858 858
     }
859 859
 
860 860
     /**
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
         /** Remove duplicates */
1047 1047
         $constraints = array_combine(
1048 1048
             array_map(
1049
-                static function ($constraint) {
1049
+                static function($constraint) {
1050 1050
                     $columns = $constraint->getColumnNames();
1051 1051
                     sort($columns, SORT_STRING);
1052 1052
 
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
         $constraints = array_values(
1065 1065
             array_filter(
1066 1066
                 $constraints,
1067
-                static function ($constraint) use ($quoter, $columns, &$columnNames) {
1067
+                static function($constraint) use ($quoter, $columns, &$columnNames) {
1068 1068
                     /** @psalm-suppress UndefinedClass, UndefinedMethod */
1069 1069
                     $constraintColumnNames = array_map([$quoter, 'quoteColumnName'], $constraint->getColumnNames());
1070 1070
                     $result = !array_diff($constraintColumnNames, $columns);
Please login to merge, or discard this patch.
src/Cache/SchemaCache.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
     ): mixed {
43 43
         return $this->cache->getOrSet(
44 44
             $key,
45
-            static fn () => $value,
45
+            static fn() => $value,
46 46
             $ttl,
47 47
             $dependency,
48 48
         );
Please login to merge, or discard this patch.
src/Command/Command.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
     public function batchInsert(string $table, array $columns, iterable $rows): self
218 218
     {
219 219
         $table = $this->queryBuilder()->quoter()->quoteSql($table);
220
-        $columns = array_map(fn ($column) => $this->queryBuilder()->quoter()->quoteSql($column), $columns);
220
+        $columns = array_map(fn($column) => $this->queryBuilder()->quoter()->quoteSql($column), $columns);
221 221
         $params = [];
222 222
         $sql = $this->queryBuilder()->batchInsert($table, $columns, $rows, $params);
223 223
 
@@ -432,18 +432,18 @@  discard block
 block discarded – undo
432 432
         $this->prepare(false);
433 433
 
434 434
         try {
435
-            $this->profiler?->begin((string)$rawSql, [__METHOD__]);
435
+            $this->profiler ? ->begin((string) $rawSql, [__METHOD__]);
436 436
 
437 437
             $this->internalExecute($rawSql);
438 438
             $n = $this->pdoStatement->rowCount();
439 439
 
440
-            $this->profiler?->end((string)$rawSql, [__METHOD__]);
440
+            $this->profiler ? ->end((string) $rawSql, [__METHOD__]);
441 441
 
442 442
             $this->refreshTableSchema();
443 443
 
444 444
             return $n;
445 445
         } catch (Exception $e) {
446
-            $this->profiler?->end((string)$rawSql, [__METHOD__]);
446
+            $this->profiler ? ->end((string) $rawSql, [__METHOD__]);
447 447
             throw $e;
448 448
         }
449 449
     }
@@ -708,11 +708,11 @@  discard block
 block discarded – undo
708 708
                 $cacheKey = $this->getCacheKey($method, $fetchMode, $rawSql);
709 709
                 $result = $cache->getOrSet(
710 710
                     $cacheKey,
711
-                    static fn () => null,
711
+                    static fn() => null,
712 712
                 );
713 713
 
714 714
                 if (is_array($result) && isset($result[0])) {
715
-                    $this->logger?->log(LogLevel::DEBUG, 'Query result served from cache', [__CLASS__ . '::query']);
715
+                    $this->logger ? ->log(LogLevel::DEBUG, 'Query result served from cache', [__CLASS__ . '::query']);
716 716
 
717 717
                     return $result[0];
718 718
                 }
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
         $this->prepare(true);
723 723
 
724 724
         try {
725
-            $this->profiler?->begin((string)$rawSql, [__CLASS__ . '::query']);
725
+            $this->profiler ? ->begin((string) $rawSql, [__CLASS__ . '::query']);
726 726
 
727 727
             $this->internalExecute($rawSql);
728 728
 
@@ -738,21 +738,21 @@  discard block
 block discarded – undo
738 738
                 $this->pdoStatement->closeCursor();
739 739
             }
740 740
 
741
-            $this->profiler?->end((string)$rawSql, [__CLASS__ . '::query']);
741
+            $this->profiler ? ->end((string) $rawSql, [__CLASS__ . '::query']);
742 742
         } catch (Exception $e) {
743
-            $this->profiler?->end((string)$rawSql, [__CLASS__ . '::query']);
743
+            $this->profiler ? ->end((string) $rawSql, [__CLASS__ . '::query']);
744 744
             throw $e;
745 745
         }
746 746
 
747 747
         if (isset($cache, $cacheKey, $info)) {
748 748
             $cache->getOrSet(
749 749
                 $cacheKey,
750
-                static fn (): array => [$result],
750
+                static fn(): array => [$result],
751 751
                 $info[1],
752 752
                 $info[2]
753 753
             );
754 754
 
755
-            $this->logger?->log(LogLevel::DEBUG, 'Saved query result in cache', [__CLASS__ . '::query']);
755
+            $this->logger ? ->log(LogLevel::DEBUG, 'Saved query result in cache', [__CLASS__ . '::query']);
756 756
         }
757 757
 
758 758
         return $result;
Please login to merge, or discard this patch.
src/TestUtility/TestQueryTrait.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/TestUtility/TestQueryBuilderTrait.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1146,20 +1146,20 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1562,13 +1562,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             ],
Please login to merge, or discard this patch.
src/TestUtility/TestConnectionTrait.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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();
Please login to merge, or discard this patch.