From 8e7f322e582d6df55a34de0214bfac1135ab19ed Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Wed, 4 Mar 2026 14:57:11 +0100 Subject: [PATCH] `Connection::prepexec()`: Add strict type declaration This change requires an adjustment in the sub-class `Icinga\Module\Reporting\RetryConnection` of the reporting module. --- src/Connection.php | 12 +++++++----- src/Test/TestConnection.php | 11 +++++++++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/Connection.php b/src/Connection.php index 5c29713..7711ffb 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -382,13 +382,15 @@ public function yieldPairs($stmt, ?array $values = null) /** * Prepare and execute the given statement * - * @param Delete|Insert|Select|Update|string $stmt The SQL statement to prepare and execute - * @param string|array $values Values to bind to the statement, if any + * @param Delete|Insert|Select|Update|string $stmt The SQL statement to prepare and execute + * @param string|array|null $values Values to bind to the statement, if any * - * @return PDOStatement + * @return false|PDOStatement */ - public function prepexec($stmt, $values = null) - { + public function prepexec( + Delete|Insert|Select|Update|string $stmt, + string|array|null $values = null + ): false|PDOStatement { if ($values !== null && ! is_array($values)) { $values = [$values]; } diff --git a/src/Test/TestConnection.php b/src/Test/TestConnection.php index 11d0117..418c363 100644 --- a/src/Test/TestConnection.php +++ b/src/Test/TestConnection.php @@ -3,6 +3,11 @@ namespace ipl\Sql\Test; use ipl\Sql\Connection; +use ipl\Sql\Delete; +use ipl\Sql\Insert; +use ipl\Sql\Select; +use ipl\Sql\Update; +use PDOStatement; /** * Config-less test connection @@ -34,8 +39,10 @@ public function rollbackTransaction() throw new \LogicException('Transactions are not supported by the test connection'); } - public function prepexec($stmt, $values = null) - { + public function prepexec( + Delete|Insert|Select|Update|string $stmt, + string|array|null $values = null + ): false|PDOStatement { if (PHP_MAJOR_VERSION >= 8) { return new class extends \PDOStatement { public function getIterator(): \Iterator