diff options
| author | 2023-10-30 20:47:27 +0100 | |
|---|---|---|
| committer | 2023-10-30 20:47:27 +0100 | |
| commit | 06d00995049db9c7b915f67cfd4a5708aace458f (patch) | |
| tree | 0176ca9761b34d72ffd597bd96da3c3ae4912d86 /lib | |
| parent | 4a02352ccc1b313ce967415c6ac10a32aba1893a (diff) | |
Require PHP 7.4+ (#5720)
* Require PHP 7.4+
https://github.com/FreshRSS/FreshRSS/discussions/5474
* Update Docker oldest
Alpine 3.13 with PHP 7.4.26
* Add missing packets to Docker oldest
* Update to typed properties
https://php.net/migration74.new-features#migration74.new-features.core.typed-properties
* More types
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Minz/ActionController.php | 6 | ||||
| -rw-r--r-- | lib/Minz/Configuration.php | 15 | ||||
| -rw-r--r-- | lib/Minz/Dispatcher.php | 11 | ||||
| -rw-r--r-- | lib/Minz/Extension.php | 4 | ||||
| -rw-r--r-- | lib/Minz/ExtensionManager.php | 17 | ||||
| -rw-r--r-- | lib/Minz/FrontController.php | 3 | ||||
| -rw-r--r-- | lib/Minz/Mailer.php | 8 | ||||
| -rw-r--r-- | lib/Minz/Migrator.php | 6 | ||||
| -rw-r--r-- | lib/Minz/ModelArray.php | 3 | ||||
| -rw-r--r-- | lib/Minz/ModelPdo.php | 23 | ||||
| -rw-r--r-- | lib/Minz/Paginator.php | 18 | ||||
| -rw-r--r-- | lib/Minz/Pdo.php | 3 | ||||
| -rw-r--r-- | lib/Minz/Request.php | 17 | ||||
| -rw-r--r-- | lib/Minz/Session.php | 9 | ||||
| -rw-r--r-- | lib/Minz/Translate.php | 9 | ||||
| -rw-r--r-- | lib/Minz/View.php | 17 |
16 files changed, 67 insertions, 102 deletions
diff --git a/lib/Minz/ActionController.php b/lib/Minz/ActionController.php index 553862bab..68ef0695c 100644 --- a/lib/Minz/ActionController.php +++ b/lib/Minz/ActionController.php @@ -10,12 +10,12 @@ class Minz_ActionController { /** @var array<string,string> */ - private static $csp_default = [ + private static array $csp_default = [ 'default-src' => "'self'", ]; /** @var array<string,string> */ - private $csp_policies; + private array $csp_policies; /** @var Minz_View */ protected $view; @@ -25,7 +25,7 @@ class Minz_ActionController { * @var class-string * @deprecated Use constructor with view type instead */ - public static $defaultViewType = Minz_View::class; + public static string $defaultViewType = Minz_View::class; /** * @phpstan-param class-string|'' $viewType diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php index 91635c4e0..b667aa515 100644 --- a/lib/Minz/Configuration.php +++ b/lib/Minz/Configuration.php @@ -17,7 +17,7 @@ class Minz_Configuration { * The list of configurations. * @var array<string,static> */ - private static $config_list = array(); + private static array $config_list = array(); /** * Add a new configuration to the list of configuration. @@ -72,31 +72,28 @@ class Minz_Configuration { * Unused. * @phpstan-ignore-next-line */ - private $namespace = ''; + private string $namespace = ''; /** * The filename for the current configuration. - * @var string */ - private $config_filename = ''; + private string $config_filename = ''; /** * The filename for the current default values, null by default. - * @var string|null */ - private $default_filename = null; + private ?string $default_filename = null; /** * The configuration values, an empty array by default. * @var array<string,mixed> */ - private $data = array(); + private array $data = []; /** * An object which help to set good values in configuration. - * @var Minz_ConfigurationSetterInterface|null */ - private $configuration_setter; + private ?Minz_ConfigurationSetterInterface $configuration_setter = null; /** * Create a new Minz_Configuration object. diff --git a/lib/Minz/Dispatcher.php b/lib/Minz/Dispatcher.php index abc7efe21..da46ce6cd 100644 --- a/lib/Minz/Dispatcher.php +++ b/lib/Minz/Dispatcher.php @@ -12,15 +12,12 @@ class Minz_Dispatcher { /** * Singleton - * @var Minz_Dispatcher|null */ - private static $instance; - /** @var bool */ - private static $needsReset; + private static ?Minz_Dispatcher $instance = null; + private static bool $needsReset; /** @var array<string,string> */ - private static $registrations = []; - /** @var Minz_ActionController */ - private $controller; + private static array $registrations = []; + private Minz_ActionController $controller; /** * Retrieves the Dispatcher instance diff --git a/lib/Minz/Extension.php b/lib/Minz/Extension.php index 79ab269fa..8bc3ce964 100644 --- a/lib/Minz/Extension.php +++ b/lib/Minz/Extension.php @@ -26,10 +26,10 @@ abstract class Minz_Extension { private $system_configuration; /** @var array{0:'system',1:'user'} */ - public static $authorized_types = array( + public static array $authorized_types = [ 'system', 'user', - ); + ]; /** @var bool */ private $is_enabled; diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php index 88e793d39..fbb6d2a17 100644 --- a/lib/Minz/ExtensionManager.php +++ b/lib/Minz/ExtensionManager.php @@ -6,22 +6,21 @@ * @todo see coding style for methods!! */ final class Minz_ExtensionManager { - /** @var string */ - private static $ext_metaname = 'metadata.json'; - /** @var string */ - private static $ext_entry_point = 'extension.php'; + + private static string $ext_metaname = 'metadata.json'; + private static string $ext_entry_point = 'extension.php'; /** @var array<string,Minz_Extension> */ - private static $ext_list = array(); + private static array $ext_list = []; /** @var array<string,Minz_Extension> */ - private static $ext_list_enabled = array(); + private static array $ext_list_enabled = []; /** @var array<string,bool> */ - private static $ext_auto_enabled = array(); + private static array $ext_auto_enabled = []; /** * List of available hooks. Please keep this list sorted. * @var array<string,array{'list':array<callable>,'signature':'NoneToNone'|'NoneToString'|'OneToOne'|'PassArguments'}> */ - private static $hook_list = array( + private static array $hook_list = [ 'check_url_before_add' => array( // function($url) -> Url | null 'list' => array(), 'signature' => 'OneToOne', @@ -90,7 +89,7 @@ final class Minz_ExtensionManager { 'list' => array(), 'signature' => 'PassArguments', ), - ); + ]; /** Remove extensions and hooks from a previous initialisation */ private static function reset(): void { diff --git a/lib/Minz/FrontController.php b/lib/Minz/FrontController.php index e80ed12aa..d91fcfa68 100644 --- a/lib/Minz/FrontController.php +++ b/lib/Minz/FrontController.php @@ -25,8 +25,7 @@ */ class Minz_FrontController { - /** @var Minz_Dispatcher */ - protected $dispatcher; + protected Minz_Dispatcher $dispatcher; /** * Constructeur diff --git a/lib/Minz/Mailer.php b/lib/Minz/Mailer.php index 7cf99a667..efdc9ea03 100644 --- a/lib/Minz/Mailer.php +++ b/lib/Minz/Mailer.php @@ -32,12 +32,10 @@ class Minz_Mailer { */ protected $view; - /** @var string */ - private $mailer; + private string $mailer; /** @var array{'hostname':string,'host':string,'auth':bool,'username':string,'password':string,'secure':string,'port':int,'from':string} */ - private $smtp_config; - /** @var int */ - private $debug_level; + private array $smtp_config; + private int $debug_level; /** * Constructor. diff --git a/lib/Minz/Migrator.php b/lib/Minz/Migrator.php index 9508c0635..91a4e6cb1 100644 --- a/lib/Minz/Migrator.php +++ b/lib/Minz/Migrator.php @@ -9,11 +9,11 @@ */ class Minz_Migrator { - /** @var string[] */ - private $applied_versions; + /** @var array<string> */ + private array $applied_versions; /** @var array<callable> */ - private $migrations = []; + private array $migrations = []; /** * Execute a list of migrations, skipping versions indicated in a file diff --git a/lib/Minz/ModelArray.php b/lib/Minz/ModelArray.php index d2f518344..1b17c1da6 100644 --- a/lib/Minz/ModelArray.php +++ b/lib/Minz/ModelArray.php @@ -10,9 +10,8 @@ class Minz_ModelArray { /** * $filename est le nom du fichier - * @var string */ - protected $filename; + protected string $filename; /** * Ouvre le fichier indiqué, charge le tableau dans $array et le $filename diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php index 63d8be2ca..1e67fef9f 100644 --- a/lib/Minz/ModelPdo.php +++ b/lib/Minz/ModelPdo.php @@ -12,29 +12,16 @@ class Minz_ModelPdo { /** * Shares the connection to the database between all instances. - * @var bool */ - public static $usesSharedPdo = true; + public static bool $usesSharedPdo = true; - /** - * @var Minz_Pdo|null - */ - private static $sharedPdo; + private static ?Minz_Pdo $sharedPdo = null; - /** - * @var string|null - */ - private static $sharedCurrentUser; + private static ?string $sharedCurrentUser; - /** - * @var Minz_Pdo - */ - protected $pdo; + protected Minz_Pdo $pdo; - /** - * @var string|null - */ - protected $current_user; + protected ?string $current_user; /** * @throws Minz_ConfigurationNamespaceException diff --git a/lib/Minz/Paginator.php b/lib/Minz/Paginator.php index cf0e52440..6b185c8b8 100644 --- a/lib/Minz/Paginator.php +++ b/lib/Minz/Paginator.php @@ -11,27 +11,27 @@ class Minz_Paginator { /** * @var array<Minz_Model> tableau des éléments à afficher/gérer */ - private $items = array (); + private array $items = []; /** - * @var int le nombre d'éléments par page + * le nombre d'éléments par page */ - private $nbItemsPerPage = 10; + private int $nbItemsPerPage = 10; /** - * @var int page actuelle à gérer + * page actuelle à gérer */ - private $currentPage = 1; + private int $currentPage = 1; /** - * @var int le nombre de pages de pagination + * le nombre de pages de pagination */ - private $nbPage = 1; + private int $nbPage = 1; /** - * @var int le nombre d'éléments + * le nombre d'éléments */ - private $nbItems = 0; + private int $nbItems = 0; /** * Constructeur diff --git a/lib/Minz/Pdo.php b/lib/Minz/Pdo.php index 474602c52..477ce7c1f 100644 --- a/lib/Minz/Pdo.php +++ b/lib/Minz/Pdo.php @@ -14,8 +14,7 @@ abstract class Minz_Pdo extends PDO { abstract public function dbType(): string; - /** @var string */ - private $prefix = ''; + private string $prefix = ''; public function prefix(): string { return $this->prefix; } diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index c5adb02e1..af2ba1243 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -8,20 +8,17 @@ * Request représente la requête http */ class Minz_Request { - /** @var string */ - private static $controller_name = ''; - /** @var string */ - private static $action_name = ''; + + private static string $controller_name = ''; + private static string $action_name = ''; /** @var array<string,mixed> */ - private static $params = array(); + private static array $params = []; - /** @var string */ - private static $default_controller_name = 'index'; - /** @var string */ - private static $default_action_name = 'index'; + private static string $default_controller_name = 'index'; + private static string $default_action_name = 'index'; /** @var array{'c'?:string,'a'?:string,'params'?:array<string,mixed>} */ - private static $originalRequest = []; + private static array $originalRequest = []; /** * Getteurs diff --git a/lib/Minz/Session.php b/lib/Minz/Session.php index 421920e2e..137f66b7a 100644 --- a/lib/Minz/Session.php +++ b/lib/Minz/Session.php @@ -4,16 +4,13 @@ * The Minz_Session class handles user’s session */ class Minz_Session { - /** - * @var bool - */ - private static $volatile = false; + + private static bool $volatile = false; /** * For mutual exclusion. - * @var bool */ - private static $locked = false; + private static bool $locked = false; public static function lock(): bool { if (!self::$volatile && !self::$locked) { diff --git a/lib/Minz/Translate.php b/lib/Minz/Translate.php index ed9eca07c..1bb2438d1 100644 --- a/lib/Minz/Translate.php +++ b/lib/Minz/Translate.php @@ -13,25 +13,24 @@ class Minz_Translate { * $path_list is the list of registered base path to search translations. * @var array<string> */ - private static $path_list = array(); + private static array $path_list = []; /** * $lang_name is the name of the current language to use. - * @var string */ - private static $lang_name; + private static string $lang_name; /** * $lang_files is a list of registered i18n files. * @var array<string,array<string>> */ - private static $lang_files = array(); + private static array $lang_files = []; /** * $translates is a cache for i18n translation. * @var array<string,mixed> */ - private static $translates = array(); + private static array $translates = []; /** * Init the translation object. diff --git a/lib/Minz/View.php b/lib/Minz/View.php index 336b57dad..87b85e190 100644 --- a/lib/Minz/View.php +++ b/lib/Minz/View.php @@ -12,22 +12,19 @@ class Minz_View { private const LAYOUT_PATH_NAME = '/layout/'; private const LAYOUT_DEFAULT = 'layout'; - /** @var string */ - private $view_filename = ''; - /** @var string */ - private $layout_filename = ''; + private string $view_filename = ''; + private string $layout_filename = ''; /** @var array<string> */ - private static $base_pathnames = array(APP_PATH); - /** @var string */ - private static $title = ''; + private static array $base_pathnames = [APP_PATH]; + private static string $title = ''; /** @var array<array{'media':string,'url':string}> */ - private static $styles = []; + private static array $styles = []; /** @var array<array{'url':string,'id':string,'defer':bool,'async':bool}> */ - private static $scripts = []; + private static array $scripts = []; /** @var string|array{'dark'?:string,'light'?:string,'default'?:string} */ private static $themeColors; /** @var array<string,mixed> */ - private static $params = []; + private static array $params = []; /** * Determines if a layout is used or not |
