aboutsummaryrefslogtreecommitdiff
path: root/lib/Minz
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Minz')
-rw-r--r--lib/Minz/ActionException.php2
-rw-r--r--lib/Minz/Configuration.php2
-rw-r--r--lib/Minz/ConfigurationException.php2
-rw-r--r--lib/Minz/ControllerNotActionControllerException.php2
-rw-r--r--lib/Minz/ControllerNotExistException.php2
-rw-r--r--lib/Minz/CurrentPagePaginationException.php2
-rw-r--r--lib/Minz/Error.php4
-rw-r--r--lib/Minz/Exception.php2
-rw-r--r--lib/Minz/ExtensionException.php2
-rw-r--r--lib/Minz/FileNotExistException.php2
-rw-r--r--lib/Minz/Helper.php2
-rw-r--r--lib/Minz/Mailer.php3
-rw-r--r--lib/Minz/ModelPdo.php1
-rw-r--r--lib/Minz/PDOConnectionException.php2
-rw-r--r--lib/Minz/Pdo.php25
-rw-r--r--lib/Minz/PdoMysql.php8
-rw-r--r--lib/Minz/PdoPgsql.php3
-rw-r--r--lib/Minz/PdoSqlite.php8
-rw-r--r--lib/Minz/PermissionDeniedException.php2
19 files changed, 53 insertions, 23 deletions
diff --git a/lib/Minz/ActionException.php b/lib/Minz/ActionException.php
index 53f0aab04..3c08b4892 100644
--- a/lib/Minz/ActionException.php
+++ b/lib/Minz/ActionException.php
@@ -1,6 +1,6 @@
<?php
class Minz_ActionException extends Minz_Exception {
- public function __construct ($controller_name, $action_name, $code = self::ERROR) {
+ public function __construct(string $controller_name, string $action_name, int $code = self::ERROR) {
// Just for security, as we are not supposed to get non-alphanumeric characters.
$action_name = rawurlencode($action_name);
diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php
index 6d4aed0ab..a9a4ae03a 100644
--- a/lib/Minz/Configuration.php
+++ b/lib/Minz/Configuration.php
@@ -8,7 +8,7 @@
* @property-read string $environment
* @property-read array<string> $extensions_enabled
* @property-read string $mailer
- * @property-read string $smtp
+ * @property-read array<string|int|bool> $smtp
* @property string $title
*/
class Minz_Configuration {
diff --git a/lib/Minz/ConfigurationException.php b/lib/Minz/ConfigurationException.php
index f294c3341..498420a67 100644
--- a/lib/Minz/ConfigurationException.php
+++ b/lib/Minz/ConfigurationException.php
@@ -1,7 +1,7 @@
<?php
class Minz_ConfigurationException extends Minz_Exception {
- public function __construct($error, $code = self::ERROR) {
+ public function __construct(string $error, int $code = self::ERROR) {
$message = 'Configuration error: ' . $error;
parent::__construct($message, $code);
}
diff --git a/lib/Minz/ControllerNotActionControllerException.php b/lib/Minz/ControllerNotActionControllerException.php
index 5cf418404..19e5df1b4 100644
--- a/lib/Minz/ControllerNotActionControllerException.php
+++ b/lib/Minz/ControllerNotActionControllerException.php
@@ -1,6 +1,6 @@
<?php
class Minz_ControllerNotActionControllerException extends Minz_Exception {
- public function __construct ($controller_name, $code = self::ERROR) {
+ public function __construct(string $controller_name, int $code = self::ERROR) {
$message = 'Controller `' . $controller_name . '` isn’t instance of ActionController';
parent::__construct ($message, $code);
diff --git a/lib/Minz/ControllerNotExistException.php b/lib/Minz/ControllerNotExistException.php
index a024e1cbd..2d2178974 100644
--- a/lib/Minz/ControllerNotExistException.php
+++ b/lib/Minz/ControllerNotExistException.php
@@ -1,6 +1,6 @@
<?php
class Minz_ControllerNotExistException extends Minz_Exception {
- public function __construct ($code = self::ERROR) {
+ public function __construct(int $code = self::ERROR) {
$message = 'Controller not found!';
parent::__construct ($message, $code);
}
diff --git a/lib/Minz/CurrentPagePaginationException.php b/lib/Minz/CurrentPagePaginationException.php
index 3e3d9d1b4..973913afb 100644
--- a/lib/Minz/CurrentPagePaginationException.php
+++ b/lib/Minz/CurrentPagePaginationException.php
@@ -1,6 +1,6 @@
<?php
class Minz_CurrentPagePaginationException extends Minz_Exception {
- public function __construct ($page) {
+ public function __construct(int $page) {
$message = 'Page number `' . $page . '` doesn\'t exist';
parent::__construct ($message, self::ERROR);
diff --git a/lib/Minz/Error.php b/lib/Minz/Error.php
index 3162c6f99..e23499a10 100644
--- a/lib/Minz/Error.php
+++ b/lib/Minz/Error.php
@@ -19,7 +19,7 @@ class Minz_Error {
* > $logs['notice']
* @param bool $redirect indique s'il faut forcer la redirection (les logs ne seront pas transmis)
*/
- public static function error ($code = 404, $logs = array (), $redirect = true) {
+ public static function error(int $code = 404, array $logs = [], bool $redirect = true): void {
$logs = self::processLogs ($logs);
$error_filename = APP_PATH . '/Controllers/errorController.php';
@@ -52,7 +52,7 @@ class Minz_Error {
* @param array<string,string>|string $logs logs sorted by category (error, warning, notice)
* @return array<string> list of matching logs, without the category, according to environment preferences (production / development)
*/
- private static function processLogs ($logs) {
+ private static function processLogs($logs) {
$conf = Minz_Configuration::get('system');
$env = $conf->environment;
$logs_ok = array ();
diff --git a/lib/Minz/Exception.php b/lib/Minz/Exception.php
index b5e71e0d8..f2d3b876b 100644
--- a/lib/Minz/Exception.php
+++ b/lib/Minz/Exception.php
@@ -4,7 +4,7 @@ class Minz_Exception extends Exception {
const WARNING = 10;
const NOTICE = 20;
- public function __construct ($message, $code = self::ERROR) {
+ public function __construct(string $message, int $code = self::ERROR) {
if ($code != Minz_Exception::ERROR
&& $code != Minz_Exception::WARNING
&& $code != Minz_Exception::NOTICE) {
diff --git a/lib/Minz/ExtensionException.php b/lib/Minz/ExtensionException.php
index b86a97798..c5bba60a9 100644
--- a/lib/Minz/ExtensionException.php
+++ b/lib/Minz/ExtensionException.php
@@ -1,7 +1,7 @@
<?php
class Minz_ExtensionException extends Minz_Exception {
- public function __construct ($message, $extension_name = false, $code = self::ERROR) {
+ public function __construct(string $message, ?string $extension_name = null, int $code = self::ERROR) {
if ($extension_name) {
$message = 'An error occurred in `' . $extension_name . '` extension with the message: ' . $message;
} else {
diff --git a/lib/Minz/FileNotExistException.php b/lib/Minz/FileNotExistException.php
index f97f161af..b467a5208 100644
--- a/lib/Minz/FileNotExistException.php
+++ b/lib/Minz/FileNotExistException.php
@@ -1,6 +1,6 @@
<?php
class Minz_FileNotExistException extends Minz_Exception {
- public function __construct ($file_name, $code = self::ERROR) {
+ public function __construct(string $file_name, int $code = self::ERROR) {
$message = 'File not found: `' . $file_name.'`';
parent::__construct ($message, $code);
diff --git a/lib/Minz/Helper.php b/lib/Minz/Helper.php
index 2c011e1bf..3e09c4758 100644
--- a/lib/Minz/Helper.php
+++ b/lib/Minz/Helper.php
@@ -12,6 +12,8 @@ class Minz_Helper {
/**
* Wrapper for htmlspecialchars.
* Force UTf-8 value and can be used on array too.
+ * @param string|array<string> $var
+ * @return string|array<string>
*/
public static function htmlspecialchars_utf8($var) {
if (is_array($var)) {
diff --git a/lib/Minz/Mailer.php b/lib/Minz/Mailer.php
index 92e396f99..ba434ec8f 100644
--- a/lib/Minz/Mailer.php
+++ b/lib/Minz/Mailer.php
@@ -32,8 +32,11 @@ class Minz_Mailer {
*/
protected $view;
+ /** @var string */
private $mailer;
+ /** @var array<string|int|bool> */
private $smtp_config;
+ /** @var int */
private $debug_level;
/**
diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php
index b8c1ad89b..0e813ddca 100644
--- a/lib/Minz/ModelPdo.php
+++ b/lib/Minz/ModelPdo.php
@@ -12,6 +12,7 @@ class Minz_ModelPdo {
/**
* Shares the connection to the database between all instances.
+ * @var bool
*/
public static $usesSharedPdo = true;
diff --git a/lib/Minz/PDOConnectionException.php b/lib/Minz/PDOConnectionException.php
index 11e4d1029..2b015607e 100644
--- a/lib/Minz/PDOConnectionException.php
+++ b/lib/Minz/PDOConnectionException.php
@@ -1,6 +1,6 @@
<?php
class Minz_PDOConnectionException extends Minz_Exception {
- public function __construct ($error, $user, $code = self::ERROR) {
+ public function __construct(string $error, string $user, int $code = self::ERROR) {
$message = 'Access to database is denied for `' . $user . '`: ' . $error;
parent::__construct ($message, $code);
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);
}
diff --git a/lib/Minz/PdoMysql.php b/lib/Minz/PdoMysql.php
index b66cccf28..ee411d949 100644
--- a/lib/Minz/PdoMysql.php
+++ b/lib/Minz/PdoMysql.php
@@ -6,7 +6,8 @@
*/
class Minz_PdoMysql extends Minz_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::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
}
@@ -15,7 +16,10 @@ class Minz_PdoMysql extends Minz_Pdo {
return 'mysql';
}
- // PHP8+: PDO::lastInsertId(?string $name = null): string|false
+ /**
+ * @param string|null $name
+ * @return string|false
+ */
#[\ReturnTypeWillChange]
public function lastInsertId($name = null) {
return parent::lastInsertId(); //We discard the name, only used by PostgreSQL
diff --git a/lib/Minz/PdoPgsql.php b/lib/Minz/PdoPgsql.php
index cae0fe476..b239d3544 100644
--- a/lib/Minz/PdoPgsql.php
+++ b/lib/Minz/PdoPgsql.php
@@ -6,7 +6,8 @@
*/
class Minz_PdoPgsql extends Minz_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->exec("SET NAMES 'UTF8';");
}
diff --git a/lib/Minz/PdoSqlite.php b/lib/Minz/PdoSqlite.php
index 2c90413a1..479879ffe 100644
--- a/lib/Minz/PdoSqlite.php
+++ b/lib/Minz/PdoSqlite.php
@@ -6,7 +6,8 @@
*/
class Minz_PdoSqlite extends Minz_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->exec('PRAGMA foreign_keys = ON;');
}
@@ -15,7 +16,10 @@ class Minz_PdoSqlite extends Minz_Pdo {
return 'sqlite';
}
- // PHP8+: PDO::lastInsertId(?string $name = null): string|false
+ /**
+ * @param string|null $name
+ * @return string|false
+ */
#[\ReturnTypeWillChange]
public function lastInsertId($name = null) {
return parent::lastInsertId(); //We discard the name, only used by PostgreSQL
diff --git a/lib/Minz/PermissionDeniedException.php b/lib/Minz/PermissionDeniedException.php
index 61be530d3..91a4b310e 100644
--- a/lib/Minz/PermissionDeniedException.php
+++ b/lib/Minz/PermissionDeniedException.php
@@ -1,6 +1,6 @@
<?php
class Minz_PermissionDeniedException extends Minz_Exception {
- public function __construct ($file_name, $code = self::ERROR) {
+ public function __construct(string $file_name, int $code = self::ERROR) {
$message = 'Permission is denied for `' . $file_name.'`';
parent::__construct ($message, $code);