Skip to content

Commit e1d8a4b

Browse files
committed
CS
1 parent f9c7737 commit e1d8a4b

19 files changed

+121
-120
lines changed

benchmarks/BasicPhpBenchmark.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public function benchmarkStringConcatenationDoubleQuotes(): void
276276
public function benchmarkStringConcatenationSprintf(): void
277277
{
278278
$i = 'a';
279-
$i = \sprintf('$%d, ', $i);
279+
$i = \sprintf('$%s, ', $i);
280280
}
281281

282282

@@ -321,7 +321,7 @@ public function benchmarkMoreStringsConcatenationSprintf(): void
321321
$x2 = 'a';
322322
$y2 = 'b';
323323
$z2 = 'c';
324-
$z2 = \sprintf('$%d, $%d, $%d, $%d, $%d, $%d', $x1, $y1, $z1, $x2, $y2, $z2);
324+
$z2 = \sprintf('$%s, $%s, $%s, $%s, $%s, $%s', $x1, $y1, $z1, $x2, $y2, $z2);
325325
}
326326

327327

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
"ext-pgsql": "^8.3"
1616
},
1717
"require-dev": {
18-
"forrest79/phpcs": "^2.0",
19-
"forrest79/phpcs-ignores": "^0.5",
18+
"forrest79/phpcs": "^2.3",
19+
"forrest79/phpcs-ignores": "^0.6",
2020
"forrest79/phpgsql-phpstan": "^1.9",
2121
"nette/tester": "^2.5",
2222
"phpstan/phpstan-strict-rules": "^2.0",
23-
"shipmonk/phpstan-rules": "^4.1"
23+
"shipmonk/phpstan-rules": "^4.2"
2424
},
2525
"suggest": {
2626
"ext-json": "Needed to support parse JSON types from PostgreSQL"

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ parameters:
6969
path: src/Fluent/Condition.php
7070

7171
-
72-
message: '#^Property Forrest79\\PhPgSql\\Fluent\\Condition\:\:\$conditions \(list\<Forrest79\\PhPgSql\\Fluent\\Condition\|list\<mixed\>\>\) does not accept non\-empty\-array\<int, Forrest79\\PhPgSql\\Fluent\\Condition\|list\<mixed\>\>\.$#'
72+
message: '#^Property Forrest79\\PhPgSql\\Fluent\\Condition\:\:\$conditions \(list\<Forrest79\\PhPgSql\\Fluent\\Condition\|list\<mixed\>\>\) does not accept non\-empty\-array\<int\<0, max\>, Forrest79\\PhPgSql\\Fluent\\Condition\|list\<mixed\>\>\.$#'
7373
identifier: assign.propertyType
7474
count: 1
7575
path: src/Fluent/Condition.php

src/Db/Result.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,12 +393,7 @@ public function hasAffectedRows(): bool
393393
*/
394394
public function getColumnType(string $column): string
395395
{
396-
$type = $this->getColumnsDataTypes()[$column] ?? null;
397-
if ($type === null) {
398-
throw Exceptions\ResultException::noColumn($column);
399-
}
400-
401-
return $type;
396+
return $this->getColumnsDataTypes()[$column] ?? throw Exceptions\ResultException::noColumn($column);
402397
}
403398

404399

src/Fluent/QueryBuilder.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@
66

77
/**
88
* @phpstan-type QueryParams array{
9-
* select: array<int|string, string|int|\BackedEnum|Query|Db\Sql>,
9+
* select: array<int|string, string|int|\BackedEnum|Db\Sql>,
1010
* distinct: bool,
11-
* distinctOn: list<string|Query|Db\Sql>,
11+
* distinctOn: list<string|Db\Sql>,
1212
* tables: array<string, array{0: string, 1: string}>,
1313
* table-types: array{main: string|null, from: list<string>, joins: list<string>, using: string|null},
1414
* on-conditions: array<string, Condition>,
1515
* lateral-tables: array<string, string>,
1616
* where: Condition|null,
1717
* groupBy: list<string>,
1818
* having: Condition|null,
19-
* orderBy: list<string|Db\Sql|Query>,
19+
* orderBy: list<string|Db\Sql>,
2020
* limit: int|null,
2121
* offset: int|null,
22-
* combine-queries: list<array{0: string|Query|Db\Sql, 1: string}>,
22+
* combine-queries: list<array{0: string|Db\Sql, 1: string}>,
2323
* insert-columns: list<string>,
2424
* insert-onconflict: array{columns-or-constraint: string|list<string>|false|null, where: Condition|null, do: array<int|string, string|Db\Sql>|false|null, do-where: Condition|null},
25-
* returning: array<int|string, string|int|Query|Db\Sql>,
25+
* returning: array<int|string, string|int|Db\Sql>,
2626
* data: array<string, mixed>,
2727
* rows: array<int, array<string, mixed>>,
2828
* merge: list<array{0: string, 1: string|Db\Sql, 2: Condition|null}>,
29-
* with: array{queries: array<string, string|Query|Db\Sql>, queries-suffix: array<string, string>, queries-not-materialized: array<string, string>, recursive: bool},
29+
* with: array{queries: array<string, string|Db\Sql>, queries-suffix: array<string, string>, queries-not-materialized: array<string, string>, recursive: bool},
3030
* prefix: list<array<mixed>>,
3131
* suffix: list<array<mixed>>
3232
* }

tests/Integration/AsyncTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function testMoreExecutesWithoutCompletePrevious(): void
9292
{
9393
Tester\Assert::exception(function (): void {
9494
$this->connection->asyncExecute('SELECT 1')->asyncExecute('SELECT 2');
95-
}, Db\Exceptions\ConnectionException::class, null, Db\Exceptions\ConnectionException::ASYNC_QUERY_SENT_FAILED);
95+
}, Db\Exceptions\ConnectionException::class, code: Db\Exceptions\ConnectionException::ASYNC_QUERY_SENT_FAILED);
9696
}
9797

9898

@@ -101,7 +101,7 @@ public function testCompleteExecuteWithQuery(): void
101101
Tester\Assert::exception(function (): void {
102102
$this->connection->asyncQuery('SELECT 1');
103103
$this->connection->completeAsyncExecute();
104-
}, Db\Exceptions\ConnectionException::class, null, Db\Exceptions\ConnectionException::ASYNC_NO_EXECUTE_IS_SENT);
104+
}, Db\Exceptions\ConnectionException::class, code: Db\Exceptions\ConnectionException::ASYNC_NO_EXECUTE_IS_SENT);
105105
}
106106

107107

@@ -112,7 +112,7 @@ public function testGetQueryResultAfterExecute(): void
112112
Tester\Assert::exception(function () use ($asyncQuery): void {
113113
$this->connection->asyncExecute('SELECT 2');
114114
$asyncQuery->getNextResult();
115-
}, Db\Exceptions\ConnectionException::class, null, Db\Exceptions\ConnectionException::ASYNC_QUERY_SENT_FAILED);
115+
}, Db\Exceptions\ConnectionException::class, code: Db\Exceptions\ConnectionException::ASYNC_QUERY_SENT_FAILED);
116116
}
117117

118118

@@ -124,7 +124,7 @@ public function testCancelAsyncQuery(): void
124124

125125
Tester\Assert::exception(static function () use ($asyncQuery): void {
126126
$asyncQuery->getNextResult();
127-
}, Db\Exceptions\ConnectionException::class, null, Db\Exceptions\ConnectionException::ASYNC_NO_QUERY_IS_SENT);
127+
}, Db\Exceptions\ConnectionException::class, code: Db\Exceptions\ConnectionException::ASYNC_NO_QUERY_IS_SENT);
128128
}
129129

130130

@@ -146,7 +146,7 @@ public function testMoreAsyncQueriesWithoutCompletePrevious(): void
146146

147147
Tester\Assert::exception(function (): void {
148148
$this->connection->asyncQuery('SELECT 2');
149-
}, Db\Exceptions\ConnectionException::class, null, Db\Exceptions\ConnectionException::ASYNC_QUERY_SENT_FAILED);
149+
}, Db\Exceptions\ConnectionException::class, code: Db\Exceptions\ConnectionException::ASYNC_QUERY_SENT_FAILED);
150150
}
151151

152152

@@ -162,13 +162,13 @@ public function testMoreAsyncQueriesInOne(): void
162162

163163
Tester\Assert::exception(static function () use ($asyncQuery1): void {
164164
$asyncQuery1->getNextResult();
165-
}, Db\Exceptions\ResultException::class, null, Db\Exceptions\ResultException::NO_OTHER_ASYNC_RESULT);
165+
}, Db\Exceptions\ResultException::class, code: Db\Exceptions\ResultException::NO_OTHER_ASYNC_RESULT);
166166

167167
$asyncQuery2 = $this->connection->asyncQuery('SELECT 3');
168168

169169
Tester\Assert::exception(static function () use ($asyncQuery1): void {
170170
$asyncQuery1->getNextResult();
171-
}, Db\Exceptions\ConnectionException::class, null, Db\Exceptions\ConnectionException::ASYNC_ANOTHER_QUERY_IS_RUNNING);
171+
}, Db\Exceptions\ConnectionException::class, code: Db\Exceptions\ConnectionException::ASYNC_ANOTHER_QUERY_IS_RUNNING);
172172

173173
$result3 = $asyncQuery2->getNextResult();
174174
Tester\Assert::same(3, $result3->fetchSingle());
@@ -177,7 +177,7 @@ public function testMoreAsyncQueriesInOne(): void
177177

178178
Tester\Assert::exception(static function () use ($asyncQuery1): void {
179179
$asyncQuery1->getNextResult();
180-
}, Db\Exceptions\ConnectionException::class, null, Db\Exceptions\ConnectionException::ASYNC_ANOTHER_QUERY_IS_RUNNING);
180+
}, Db\Exceptions\ConnectionException::class, code: Db\Exceptions\ConnectionException::ASYNC_ANOTHER_QUERY_IS_RUNNING);
181181
}
182182

183183

@@ -196,12 +196,12 @@ public function testError(): void
196196
$asyncQuery = $this->connection->asyncQuery('SELECT bad_column');
197197
Tester\Assert::exception(static function () use ($asyncQuery): void {
198198
$asyncQuery->getNextResult();
199-
}, Db\Exceptions\QueryException::class, null, Db\Exceptions\QueryException::ASYNC_QUERY_FAILED);
199+
}, Db\Exceptions\QueryException::class, code: Db\Exceptions\QueryException::ASYNC_QUERY_FAILED);
200200

201201
$this->connection->asyncExecute('SELECT bad_column');
202202
Tester\Assert::exception(function (): void {
203203
$this->connection->completeAsyncExecute();
204-
}, Db\Exceptions\QueryException::class, null, Db\Exceptions\QueryException::ASYNC_QUERY_FAILED);
204+
}, Db\Exceptions\QueryException::class, code: Db\Exceptions\QueryException::ASYNC_QUERY_FAILED);
205205
}
206206

207207

tests/Integration/BasicTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function testConnectionNoConfig(): void
8484

8585
Tester\Assert::exception(function (): void {
8686
$this->connection->connect();
87-
}, Db\Exceptions\ConnectionException::class, null, Db\Exceptions\ConnectionException::NO_CONFIG);
87+
}, Db\Exceptions\ConnectionException::class, code: Db\Exceptions\ConnectionException::NO_CONFIG);
8888
}
8989

9090

@@ -94,7 +94,7 @@ public function testFailedConnection(): void
9494

9595
Tester\Assert::exception(function (): void {
9696
$this->connection->ping();
97-
}, Db\Exceptions\ConnectionException::class, null, Db\Exceptions\ConnectionException::CONNECTION_FAILED);
97+
}, Db\Exceptions\ConnectionException::class, code: Db\Exceptions\ConnectionException::CONNECTION_FAILED);
9898
}
9999

100100

@@ -104,7 +104,7 @@ public function testChangeConnectionSettingsAfterConnected(): void
104104

105105
Tester\Assert::exception(function (): void {
106106
$this->connection->setConnectionConfig('');
107-
}, Db\Exceptions\ConnectionException::class, null, Db\Exceptions\ConnectionException::CANT_CHANGE_CONNECTION_CONFIG_WHEN_CONNECTED);
107+
}, Db\Exceptions\ConnectionException::class, code: Db\Exceptions\ConnectionException::CANT_CHANGE_CONNECTION_CONFIG_WHEN_CONNECTED);
108108

109109
$this->connection->close();
110110

@@ -187,7 +187,7 @@ public function testFailedQuery(): void
187187
Tester\Assert::true($e->getQuery() instanceof Db\Query);
188188
throw $e;
189189
}
190-
}, Db\Exceptions\QueryException::class, null, Db\Exceptions\QueryException::QUERY_FAILED);
190+
}, Db\Exceptions\QueryException::class, code: Db\Exceptions\QueryException::QUERY_FAILED);
191191
}
192192

193193

@@ -196,7 +196,7 @@ public function testPassParamToQuery(): void
196196
Tester\Assert::exception(function (): void {
197197
$query = Db\Sql\Query::create('SELECT 1');
198198
$this->connection->query($query, 1);
199-
}, Db\Exceptions\QueryException::class, null, Db\Exceptions\QueryException::CANT_PASS_PARAMS);
199+
}, Db\Exceptions\QueryException::class, code: Db\Exceptions\QueryException::CANT_PASS_PARAMS);
200200
}
201201

202202

@@ -243,7 +243,7 @@ public function testFailedExecute(): void
243243
{
244244
Tester\Assert::exception(function (): void {
245245
$this->connection->execute('SELECT bad_column');
246-
}, Db\Exceptions\QueryException::class, null, Db\Exceptions\QueryException::QUERY_FAILED);
246+
}, Db\Exceptions\QueryException::class, code: Db\Exceptions\QueryException::QUERY_FAILED);
247247
}
248248

249249

tests/Integration/CollectingResultsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function testResultCollector(): void
5252
// Try also parse some non-existing column
5353
Tester\Assert::exception(static function () use ($resultSelect): void {
5454
$resultSelect->parseColumnValue('non_existing_column', 'someValue');
55-
}, Db\Exceptions\ResultException::class, null, Db\Exceptions\ResultException::NO_COLUMN);
55+
}, Db\Exceptions\ResultException::class, code: Db\Exceptions\ResultException::NO_COLUMN);
5656

5757
$querySelect = $resultSelect->getQuery();
5858

tests/Integration/DataTypeCacheTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function testNoOidInCache(): void
108108

109109
Tester\Assert::exception(static function () use ($result2): void {
110110
Tester\Assert::same('hstore', $result2->getColumnType('data'));
111-
}, Db\Exceptions\ResultException::class, null, Db\Exceptions\ResultException::NO_OID_IN_DATA_TYPE_CACHE);
111+
}, Db\Exceptions\ResultException::class, code: Db\Exceptions\ResultException::NO_OID_IN_DATA_TYPE_CACHE);
112112

113113
$result2->free();
114114
}

tests/Integration/FetchMutatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public function testFetchAssocColumnMutatorMutatedObjectAsKey(): void
212212

213213
Tester\Assert::exception(static function () use ($result): void {
214214
$result->fetchAssoc('test_date=id');
215-
}, Db\Exceptions\ResultException::class, null, Db\Exceptions\ResultException::FETCH_MUTATOR_BAR_RETURN_TYPE);
215+
}, Db\Exceptions\ResultException::class, code: Db\Exceptions\ResultException::FETCH_MUTATOR_BAR_RETURN_TYPE);
216216

217217
$result->free();
218218
}
@@ -415,7 +415,7 @@ public function testFetchPairsKeyMutatorMutatedObject(): void
415415

416416
Tester\Assert::exception(static function () use ($result): void {
417417
$result->fetchPairs();
418-
}, Db\Exceptions\ResultException::class, null, Db\Exceptions\ResultException::FETCH_MUTATOR_BAR_RETURN_TYPE);
418+
}, Db\Exceptions\ResultException::class, code: Db\Exceptions\ResultException::FETCH_MUTATOR_BAR_RETURN_TYPE);
419419

420420
$result->free();
421421
}

0 commit comments

Comments
 (0)