aboutsummaryrefslogtreecommitdiff
path: root/lib/Minz/Pdo.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-03-31 08:23:39 +0200
committerGravatar GitHub <noreply@github.com> 2023-03-31 08:23:39 +0200
commit288ed04ccc30b58373576dc3be811aee43e67034 (patch)
tree27f4c571e04d64c97737416dfa2b8d65f481dfd8 /lib/Minz/Pdo.php
parentc9d5fe2da12cbc3a071ebf9a518afe2789bb3d61 (diff)
PHPStan level 6 for all PDO and Exception classes (#5239)
* PHPStan level 6 for all PDO and Exception classes Contributes to https://github.com/FreshRSS/FreshRSS/issues/4112 * Fix type * Now also our remaining own librairies * Motivation for a few more files * A few more DAO classes * Last interface
Diffstat (limited to 'lib/Minz/Pdo.php')
-rw-r--r--lib/Minz/Pdo.php25
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/Minz/Pdo.php b/lib/Minz/Pdo.php
index 8c9cd9076..2efff61d4 100644
--- a/lib/Minz/Pdo.php
+++ b/lib/Minz/Pdo.php
@@ -6,18 +6,20 @@
*/
abstract class Minz_Pdo extends PDO {
- public function __construct(string $dsn, $username = null, $passwd = null, $options = null) {
+ /** @param array<int,int|string>|null $options */
+ 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);
}
- abstract public function dbType();
+ abstract public function dbType(): string;
+ /** @var string */
private $prefix = '';
public function prefix(): string {
return $this->prefix;
}
- public function setPrefix(string $prefix) {
+ public function setPrefix(string $prefix): void {
$this->prefix = $prefix;
}
@@ -33,6 +35,10 @@ abstract class Minz_Pdo extends PDO {
}
// PHP8+: PDO::lastInsertId(?string $name = null): string|false
+ /**
+ * @param string|null $name
+ * @return string|false
+ */
#[\ReturnTypeWillChange]
public function lastInsertId($name = null) {
if ($name != null) {
@@ -42,6 +48,11 @@ abstract class Minz_Pdo extends PDO {
}
// PHP8+: PDO::prepare(string $query, array $options = []): PDOStatement|false
+ /**
+ * @param string $statement
+ * @param array<int,string>|null $driver_options
+ * @return PDOStatement|false
+ */
#[\ReturnTypeWillChange]
public function prepare($statement, $driver_options = []) {
$statement = $this->preSql($statement);
@@ -49,15 +60,19 @@ abstract class Minz_Pdo extends PDO {
}
// PHP8+: PDO::exec(string $statement): int|false
+ /**
+ * @param string $statement
+ * @return int|false
+ */
#[\ReturnTypeWillChange]
public function exec($statement) {
$statement = $this->preSql($statement);
return parent::exec($statement);
}
- // PHP8+: PDO::query(string $query, ?int $fetchMode = null, mixed ...$fetchModeArgs): PDOStatement|false
+ /** @return PDOStatement|false */
#[\ReturnTypeWillChange]
- public function query($query, $fetch_mode = null, ...$fetch_mode_args) {
+ public function query(string $query, ?int $fetch_mode = null, ...$fetch_mode_args) {
$query = $this->preSql($query);
return $fetch_mode ? parent::query($query, $fetch_mode, ...$fetch_mode_args) : parent::query($query);
}