Skip to content

Commit 779fab0

Browse files
committed
Add #[Override] annotations
1 parent da67d61 commit 779fab0

25 files changed

+116
-0
lines changed

src/DefaultPostgresConnector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ final class DefaultPostgresConnector implements SqlConnector
2222
*
2323
* @throws \Error If neither ext-pgsql nor pecl-pq is loaded.
2424
*/
25+
#[\Override]
2526
public function connect(SqlConfig $config, ?Cancellation $cancellation = null): PostgresConnection
2627
{
2728
if (!$config instanceof PostgresConfig) {

src/Internal/AbstractHandle.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,25 @@ public function __destruct()
4141
}
4242
}
4343

44+
#[\Override]
4445
public function getConfig(): PostgresConfig
4546
{
4647
return $this->config;
4748
}
4849

50+
#[\Override]
4951
public function getLastUsedAt(): int
5052
{
5153
return $this->lastUsedAt;
5254
}
5355

56+
#[\Override]
5457
public function onClose(\Closure $onClose): void
5558
{
5659
$this->onClose->getFuture()->finally($onClose);
5760
}
5861

62+
#[\Override]
5963
public function close(): void
6064
{
6165
self::shutdown($this->listeners, $this->pendingOperation, $this->onClose);
@@ -94,26 +98,31 @@ protected function encodeParam(mixed $value): string|int|float|null
9498
return encodeParam($this, $value);
9599
}
96100

101+
#[\Override]
97102
public function commit(): void
98103
{
99104
$this->query("COMMIT");
100105
}
101106

107+
#[\Override]
102108
public function rollback(): void
103109
{
104110
$this->query("ROLLBACK");
105111
}
106112

113+
#[\Override]
107114
public function createSavepoint(string $identifier): void
108115
{
109116
$this->query("SAVEPOINT " . $this->quoteIdentifier($identifier));
110117
}
111118

119+
#[\Override]
112120
public function rollbackTo(string $identifier): void
113121
{
114122
$this->query("ROLLBACK TO " . $this->quoteIdentifier($identifier));
115123
}
116124

125+
#[\Override]
117126
public function releaseSavepoint(string $identifier): void
118127
{
119128
$this->query("RELEASE SAVEPOINT " . $this->quoteIdentifier($identifier));

src/Internal/PgSqlHandle.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,14 @@ private static function getErrorHandler(): \Closure
248248
};
249249
}
250250

251+
#[\Override]
251252
public function close(): void
252253
{
253254
$this->handle = null;
254255
parent::close();
255256
}
256257

258+
#[\Override]
257259
public function isClosed(): bool
258260
{
259261
return !$this->handle instanceof \PgSql\Connection;
@@ -378,6 +380,7 @@ private function fetchNextResult(string $sql): ?PostgresResult
378380
return null;
379381
}
380382

