summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwn_ <[email protected]>2021-11-12 21:17:31 +0000
committerwn_ <[email protected]>2021-11-12 21:17:31 +0000
commitd3a81f598b24d6ae4f98415fac9509df6749eaf8 (patch)
tree79fcdaba8badc193595485c965e6150bcaaecd25
parent2c41bc7fbc9013e79e929a31e3824cf040afc54a (diff)
Switch class properties from PHP typing to PHPDoc for compatibility with PHP < 7.4.0
-rw-r--r--classes/db/migrations.php37
-rw-r--r--classes/debug.php48
-rw-r--r--classes/diskcache.php4
-rw-r--r--classes/mailer.php4
-rwxr-xr-xclasses/pluginhost.php41
-rw-r--r--classes/urlhelper.php32
6 files changed, 116 insertions, 50 deletions
diff --git a/classes/db/migrations.php b/classes/db/migrations.php
index cb74c247a..6e20ddf7f 100644
--- a/classes/db/migrations.php
+++ b/classes/db/migrations.php
@@ -1,16 +1,33 @@
<?php
class Db_Migrations {
- 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;
- private int $cached_max_version;
- private int $max_version_override;
+ // 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;
+
+ /** @var int */
+ private $cached_max_version;
+
+ /** @var int */
+ private $max_version_override;
function __construct() {
$this->pdo = Db::pdo();
diff --git a/classes/debug.php b/classes/debug.php
index 6e8c46ed2..e20126b86 100644
--- a/classes/debug.php
+++ b/classes/debug.php
@@ -1,9 +1,9 @@
<?php
class Debug {
const LOG_DISABLED = -1;
- const LOG_NORMAL = 0;
- const LOG_VERBOSE = 1;
- const LOG_EXTENDED = 2;
+ const LOG_NORMAL = 0;
+ const LOG_VERBOSE = 1;
+ const LOG_EXTENDED = 2;
const ALL_LOG_LEVELS = [
Debug::LOG_DISABLED,
@@ -12,26 +12,44 @@ class Debug {
Debug::LOG_EXTENDED,
];
- /** @deprecated */
- public static int $LOG_DISABLED = self::LOG_DISABLED;
+ // 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;
+
+ /**
+ * @deprecated
+ * @var int
+ */
+ public static $LOG_NORMAL = self::LOG_NORMAL;
- /** @deprecated */
- public static int $LOG_NORMAL = self::LOG_NORMAL;
+ /**
+ * @deprecated
+ * @var int
+ */
+ public static $LOG_VERBOSE = self::LOG_VERBOSE;
+
+ /**
+ * @deprecated
+ * @var int
+ */
+ public static $LOG_EXTENDED = self::LOG_EXTENDED;
- /** @deprecated */
- public static int $LOG_VERBOSE = self::LOG_VERBOSE;
+ /** @var bool */
+ private static $enabled = false;
- /** @deprecated */
- public static int $LOG_EXTENDED = self::LOG_EXTENDED;
+ /** @var bool */
+ private static $quiet = false;
- private static bool $enabled = false;
- private static bool $quiet = false;
- private static ?string $logfile = null;
+ /** @var string|null */
+ private static $logfile = null;
/**
* @var int Debug::LOG_*
*/
- private static int $loglevel = self::LOG_NORMAL;
+ private static $loglevel = self::LOG_NORMAL;
public static function set_logfile(string $logfile): void {
self::$logfile = $logfile;
diff --git a/classes/diskcache.php b/classes/diskcache.php
index 9fa043aee..ed334b2d2 100644
--- a/classes/diskcache.php
+++ b/classes/diskcache.php
@@ -1,6 +1,8 @@
<?php
class DiskCache {
- private string $dir;
+ // 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;
/**
* https://stackoverflow.com/a/53662733
diff --git a/classes/mailer.php b/classes/mailer.php
index 4eb13aec8..a0f232800 100644
--- a/classes/mailer.php
+++ b/classes/mailer.php
@@ -1,6 +1,8 @@
<?php
class Mailer {
- private string $last_error = "";
+ // 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 = "";
/**
* @param array<string, mixed> $params
diff --git a/classes/pluginhost.php b/classes/pluginhost.php
index 36e050377..173a75611 100755
--- a/classes/pluginhost.php
+++ b/classes/pluginhost.php
@@ -1,38 +1,49 @@
<?php
class PluginHost {
- private ?\Pdo $pdo = null;
+ // 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;
- /* separate handle for plugin data so transaction while saving wouldn't clash with possible main
- tt-rss code transactions; only initialized when first needed */
- private ?\Pdo $pdo_data = 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;
/** @var array<string, array<int, array<int, Plugin>>> hook types -> priority levels -> Plugins */
- private array $hooks = [];
+ private $hooks = [];
/** @var array<string, Plugin> */
- private array $plugins = [];
+ private $plugins = [];
/** @var array<string, array<string, Plugin>> handler type -> method type -> Plugin */
- private array $handlers = [];
+ private $handlers = [];
/** @var array<string, array{'description': string, 'suffix': string, 'arghelp': string, 'class': Plugin}> command type -> details array */
- private array $commands = [];
+ private $commands = [];
/** @var array<string, array<string, mixed>> plugin name -> (potential profile array) -> key -> value */
- private array $storage = [];
+ private $storage = [];
/** @var array<int, array<int, array{'id': int, 'title': string, 'sender': Plugin, 'icon': string}>> */
- private array $feeds = [];
+ private $feeds = [];
/** @var array<string, Plugin> API method name, Plugin sender */
- private array $api_methods = [];
+ private $api_methods = [];
/** @var array<string, array<int, array{'action': string, 'description': string, 'sender': Plugin}>> */
- private array $plugin_actions = [];
+ private $plugin_actions = [];
+
+ /** @var int|null */
+ private $owner_uid = null;
+
+ /** @var bool */
+ private $data_loaded = false;
- private ?int $owner_uid = null;
- private bool $data_loaded = false;
- private static ?PluginHost $instance = null;
+ /** @var PluginHost|null */
+ private static $instance = null;
const API_VERSION = 2;
const PUBLIC_METHOD_DELIMITER = "--";
diff --git a/classes/urlhelper.php b/classes/urlhelper.php
index 0592bf28c..351d66b8d 100644
--- a/classes/urlhelper.php
+++ b/classes/urlhelper.php
@@ -6,14 +6,30 @@ class UrlHelper {
"tel"
];
- 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;
+ // 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;
/**
* @param array<string, string|int> $parts