From 6edd4e7df40b5878959476e1e45528d1ad4cd2f3 Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Thu, 7 Dec 2023 10:10:19 -0600 Subject: [PATCH] Restore library-specific return types The order of interface declarations is important to avoid a PHP bug validating method prototypes. --- src/PostgresConnection.php | 2 +- src/PostgresExecutor.php | 17 ++++++++++++++++- src/PostgresLink.php | 6 +++++- src/PostgresTransaction.php | 2 +- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/PostgresConnection.php b/src/PostgresConnection.php index a840d73..67742dc 100644 --- a/src/PostgresConnection.php +++ b/src/PostgresConnection.php @@ -10,7 +10,7 @@ /** * @extends Connection */ -interface PostgresConnection extends Connection, PostgresLink +interface PostgresConnection extends PostgresLink, Connection { /** * @return PostgresConfig Config object specific to this library. diff --git a/src/PostgresExecutor.php b/src/PostgresExecutor.php index 209898a..fcbc262 100644 --- a/src/PostgresExecutor.php +++ b/src/PostgresExecutor.php @@ -9,8 +9,23 @@ /** * @extends Executor */ -interface PostgresExecutor extends Executor, PostgresQuoter +interface PostgresExecutor extends PostgresQuoter, Executor { + /** + * @return PostgresResult Result object specific to this library. + */ + public function query(string $sql): PostgresResult; + + /** + * @return PostgresStatement Statement object specific to this library. + */ + public function prepare(string $sql): PostgresStatement; + + /** + * @return PostgresResult Result object specific to this library. + */ + public function execute(string $sql, array $params = []): PostgresResult; + /** * @param non-empty-string $channel Channel name. * @param string $payload Notification payload. diff --git a/src/PostgresLink.php b/src/PostgresLink.php index a0c08a7..361964f 100644 --- a/src/PostgresLink.php +++ b/src/PostgresLink.php @@ -7,6 +7,10 @@ /** * @extends Link */ -interface PostgresLink extends Link, PostgresExecutor +interface PostgresLink extends PostgresExecutor, Link { + /** + * @return PostgresTransaction Transaction object specific to this library. + */ + public function beginTransaction(): PostgresTransaction; } diff --git a/src/PostgresTransaction.php b/src/PostgresTransaction.php index 9c9e9b3..55904be 100644 --- a/src/PostgresTransaction.php +++ b/src/PostgresTransaction.php @@ -9,6 +9,6 @@ * * @extends Transaction */ -interface PostgresTransaction extends Transaction, PostgresLink +interface PostgresTransaction extends PostgresLink, Transaction { }