Switch to direct type declarations of class properties.
This commit is contained in:
parent
ed2cbeffcc
commit
93fd85df6f
|
@ -1,33 +1,15 @@
|
|||
<?php
|
||||
class Db_Migrations {
|
||||
|
||||
// TODO: class properties can be switched to PHP typing if/when the minimum PHP_VERSION is raised to 7.4.0+
|
||||
/** @var string */
|
||||
private $base_filename = "schema.sql";
|
||||
|
||||
/** @var string */
|
||||
private $base_path;
|
||||
|
||||
/** @var string */
|
||||
private $migrations_path;
|
||||
|
||||
/** @var string */
|
||||
private $migrations_table;
|
||||
|
||||
/** @var bool */
|
||||
private $base_is_latest;
|
||||
|
||||
/** @var PDO */
|
||||
private $pdo;
|
||||
|
||||
/** @var int */
|
||||
private $cached_version = 0;
|
||||
|
||||
/** @var int */
|
||||
private $cached_max_version = 0;
|
||||
|
||||
/** @var int */
|
||||
private $max_version_override;
|
||||
private string $base_filename = "schema.sql";
|
||||
private string $base_path;
|
||||
private string $migrations_path;
|
||||
private string $migrations_table;
|
||||
private bool $base_is_latest;
|
||||
private PDO $pdo;
|
||||
private int $cached_version = 0;
|
||||
private int $cached_max_version = 0;
|
||||
private int $max_version_override;
|
||||
|
||||
function __construct() {
|
||||
$this->pdo = Db::pdo();
|
||||
|
|
|
@ -12,44 +12,31 @@ class Debug {
|
|||
Debug::LOG_EXTENDED,
|
||||
];
|
||||
|
||||
// TODO: class properties can be switched to PHP typing if/when the minimum PHP_VERSION is raised to 7.4.0+
|
||||
/**
|
||||
* @deprecated
|
||||
* @var int
|
||||
*/
|
||||
public static $LOG_DISABLED = self::LOG_DISABLED;
|
||||
public static int $LOG_DISABLED = self::LOG_DISABLED;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @var int
|
||||
*/
|
||||
public static $LOG_NORMAL = self::LOG_NORMAL;
|
||||
public static int $LOG_NORMAL = self::LOG_NORMAL;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @var int
|
||||
*/
|
||||
public static $LOG_VERBOSE = self::LOG_VERBOSE;
|
||||
public static int $LOG_VERBOSE = self::LOG_VERBOSE;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @var int
|
||||
*/
|
||||
public static $LOG_EXTENDED = self::LOG_EXTENDED;
|
||||
public static int $LOG_EXTENDED = self::LOG_EXTENDED;
|
||||
|
||||
/** @var bool */
|
||||
private static $enabled = false;
|
||||
private static bool $enabled = false;
|
||||
private static bool $quiet = false;
|
||||
private static ?string $logfile = null;
|
||||
|
||||
/** @var bool */
|
||||
private static $quiet = false;
|
||||
|
||||
/** @var string|null */
|
||||
private static $logfile = null;
|
||||
|
||||
/**
|
||||
* @var int Debug::LOG_*
|
||||
*/
|
||||
private static $loglevel = self::LOG_NORMAL;
|
||||
private static int $loglevel = self::LOG_NORMAL;
|
||||
|
||||
public static function set_logfile(string $logfile): void {
|
||||
self::$logfile = $logfile;
|
||||
|
@ -70,7 +57,7 @@ class Debug {
|
|||
/**
|
||||
* @param Debug::LOG_* $level
|
||||
*/
|
||||
public static function set_loglevel($level): void {
|
||||
public static function set_loglevel(int $level): void {
|
||||
self::$loglevel = $level;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
<?php
|
||||
class DiskCache {
|
||||
// TODO: class properties can be switched to PHP typing if/when the minimum PHP_VERSION is raised to 7.4.0+
|
||||
/** @var string */
|
||||
private $dir;
|
||||
private string $dir;
|
||||
|
||||
/**
|
||||
* https://stackoverflow.com/a/53662733
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
private $mimeMap = [
|
||||
private array $mimeMap = [
|
||||
'video/3gpp2' => '3g2',
|
||||
'video/3gp' => '3gp',
|
||||
'video/3gpp' => '3gp',
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
<?php
|
||||
class Handler implements IHandler {
|
||||
// TODO: class properties can be switched to PHP typing if/when the minimum PHP_VERSION is raised to 7.4.0+
|
||||
/** @var PDO */
|
||||
protected $pdo;
|
||||
protected PDO $pdo;
|
||||
|
||||
/** @var array<int|string, mixed> */
|
||||
protected $args;
|
||||
protected array $args;
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $args
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
class Mailer {
|
||||
// TODO: class properties can be switched to PHP typing if/when the minimum PHP_VERSION is raised to 7.4.0+
|
||||
/** @var string */
|
||||
private $last_error = "";
|
||||
private string $last_error = "";
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $params
|
||||
|
|
|
@ -1,49 +1,42 @@
|
|||
<?php
|
||||
class PluginHost {
|
||||
// TODO: class properties can be switched to PHP typing if/when the minimum PHP_VERSION is raised to 7.4.0+
|
||||
/** @var PDO|null */
|
||||
private $pdo = null;
|
||||
private ?PDO $pdo = null;
|
||||
|
||||
/**
|
||||
* separate handle for plugin data so transaction while saving wouldn't clash with possible main
|
||||
* tt-rss code transactions; only initialized when first needed
|
||||
*
|
||||
* @var PDO|null
|
||||
*/
|
||||
private $pdo_data = null;
|
||||
private ?PDO $pdo_data = null;
|
||||
|
||||
/** @var array<string, array<int, array<int, Plugin>>> hook types -> priority levels -> Plugins */
|
||||
private $hooks = [];
|
||||
private array $hooks = [];
|
||||
|
||||
/** @var array<string, Plugin> */
|
||||
private $plugins = [];
|
||||
private array $plugins = [];
|
||||
|
||||
/** @var array<string, array<string, Plugin>> handler type -> method type -> Plugin */
|
||||
private $handlers = [];
|
||||
private array $handlers = [];
|
||||
|
||||
/** @var array<string, array{'description': string, 'suffix': string, 'arghelp': string, 'class': Plugin}> command type -> details array */
|
||||
private $commands = [];
|
||||
private array $commands = [];
|
||||
|
||||
/** @var array<string, array<string, mixed>> plugin name -> (potential profile array) -> key -> value */
|
||||
private $storage = [];
|
||||
private array $storage = [];
|
||||
|
||||
/** @var array<int, array<int, array{'id': int, 'title': string, 'sender': Plugin, 'icon': string}>> */
|
||||
private $feeds = [];
|
||||
private array $feeds = [];
|
||||
|
||||
/** @var array<string, Plugin> API method name, Plugin sender */
|
||||
private $api_methods = [];
|
||||
private array $api_methods = [];
|
||||
|
||||
/** @var array<string, array<int, array{'action': string, 'description': string, 'sender': Plugin}>> */
|
||||
private $plugin_actions = [];
|
||||
private array $plugin_actions = [];
|
||||
|
||||
/** @var int|null */
|
||||
private $owner_uid = null;
|
||||
private ?int $owner_uid = null;
|
||||
|
||||
/** @var bool */
|
||||
private $data_loaded = false;
|
||||
private bool $data_loaded = false;
|
||||
|
||||
/** @var PluginHost|null */
|
||||
private static $instance = null;
|
||||
private static ?PluginHost $instance = null;
|
||||
|
||||
const API_VERSION = 2;
|
||||
const PUBLIC_METHOD_DELIMITER = "--";
|
||||
|
|
|
@ -2,18 +2,17 @@
|
|||
use chillerlan\QRCode;
|
||||
|
||||
class Pref_Prefs extends Handler_Protected {
|
||||
// TODO: class properties can be switched to PHP typing if/when the minimum PHP_VERSION is raised to 7.4.0+
|
||||
/** @var array<Prefs::*, array<int, string>> */
|
||||
private $pref_help = [];
|
||||
private array $pref_help = [];
|
||||
|
||||
/** @var array<string, array<int, string>> pref items are Prefs::*|Pref_Prefs::BLOCK_SEPARATOR (PHPStan was complaining) */
|
||||
private $pref_item_map = [];
|
||||
private array $pref_item_map = [];
|
||||
|
||||
/** @var array<string, string> */
|
||||
private $pref_help_bottom = [];
|
||||
private array $pref_help_bottom = [];
|
||||
|
||||
/** @var array<int, string> */
|
||||
private $pref_blacklist = [];
|
||||
private array $pref_blacklist = [];
|
||||
|
||||
private const BLOCK_SEPARATOR = 'BLOCK_SEPARATOR';
|
||||
|
||||
|
@ -26,7 +25,6 @@ class Pref_Prefs extends Handler_Protected {
|
|||
const PI_ERR_PLUGIN_NOT_FOUND = "PI_ERR_PLUGIN_NOT_FOUND";
|
||||
const PI_ERR_NO_WORKDIR = "PI_ERR_NO_WORKDIR";
|
||||
|
||||
/** @param string $method */
|
||||
function csrf_ignore(string $method) : bool {
|
||||
$csrf_ignored = array("index", "updateself", "otpqrcode");
|
||||
|
||||
|
|
|
@ -10,31 +10,14 @@ class UrlHelper {
|
|||
"application/x-bittorrent" => [ "magnet" ],
|
||||
];
|
||||
|
||||
// TODO: class properties can be switched to PHP typing if/when the minimum PHP_VERSION is raised to 7.4.0+
|
||||
/** @var string */
|
||||
static $fetch_last_error;
|
||||
|
||||
/** @var int */
|
||||
static $fetch_last_error_code;
|
||||
|
||||
/** @var string */
|
||||
static $fetch_last_error_content;
|
||||
|
||||
/** @var string */
|
||||
static $fetch_last_content_type;
|
||||
|
||||
/** @var string */
|
||||
static $fetch_last_modified;
|
||||
|
||||
|
||||
/** @var string */
|
||||
static $fetch_effective_url;
|
||||
|
||||
/** @var string */
|
||||
static $fetch_effective_ip_addr;
|
||||
|
||||
/** @var bool */
|
||||
static $fetch_curl_used;
|
||||
static string $fetch_last_error;
|
||||
static int $fetch_last_error_code;
|
||||
static string $fetch_last_error_content;
|
||||
static string $fetch_last_content_type;
|
||||
static string $fetch_last_modified;
|
||||
static string $fetch_effective_url;
|
||||
static string $fetch_effective_ip_addr;
|
||||
static bool $fetch_curl_used;
|
||||
|
||||
/**
|
||||
* @param array<string, string|int> $parts
|
||||
|
|
Loading…
Reference in New Issue