summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorfox <[email protected]>2021-11-02 08:37:11 +0300
committerfox <[email protected]>2021-11-02 08:37:11 +0300
commit7a52560e4e3b0652d32645b60ae13e4904f606bc (patch)
tree42b5748e6fc518a48adf52ec97a2f084acbfd036 /classes
parent9714c4fbcf76492d084ca5327cbab1ad1b662280 (diff)
parent57436ee0c184c5fa362c66f8383a8a3b29f171cf (diff)
Merge pull request 'PHPStan 1.0.0 and related warning fixes' (#49) from wn/tt-rss:feature/phpstan-1.0.0-and-fixes into master
Reviewed-on: https://git.tt-rss.org/fox/tt-rss/pulls/49
Diffstat (limited to 'classes')
-rw-r--r--classes/config.php11
-rwxr-xr-xclasses/db.php4
-rwxr-xr-xclasses/feeditem/common.php1
-rwxr-xr-xclasses/feeds.php2
-rwxr-xr-xclasses/logger/sql.php2
-rwxr-xr-xclasses/pluginhost.php5
-rw-r--r--classes/pref/prefs.php2
-rw-r--r--classes/pref/users.php2
-rw-r--r--classes/urlhelper.php11
9 files changed, 15 insertions, 25 deletions
diff --git a/classes/config.php b/classes/config.php
index be4ecde36..53a31b61c 100644
--- a/classes/config.php
+++ b/classes/config.php
@@ -234,10 +234,9 @@ class Config {
private static $instance;
private $params = [];
- private $schema_version = null;
private $version = [];
- /** @var Db_Migrations $migrations */
+ /** @var Db_Migrations|null $migrations */
private $migrations;
public static function get_instance() : Config {
@@ -255,10 +254,10 @@ class Config {
$ref = new ReflectionClass(get_class($this));
foreach ($ref->getConstants() as $const => $cvalue) {
- if (isset($this::_DEFAULTS[$const])) {
- $override = getenv($this::_ENVVAR_PREFIX . $const);
+ if (isset(self::_DEFAULTS[$const])) {
+ $override = getenv(self::_ENVVAR_PREFIX . $const);
- list ($defval, $deftype) = $this::_DEFAULTS[$const];
+ list ($defval, $deftype) = self::_DEFAULTS[$const];
$this->params[$cvalue] = [ self::cast_to($override !== false ? $override : $defval, $deftype), $deftype ];
}
@@ -383,7 +382,7 @@ class Config {
}
private function _add(string $param, string $default, int $type_hint) {
- $override = getenv($this::_ENVVAR_PREFIX . $param);
+ $override = getenv(self::_ENVVAR_PREFIX . $param);
$this->params[$param] = [ self::cast_to($override !== false ? $override : $default, $type_hint), $type_hint ];
}
diff --git a/classes/db.php b/classes/db.php
index a09c44628..7b669cf32 100755
--- a/classes/db.php
+++ b/classes/db.php
@@ -4,9 +4,7 @@ class Db
/** @var Db $instance */
private static $instance;
- private $link;
-
- /** @var PDO $pdo */
+ /** @var PDO|null $pdo */
private $pdo;
function __construct() {
diff --git a/classes/feeditem/common.php b/classes/feeditem/common.php
index b4774941f..18afeaa94 100755
--- a/classes/feeditem/common.php
+++ b/classes/feeditem/common.php
@@ -190,7 +190,6 @@ abstract class FeedItem_Common extends FeedItem {
}, $tmp);
// remove empty values
- // @phpstan-ignore-next-line
$tmp = array_filter($tmp, 'strlen');
asort($tmp);
diff --git a/classes/feeds.php b/classes/feeds.php
index ea9158949..987123a21 100755
--- a/classes/feeds.php
+++ b/classes/feeds.php
@@ -5,8 +5,6 @@ class Feeds extends Handler_Protected {
const NEVER_GROUP_FEEDS = [ -6, 0 ];
const NEVER_GROUP_BY_DATE = [ -2, -1, -3 ];
- private $params;
-
private $viewfeed_timestamp;
private $viewfeed_timestamp_last;
diff --git a/classes/logger/sql.php b/classes/logger/sql.php
index 784ebef31..0f6177a5b 100755
--- a/classes/logger/sql.php
+++ b/classes/logger/sql.php
@@ -1,8 +1,6 @@
<?php
class Logger_SQL implements Logger_Adapter {
- private $pdo;
-
function __construct() {
$conn = get_class($this);
diff --git a/classes/pluginhost.php b/classes/pluginhost.php
index f067543bb..b506a957a 100755
--- a/classes/pluginhost.php
+++ b/classes/pluginhost.php
@@ -13,7 +13,6 @@ class PluginHost {
private $api_methods = array();
private $plugin_actions = array();
private $owner_uid;
- private $last_registered;
private $data_loaded;
private static $instance;
@@ -383,7 +382,7 @@ class PluginHost {
if (!isset($this->plugins[$class])) {
try {
- if (file_exists($file)) require_once $file;
+ require_once $file;
} catch (Error $err) {
user_error($err, E_USER_WARNING);
continue;
@@ -404,8 +403,6 @@ class PluginHost {
_bind_textdomain_codeset($class, "UTF-8");
}
- $this->last_registered = $class;
-
try {
switch ($kind) {
case $this::KIND_SYSTEM:
diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php
index cb666e945..c47a99469 100644
--- a/classes/pref/prefs.php
+++ b/classes/pref/prefs.php
@@ -1325,7 +1325,7 @@ class Pref_Prefs extends Handler_Protected {
}
function activateprofile() {
- $id = (int) $_REQUEST['id'] ?? 0;
+ $id = (int) ($_REQUEST['id'] ?? 0);
$profile = ORM::for_table('ttrss_settings_profiles')
->where('owner_uid', $_SESSION['uid'])
diff --git a/classes/pref/users.php b/classes/pref/users.php
index 76a879efd..aeba296b2 100644
--- a/classes/pref/users.php
+++ b/classes/pref/users.php
@@ -167,7 +167,7 @@ class Pref_Users extends Handler_Administrative {
$user->created = Db::NOW();
$user->save();
- if ($new_uid = UserHelper::find_user_by_login($login)) {
+ if (!is_null(UserHelper::find_user_by_login($login))) {
print T_sprintf("Added user %s with password %s",
$login, $new_password);
} else {
diff --git a/classes/urlhelper.php b/classes/urlhelper.php
index 0e4834b72..4d11b5a4d 100644
--- a/classes/urlhelper.php
+++ b/classes/urlhelper.php
@@ -162,8 +162,12 @@ class UrlHelper {
$context = stream_context_create($context_options);
+ // PHP 8 changed the second param from int to bool, but we still support PHP >= 7.1.0
+ // @phpstan-ignore-next-line
$headers = get_headers($url, 0, $context);
} else {
+ // PHP 8 changed the second param from int to bool, but we still support PHP >= 7.1.0
+ // @phpstan-ignore-next-line
$headers = get_headers($url, 0);
}
@@ -275,7 +279,7 @@ class UrlHelper {
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : Config::get(Config::FILE_FETCH_CONNECT_TIMEOUT));
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : Config::get(Config::FILE_FETCH_TIMEOUT));
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("open_basedir") && $followlocation);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $followlocation);
curl_setopt($ch, CURLOPT_MAXREDIRS, 20);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@@ -283,6 +287,7 @@ class UrlHelper {
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent ? $useragent : Config::get_user_agent());
curl_setopt($ch, CURLOPT_ENCODING, "");
+ curl_setopt($ch, CURLOPT_COOKIEJAR, "/dev/null");
if ($http_referrer)
curl_setopt($ch, CURLOPT_REFERER, $http_referrer);
@@ -306,10 +311,6 @@ class UrlHelper {
}
- if (!ini_get("open_basedir")) {
- curl_setopt($ch, CURLOPT_COOKIEJAR, "/dev/null");
- }
-
if (Config::get(Config::HTTP_PROXY)) {
curl_setopt($ch, CURLOPT_PROXY, Config::get(Config::HTTP_PROXY));
}