Skip to content

Commit 68ed99a

Browse files
committed
Add Connection interface
1 parent be59ba0 commit 68ed99a

3 files changed

Lines changed: 25 additions & 5 deletions

File tree

src/Connection.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Amp\Sql;
4+
5+
/**
6+
* @template TResult of Result
7+
* @template TStatement of Statement
8+
* @template TTransaction of Transaction
9+
* @template TConfig of SqlConfig
10+
*
11+
* @extends Link<TResult, TStatement, TTransaction>
12+
*/
13+
interface Connection extends Link
14+
{
15+
/**
16+
* @return TConfig The configuration used to create this connection.
17+
*/
18+
public function getConfig(): SqlConfig;
19+
}

src/Pool.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* @template TResult of Result
77
* @template TStatement of Statement
88
* @template TTransaction of Transaction
9+
* @template TConfig of SqlConfig
910
*
1011
* @extends Link<TResult, TStatement, TTransaction>
1112
*/
@@ -15,9 +16,9 @@ interface Pool extends Link
1516
* Gets a single connection from the pool to run a set of queries against a single connection.
1617
* Generally a transaction should be used instead of this method.
1718
*
18-
* @return Link<TResult, TStatement, TTransaction>
19+
* @return Connection<TResult, TStatement, TTransaction, TConfig>
1920
*/
20-
public function extractConnection(): Link;
21+
public function extractConnection(): Connection;
2122

2223
/**
2324
* @return int Total number of active connections in the pool.

src/SqlConnector.php

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

77
/**
88
* @template TConfig of SqlConfig
9-
* @template TLink of Link
9+
* @template TConnection of Connection
1010
*/
1111
interface SqlConnector
1212
{
@@ -16,9 +16,9 @@ interface SqlConnector
1616
*
1717
* @param TConfig $config
1818
*
19-
* @return TLink
19+
* @return TConnection
2020
*
2121
* @throws ConnectionException
2222
*/
23-
public function connect(SqlConfig $config, ?Cancellation $cancellation = null): Link;
23+
public function connect(SqlConfig $config, ?Cancellation $cancellation = null): Connection;
2424
}

0 commit comments

Comments
 (0)