Skip to content

Commit

Permalink
Restore library-specific return types
Browse files Browse the repository at this point in the history
The order of interface declarations is important to avoid a PHP bug validating method prototypes.
  • Loading branch information
trowski committed Dec 7, 2023
1 parent 42a5e1f commit 6edd4e7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/PostgresConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* @extends Connection<PostgresConfig, PostgresResult, PostgresStatement, PostgresTransaction>
*/
interface PostgresConnection extends Connection, PostgresLink
interface PostgresConnection extends PostgresLink, Connection
{
/**
* @return PostgresConfig Config object specific to this library.
Expand Down
17 changes: 16 additions & 1 deletion src/PostgresExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,23 @@
/**
* @extends Executor<PostgresResult, PostgresStatement>
*/
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.
Expand Down
6 changes: 5 additions & 1 deletion src/PostgresLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
/**
* @extends Link<PostgresResult, PostgresStatement, PostgresTransaction>
*/
interface PostgresLink extends Link, PostgresExecutor
interface PostgresLink extends PostgresExecutor, Link
{
/**
* @return PostgresTransaction Transaction object specific to this library.
*/
public function beginTransaction(): PostgresTransaction;
}
2 changes: 1 addition & 1 deletion src/PostgresTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
*
* @extends Transaction<PostgresResult, PostgresStatement, PostgresTransaction>
*/
interface PostgresTransaction extends Transaction, PostgresLink
interface PostgresTransaction extends PostgresLink, Transaction
{
}

0 comments on commit 6edd4e7

Please sign in to comment.