aboutsummaryrefslogtreecommitdiff
path: root/lib/Minz/Pdo.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-01-15 10:36:30 +0100
committerGravatar GitHub <noreply@github.com> 2024-01-15 10:36:30 +0100
commit314077a457f04cc2f0472e036af029e2676fbf02 (patch)
tree1f38bb78761a56b8ee2034caba0dbda3912ef7c1 /lib/Minz/Pdo.php
parent52f6c8399b41e0c8be49dd56c89f451843189791 (diff)
PHPStan prepare exceptions (#6037)
Take advantage of https://phpstan.org/blog/bring-your-exceptions-under-control Minimum changes to pass `tooWideThrowType` and `implicitThrows`. Revert some mistakes from: https://github.com/FreshRSS/FreshRSS/pull/5504 Preparation needed before new PRs of the same type: https://github.com/FreshRSS/FreshRSS/pull/5962 Fix several wrong PHPDocs and catches: > Method ... has ...Exception in PHPDoc @throws tag but it's not thrown. > Dead catch - ...Exception is never thrown in the try block.
Diffstat (limited to 'lib/Minz/Pdo.php')
-rw-r--r--lib/Minz/Pdo.php15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/Minz/Pdo.php b/lib/Minz/Pdo.php
index 3d613e832..2f053c2af 100644
--- a/lib/Minz/Pdo.php
+++ b/lib/Minz/Pdo.php
@@ -7,7 +7,10 @@ declare(strict_types=1);
*/
abstract class Minz_Pdo extends PDO {
- /** @param array<int,int|string|bool>|null $options */
+ /**
+ * @param array<int,int|string|bool>|null $options
+ * @throws PDOException
+ */
public function __construct(string $dsn, ?string $username = null, ?string $passwd = null, ?array $options = null) {
parent::__construct($dsn, $username, $passwd, $options);
$this->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
@@ -38,6 +41,7 @@ abstract class Minz_Pdo extends PDO {
/**
* @param string|null $name
* @return string|false
+ * @throws PDOException if the attribute `PDO::ATTR_ERRMODE` is set to `PDO::ERRMODE_EXCEPTION`
*/
#[\ReturnTypeWillChange]
public function lastInsertId($name = null) {
@@ -52,6 +56,7 @@ abstract class Minz_Pdo extends PDO {
* @param string $query
* @param array<int,string> $options
* @return PDOStatement|false
+ * @throws PDOException if the attribute `PDO::ATTR_ERRMODE` is set to `PDO::ERRMODE_EXCEPTION`
* @phpstan-ignore-next-line
*/
#[\ReturnTypeWillChange]
@@ -64,6 +69,8 @@ abstract class Minz_Pdo extends PDO {
/**
* @param string $statement
* @return int|false
+ * @throws PDOException if the attribute `PDO::ATTR_ERRMODE` is set to `PDO::ERRMODE_EXCEPTION`
+ * @phpstan-ignore-next-line
*/
#[\ReturnTypeWillChange]
public function exec($statement) {
@@ -71,7 +78,11 @@ abstract class Minz_Pdo extends PDO {
return parent::exec($statement);
}
- /** @return PDOStatement|false */
+ /**
+ * @return PDOStatement|false
+ * @throws PDOException if the attribute `PDO::ATTR_ERRMODE` is set to `PDO::ERRMODE_EXCEPTION`
+ * @phpstan-ignore-next-line
+ */
#[\ReturnTypeWillChange]
public function query(string $query, ?int $fetch_mode = null, ...$fetch_mode_args) {
$query = $this->preSql($query);