Passed
Branch psalm-3 (d5d890)
by Wilmer
02: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/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/Connection/Connection.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -262,7 +262,7 @@
 block discarded – undo
262 262
 
263 263
                 return $poolConnection;
264 264
             } catch (Exception $e) {
265
-                $this->logger?->log(
265
+                $this->logger ? ->log(
266 266
                     LogLevel::WARNING,
267 267
                     "Connection ({$poolConnection->getDriver()->getDsn()}) failed: " . $e->getMessage() . ' ' . __METHOD__
268 268
                 );
Please login to merge, or discard this patch.
src/TestSupport/Provider/QueryBuilderProvider.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             ],
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
             [new Expression('NOT (any_expression(:a))', [':a' => 1]), 'NOT (any_expression(:a))', [':a' => 1]],
495 495
         ];
496 496
 
497
-        $conditions = match ($this->db->getDriverName()) {
497
+        $conditions = match($this->db->getDriverName()) {
498 498
             'sqlsrv', 'sqlite' => array_merge($conditions, [
499 499
                 [
500 500
                     ['in', ['id', 'name'], [['id' => 1, 'name' => 'foo'], ['id' => 2, 'name' => 'bar']]],
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             ],
Please login to merge, or discard this patch.
src/TestSupport/TestTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -185,7 +185,7 @@
 block discarded – undo
185 185
      */
186 186
     protected function replaceQuotes($sql): string|array|null
187 187
     {
188
-        return match ($this->drivername) {
188
+        return match($this->drivername) {
189 189
             'mysql', 'sqlite' => str_replace(['[[', ']]'], '`', $sql),
190 190
             'oci' => str_replace(['[[', ']]'], '"', $sql),
191 191
             'pgsql' => str_replace(['\\[', '\\]'], ['[', ']'], preg_replace('/(\[\[)|((?<!(\[))]])/', '"', $sql)),
Please login to merge, or discard this patch.
src/TestSupport/Helper/DbHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
      */
17 17
     public static function replaceQuotes(string $sql, string $drivername): string
18 18
     {
19
-        return match ($drivername) {
19
+        return match($drivername) {
20 20
             'mysql', 'sqlite' => str_replace(['[[', ']]'], '`', $sql),
21 21
             'oci' => str_replace(['[[', ']]'], '"', $sql),
22 22
             'pgsql' => str_replace(['\\[', '\\]'], ['[', ']'], preg_replace('/(\[\[)|((?<!(\[))]])/', '"', $sql)),
Please login to merge, or discard this patch.
src/TestSupport/TestConnectionTrait.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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();
Please login to merge, or discard this patch.
src/TestSupport/TestCommandTrait.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
      */
233 233
     public function testBatchInsertWithYield(): void
234 234
     {
235
-        $rows = (static function () {
235
+        $rows = (static function() {
236 236
             if (false) {
237 237
                 yield [];
238 238
             }
@@ -791,14 +791,14 @@  discard block
 block discarded – undo
791 791
         $update->bindValues([':id' => 1, ':name' => 'user11'])->execute();
792 792
         $this->assertEquals('user11', $command->bindValue(':id', 1)->queryScalar());
793 793
 
794
-        $db->cache(function (ConnectionInterface $db) use ($command, $update) {
794
+        $db->cache(function(ConnectionInterface $db) use ($command, $update) {
795 795
             $this->assertEquals('user2', $command->bindValue(':id', 2)->queryScalar());
796 796
 
797 797
             $update->bindValues([':id' => 2, ':name' => 'user22'])->execute();
798 798
 
799 799
             $this->assertEquals('user2', $command->bindValue(':id', 2)->queryScalar());
800 800
 
801
-            $db->noCache(function () use ($command) {
801
+            $db->noCache(function() use ($command) {
802 802
                 $this->assertEquals('user22', $command->bindValue(':id', 2)->queryScalar());
803 803
             });
804 804
 
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
 
808 808
         $this->queryCache->setEnable(false);
809 809
 
810
-        $db->cache(function () use ($command, $update) {
810
+        $db->cache(function() use ($command, $update) {
811 811
             $this->assertEquals('user22', $command->bindValue(':id', 2)->queryScalar());
812 812
             $update->bindValues([':id' => 2, ':name' => 'user2'])->execute();
813 813
             $this->assertEquals('user2', $command->bindValue(':id', 2)->queryScalar());
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
 
824 824
         $command = $db->createCommand('SELECT [[name]] FROM {{customer}} WHERE [[id]] = :id');
825 825
 
826
-        $db->cache(function () use ($command) {
826
+        $db->cache(function() use ($command) {
827 827
             $this->assertEquals('user11', $command->bindValue(':id', 1)->queryScalar());
828 828
             $this->assertEquals('user1', $command->noCache()->bindValue(':id', 1)->queryScalar());
829 829
         }, 10);
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
         $this->invokeMethod(
898 898
             $command,
899 899
             'setRetryHandler',
900
-            [static function ($exception, $attempt) use (&$attempts, &$hitHandler) {
900
+            [static function($exception, $attempt) use (&$attempts, &$hitHandler) {
901 901
                 $attempts = $attempt;
902 902
                 $hitHandler = true;
903 903
 
Please login to merge, or discard this patch.
src/TestSupport/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.