383+
#[\Override]
381384
public function statementExecute(string $name, array $params): PostgresResult
382385
{
383386
\assert(isset($this->statements[$name]), "Named statement not found when executing");
@@ -388,6 +391,7 @@ public function statementExecute(string $name, array $params): PostgresResult
388391
/**
389392
* @throws \Error
390393
*/
394+
#[\Override]
391395
public function statementDeallocate(string $name): void
392396
{
393397
if ($this->isClosed()) {
@@ -414,6 +418,7 @@ public function statementDeallocate(string $name): void
414418
$storage->future->ignore();
415419
}
416420

421+
#[\Override]
417422
public function escapeByteA(string $data): string
418423
{
419424
if ($this->handle === null) {
@@ -423,6 +428,7 @@ public function escapeByteA(string $data): string
423428
return \pg_escape_bytea($this->handle, $data);
424429
}
425430

431+
#[\Override]
426432
public function query(string $sql): PostgresResult
427433
{
428434
if ($this->handle === null) {
@@ -432,6 +438,7 @@ public function query(string $sql): PostgresResult
432438
return $this->createResult($this->send(\pg_send_query(...), $sql), $sql);
433439
}
434440

441+
#[\Override]
435442
public function execute(string $sql, array $params = []): PostgresResult
436443
{
437444
if ($this->handle === null) {
@@ -450,6 +457,7 @@ public function execute(string $sql, array $params = []): PostgresResult
450457
return $this->createResult($result, $sql);
451458
}
452459

460+
#[\Override]
453461
public function prepare(string $sql): PostgresStatement
454462
{
455463
if ($this->handle === null) {
@@ -514,6 +522,7 @@ public function prepare(string $sql): PostgresStatement
514522
return new PostgresConnectionStatement($this, $name, $sql, $names);
515523
}
516524

525+
#[\Override]
517526
public function notify(string $channel, string $payload = ""): PostgresResult
518527
{
519528
if ($payload === "") {
@@ -523,6 +532,7 @@ public function notify(string $channel, string $payload = ""): PostgresResult
523532
return $this->query(\sprintf("NOTIFY %s, %s", $this->quoteIdentifier($channel), $this->quoteLiteral($payload)));
524533
}
525534

535+
#[\Override]
526536
public function listen(string $channel): PostgresListener
527537
{
528538
if (isset($this->listeners[$channel])) {
@@ -567,6 +577,7 @@ private function unlisten(string $channel): void
567577
}
568578
}
569579

580+
#[\Override]
570581
public function quoteLiteral(string $data): string
571582
{
572583
if ($this->handle === null) {
@@ -576,6 +587,7 @@ public function quoteLiteral(string $data): string
576587
return \pg_escape_literal($this->handle, $data);
577588
}
578589

590+
#[\Override]
579591
public function quoteIdentifier(string $name): string
580592
{
581593
if ($this->handle === null) {

src/Internal/PgSqlResultSet.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function __construct(
3838
$this->iterator = PgSqlResultIterator::iterate($handle, $types);
3939
}
4040

41+
#[\Override]
4142
public function fetchRow(): ?array
4243
{
4344
if (!$this->iterator->valid()) {
@@ -49,11 +50,13 @@ public function fetchRow(): ?array
4950
return $current;
5051
}
5152

53+
#[\Override]
5254
public function getIterator(): \Traversable
5355
{
5456
return $this->iterator;
5557
}
5658

59+
#[\Override]
5760
public function getNextResult(): ?PostgresResult
5861
{
5962
return $this->nextResult->await();
@@ -62,6 +65,7 @@ public function getNextResult(): ?PostgresResult
6265
/**
6366
* @return int Number of rows returned.
6467
*/
68+
#[\Override]
6569
public function getRowCount(): int
6670
{
6771
return $this->rowCount;
@@ -70,6 +74,7 @@ public function getRowCount(): int
7074
/**
7175
* @return int Number of columns returned.
7276
*/
77+
#[\Override]
7378
public function getColumnCount(): int
7479
{
7580
return $this->columnCount;

src/Internal/PostgresCommandResult.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ final class PostgresCommandResult extends SqlCommandResult implements PostgresRe
1515
/**
1616
* Changes return type to this library's Result type.
1717
*/
18+
#[\Override]
1819
public function getNextResult(): ?PostgresResult
1920
{
2021
return parent::getNextResult();

src/Internal/PostgresConnectionListener.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,20 @@ public function __destruct()
4141
}
4242
}
4343

44+
#[\Override]
4445
public function getIterator(): \Traversable
4546
{
4647
// Using a Generator to keep a reference to $this.
4748
yield from $this->source;
4849
}
4950

51+
#[\Override]
5052
public function getChannel(): string
5153
{
5254
return $this->channel;
5355
}
5456

57+
#[\Override]
5558
public function isListening(): bool
5659
{
5760
return $this->unlisten !== null;
@@ -62,6 +65,7 @@ public function isListening(): bool
6265
*
6366
* @throws \Error If this method was previously invoked.
6467
*/
68+
#[\Override]
6569
public function unlisten(): void
6670
{
6771
if (!$this->unlisten) {

src/Internal/PostgresConnectionStatement.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,33 +40,39 @@ public function __destruct()
4040
$this->close();
4141
}
4242

43+
#[\Override]
4344
public function isClosed(): bool
4445
{
4546
return $this->onClose->isComplete();
4647
}
4748

49+
#[\Override]
4850
public function close(): void
4951
{
5052
if (!$this->onClose->isComplete()) {
5153
$this->onClose->complete();
5254
}
5355
}
5456

57+
#[\Override]
5558
public function onClose(\Closure $onClose): void
5659
{
5760
$this->onClose->getFuture()->finally($onClose);
5861
}
5962

63+
#[\Override]
6064
public function getQuery(): string
6165
{
6266
return $this->sql;
6367
}
6468

69+
#[\Override]
6570
public function getLastUsedAt(): int
6671
{
6772
return $this->lastUsedAt;
6873
}
6974

75+
#[\Override]
7076
public function execute(array $params = []): PostgresResult
7177
{
7278
if ($this->isClosed()) {

src/Internal/PostgresConnectionTransaction.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function __construct(
2727
parent::__construct($handle, $release, $isolation);
2828
}
2929

30+
#[\Override]
3031
protected function createNestedTransaction(
3132
SqlTransaction $transaction,
3233
SqlNestableTransactionExecutor $executor,
@@ -37,6 +38,7 @@ protected function createNestedTransaction(
3738
return new PostgresNestedTransaction($this, $executor, $identifier, $release);
3839
}
3940

41+
#[\Override]
4042
protected function getExecutor(): PostgresExecutor
4143
{
4244
return $this->handle;

src/Internal/PostgresHandleConnection.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,31 @@ protected function __construct(private readonly PostgresHandle $handle)
4040
{
4141
}
4242

43+
#[\Override]
4344
final public function getConfig(): PostgresConfig
4445
{
4546
return $this->handle->getConfig();
4647
}
4748

49+
#[\Override]
4850
final public function getLastUsedAt(): int
4951
{
5052
return $this->handle->getLastUsedAt();
5153
}
5254

55+
#[\Override]
5356
final public function close(): void
5457
{
5558
$this->handle->close();
5659
}
5760

61+
#[\Override]
5862
final public function isClosed(): bool
5963
{
6064
return $this->handle->isClosed();
6165
}
6266

67+
#[\Override]
6368
final public function onClose(\Closure $onClose): void
6469
{
6570
$this->handle->onClose($onClose);
@@ -92,36 +97,42 @@ private function release(): void
9297
$this->busy = null;
9398
}
9499

100+
#[\Override]
95101
final public function query(string $sql): PostgresResult
96102
{
97103
$this->awaitPending();
98104
return $this->handle->query($sql);
99105
}
100106

107+
#[\Override]
101108
final public function execute(string $sql, array $params = []): PostgresResult
102109
{
103110
$this->awaitPending();
104111
return $this->handle->execute($sql, $params);
105112
}
106113

114+
#[\Override]
107115
final public function prepare(string $sql): PostgresStatement
108116
{
109117
$this->awaitPending();
110118
return $this->handle->prepare($sql);
111119
}
112120

121+
#[\Override]
113122
final public function notify(string $channel, string $payload = ""): PostgresResult
114123
{
115124
$this->awaitPending();
116125
return $this->handle->notify($channel, $payload);
117126
}
118127

128+
#[\Override]
119129
final public function listen(string $channel): PostgresListener
120130
{
121131
$this->awaitPending();
122132
return $this->handle->listen($channel);
123133
}
124134

135+
#[\Override]
125136
final public function beginTransaction(): PostgresTransaction
126137
{
127138
$this->reserve();
@@ -140,26 +151,31 @@ final public function beginTransaction(): PostgresTransaction
140151
);
141152
}
142153

154+
#[\Override]
143155
final public function getTransactionIsolation(): SqlTransactionIsolation
144156
{
145157
return $this->transactionIsolation;
146158
}
147159

160+
#[\Override]
148161
final public function setTransactionIsolation(SqlTransactionIsolation $isolation): void
149162
{
150163
$this->transactionIsolation = $isolation;
151164
}
152165

166+
#[\Override]
153167
final public function quoteLiteral(string $data): string
154168
{
155169
return $this->handle->quoteLiteral($data);
156170
}
157171

172+
#[\Override]
158173
final public function quoteIdentifier(string $name): string
159174
{
160175
return $this->handle->quoteIdentifier($name);
161176
}
162177

178+
#[\Override]
163179
final public function escapeByteA(string $data): string
164180
{
165181
return $this->handle->escapeByteA($data);

0 commit comments

Comments
 (0)