Skip to content

Commit 8e7f322

Browse files
Connection::prepexec(): Add strict type declaration
This change requires an adjustment in the sub-class `Icinga\Module\Reporting\RetryConnection` of the reporting module.
1 parent ffbf95e commit 8e7f322

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

src/Connection.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,15 @@ public function yieldPairs($stmt, ?array $values = null)
382382
/**
383383
* Prepare and execute the given statement
384384
*
385-
* @param Delete|Insert|Select|Update|string $stmt The SQL statement to prepare and execute
386-
* @param string|array $values Values to bind to the statement, if any
385+
* @param Delete|Insert|Select|Update|string $stmt The SQL statement to prepare and execute
386+
* @param string|array|null $values Values to bind to the statement, if any
387387
*
388-
* @return PDOStatement
388+
* @return false|PDOStatement
389389
*/
390-
public function prepexec($stmt, $values = null)
391-
{
390+
public function prepexec(
391+
Delete|Insert|Select|Update|string $stmt,
392+
string|array|null $values = null
393+
): false|PDOStatement {
392394
if ($values !== null && ! is_array($values)) {
393395
$values = [$values];
394396
}

src/Test/TestConnection.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
namespace ipl\Sql\Test;
44

55
use ipl\Sql\Connection;
6+
use ipl\Sql\Delete;
7+
use ipl\Sql\Insert;
8+
use ipl\Sql\Select;
9+
use ipl\Sql\Update;
10+
use PDOStatement;
611

712
/**
813
* Config-less test connection
@@ -34,8 +39,10 @@ public function rollbackTransaction()
3439
throw new \LogicException('Transactions are not supported by the test connection');
3540
}
3641

37-
public function prepexec($stmt, $values = null)
38-
{
42+
public function prepexec(
43+
Delete|Insert|Select|Update|string $stmt,
44+
string|array|null $values = null
45+
): false|PDOStatement {
3946
if (PHP_MAJOR_VERSION >= 8) {
4047
return new class extends \PDOStatement {
4148
public function getIterator(): \Iterator

0 commit comments

Comments
 (0)