Skip to content

Commit 238a8fb

Browse files
Ensure forward compatibility with ipl-sql by adding return types (#269)
Add explicit return types to `ipl-sql`-derived methods to prepare for strict typing. These additions are safe, as they only annotate existing methods that previously lacked return type declarations.
1 parent 7d65ada commit 238a8fb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

library/Reporting/RetryConnection.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55

66
namespace Icinga\Module\Reporting;
77

8+
use Exception;
89
use ipl\Sql\Connection;
10+
use PDOStatement;
911

1012
class RetryConnection extends Connection
1113
{
12-
public function prepexec($stmt, $values = null)
14+
public function prepexec($stmt, $values = null): PDOStatement
1315
{
1416
try {
1517
$sth = parent::prepexec($stmt, $values);
16-
} catch (\Exception $e) {
18+
} catch (Exception $e) {
1719
$lostConnection = Str::contains($e->getMessage(), [
1820
'server has gone away',
1921
'no connection to the server',
@@ -45,7 +47,7 @@ public function prepexec($stmt, $values = null)
4547

4648
try {
4749
$this->connect();
48-
} catch (\Exception $e) {
50+
} catch (Exception $e) {
4951
$noConnection = Str::contains($e->getMessage(), [
5052
'No such file or directory',
5153
'Connection refused'
@@ -55,7 +57,7 @@ public function prepexec($stmt, $values = null)
5557
throw $e;
5658
}
5759

58-
\sleep(10);
60+
sleep(10);
5961

6062
$this->connect();
6163
}

0 commit comments

Comments
 (0)