Skip to content

Commit

Permalink
Fixup some types
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Dec 3, 2023
1 parent 9f9a21a commit 4c53678
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
5 changes: 2 additions & 3 deletions src/DefaultPostgresConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
namespace Amp\Postgres;

use Amp\Cancellation;
use Amp\Postgres\Internal\PostgresHandleConnection;
use Amp\Sql\SqlConfig;
use Amp\Sql\SqlConnector;
use Amp\Sql\SqlException;

/**
* @implements SqlConnector<PostgresConfig, PostgresHandleConnection>
* @implements SqlConnector<PostgresConfig, PostgresConnection>
*/
final class DefaultPostgresConnector implements SqlConnector
{
Expand All @@ -18,7 +17,7 @@ final class DefaultPostgresConnector implements SqlConnector
*
* @throws \Error If neither ext-pgsql nor pecl-pq is loaded.
*/
public function connect(SqlConfig $config, ?Cancellation $cancellation = null): PostgresHandleConnection
public function connect(SqlConfig $config, ?Cancellation $cancellation = null): PostgresConnection
{
if (!$config instanceof PostgresConfig) {
throw new \TypeError(\sprintf("Must provide an instance of %s to Postgres connectors", PostgresConfig::class));
Expand Down
8 changes: 4 additions & 4 deletions src/Internal/PostgresNestedTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Amp\Postgres\PostgresResult;
use Amp\Postgres\PostgresStatement;
use Amp\Postgres\PostgresTransaction;
use Amp\Sql\Common\NestableTransactionExecutor;
use Amp\Sql\Common\NestedTransaction;
use Amp\Sql\Executor;
use Amp\Sql\Transaction;

/**
Expand Down Expand Up @@ -40,11 +40,11 @@ protected function getTransaction(): PostgresTransaction

protected function createNestedTransaction(
Transaction $transaction,
Executor $executor,
NestableTransactionExecutor $executor,
string $identifier,
\Closure $release,
): Transaction {
return new PostgresNestedTransaction($transaction, $executor, $identifier, $release);
): PostgresTransaction {
return new self($transaction, $executor, $identifier, $release);
}

public function prepare(string $sql): PostgresStatement
Expand Down
9 changes: 4 additions & 5 deletions src/PostgresConnectionPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Amp\Postgres;

use Amp\Future;
use Amp\Postgres\Internal\PostgresHandleConnection;
use Amp\Sql\Common\ConnectionPool;
use Amp\Sql\Result;
use Amp\Sql\SqlConnector;
Expand All @@ -12,11 +11,11 @@
use function Amp\async;

/**
* @extends ConnectionPool<PostgresConfig, PostgresResult, PostgresStatement, PostgresTransaction, PostgresHandleConnection>
* @extends ConnectionPool<PostgresConfig, PostgresResult, PostgresStatement, PostgresTransaction, PostgresConnection>
*/
final class PostgresConnectionPool extends ConnectionPool implements PostgresConnection
{
/** @var Future<PostgresHandleConnection>|null Connection used for notification listening. */
/** @var Future<PostgresConnection>|null Connection used for notification listening. */
private Future|null $listeningConnection = null;

/** @var int Number of listeners on listening connection. */
Expand All @@ -26,7 +25,7 @@ final class PostgresConnectionPool extends ConnectionPool implements PostgresCon
* @param positive-int $maxConnections
* @param positive-int $idleTimeout
* @param bool $resetConnections True to automatically execute DISCARD ALL on a connection before use.
* @param SqlConnector<PostgresConfig, PostgresHandleConnection>|null $connector
* @param SqlConnector<PostgresConfig, PostgresConnection>|null $connector
*/
public function __construct(
PostgresConfig $config,
Expand Down Expand Up @@ -64,7 +63,7 @@ protected function createTransaction(Transaction $transaction, \Closure $release
return new Internal\PostgresPooledTransaction($transaction, $release);
}

protected function pop(): PostgresHandleConnection
protected function pop(): PostgresConnection
{
$connection = parent::pop();

Expand Down

0 comments on commit 4c53678

Please sign in to comment.