A free, self-hostable news aggregator…
Use PHPStan dynamicConstantNames (#5370)
Alexandre Alapetite30c69ef14705
diff --git a/app/Models/Feed.php b/app/Models/Feed.phpindex 6c840942b..f833b2834 100644--- a/app/Models/Feed.php+++ b/app/Models/Feed.php@@ -363,7 +363,7 @@ class FreshRSS_Feed extends Minz_Model {public function load(bool $loadDetails = false, bool $noCache = false): ?SimplePie {if ($this->url != '') {// @phpstan-ignore-next-line- if (CACHE_PATH === false) {+ if (CACHE_PATH == '') {throw new Minz_FileNotExistException('CACHE_PATH',Minz_Exception::ERRORdiff --git a/app/actualize_script.php b/app/actualize_script.phpindex 160911f53..67dcc9631 100755--- a/app/actualize_script.php+++ b/app/actualize_script.php@@ -30,11 +30,9 @@ define('SIMPLEPIE_SYSLOG_ENABLED', FreshRSS_Context::$system_conf->simplepie_sys*/function notice(string $message): void {Minz_Log::notice($message, ADMIN_LOG);- // @phpstan-ignore-next-lineif (!COPY_LOG_TO_SYSLOG && SIMPLEPIE_SYSLOG_ENABLED) {syslog(LOG_NOTICE, $message);}- // @phpstan-ignore-next-lineif (defined('STDOUT') && !COPY_SYSLOG_TO_STDERR) {fwrite(STDOUT, $message . "\n"); //Unbuffered}diff --git a/lib/Minz/Log.php b/lib/Minz/Log.phpindex 20e8578be..f30aac7d1 100644--- a/lib/Minz/Log.php+++ b/lib/Minz/Log.php@@ -56,7 +56,6 @@ class Minz_Log {$log = '[' . date('r') . '] [' . $level_label . '] --- ' . $information . "\n";- // @phpstan-ignore-next-lineif (defined('COPY_LOG_TO_SYSLOG') && COPY_LOG_TO_SYSLOG) {syslog($level, '[' . $username . '] ' . trim($log));}@@ -80,7 +79,6 @@ class Minz_Log {*/protected static function ensureMaxLogSize(string $file_name): void {$maxSize = defined('MAX_LOG_SIZE') ? MAX_LOG_SIZE : 1048576;- // @phpstan-ignore-next-lineif ($maxSize > 0 && @filesize($file_name) > $maxSize) {$fp = fopen($file_name, 'c+');if ($fp && flock($fp, LOCK_EX)) {@@ -95,10 +93,7 @@ class Minz_Log {} else {throw new Minz_PermissionDeniedException($file_name, Minz_Exception::ERROR);}- // @phpstan-ignore-next-line- if ($fp) {- fclose($fp);- }+ fclose($fp);}}diff --git a/lib/lib_install.php b/lib/lib_install.phpindex 23c902440..780115b63 100644--- a/lib/lib_install.php+++ b/lib/lib_install.php@@ -41,14 +41,14 @@ function checkRequirements(string $dbType = ''): array {$json = function_exists('json_encode');$mbstring = extension_loaded('mbstring');// @phpstan-ignore-next-line- $data = DATA_PATH && touch(DATA_PATH . '/index.html'); // is_writable() is not reliable for a folder on NFS+ $data = DATA_PATH != '' && touch(DATA_PATH . '/index.html'); // is_writable() is not reliable for a folder on NFS// @phpstan-ignore-next-line- $cache = CACHE_PATH && touch(CACHE_PATH . '/index.html');+ $cache = CACHE_PATH != '' && touch(CACHE_PATH . '/index.html');+ $tmp = TMP_PATH != '' && is_writable(TMP_PATH);// @phpstan-ignore-next-line- $tmp = TMP_PATH && is_writable(TMP_PATH);+ $users = USERS_PATH != '' && touch(USERS_PATH . '/index.html');// @phpstan-ignore-next-line- $users = USERS_PATH && touch(USERS_PATH . '/index.html');- $favicons = touch(DATA_PATH . '/favicons/index.html');+ $favicons = DATA_PATH != '' && touch(DATA_PATH . '/favicons/index.html');return array('php' => $php ? 'ok' : 'ko',diff --git a/lib/lib_rss.php b/lib/lib_rss.phpindex a7e03d4ea..e7cb7386a 100644--- a/lib/lib_rss.php+++ b/lib/lib_rss.php@@ -17,7 +17,6 @@ if (!function_exists('str_starts_with')) {}if (!function_exists('syslog')) {- // @phpstan-ignore-next-lineif (COPY_SYSLOG_TO_STDERR && !defined('STDERR')) {define('STDERR', fopen('php://stderr', 'w'));}@@ -31,7 +30,6 @@ if (!function_exists('syslog')) {}if (function_exists('openlog')) {- // @phpstan-ignore-next-lineif (COPY_SYSLOG_TO_STDERR) {openlog('FreshRSS', LOG_CONS | LOG_ODELAY | LOG_PID | LOG_PERROR, LOG_USER);} else {diff --git a/phpstan.neon b/phpstan.neonindex dd47c79ee..90c41aec7 100644--- a/phpstan.neon+++ b/phpstan.neon@@ -20,6 +20,17 @@ parameters:bootstrapFiles:- cli/_cli.php- lib/favicons.php+ dynamicConstantNames:+ - CACHE_PATH+ - COPY_LOG_TO_SYSLOG+ - COPY_SYSLOG_TO_STDERR+ - DATA_PATH+ - MAX_LOG_SIZE+ - SIMPLEPIE_SYSLOG_ENABLED+ - STDERR+ - STDOUT+ - TMP_PATH+ - USERS_PATHincludes:- vendor/phpstan/phpstan-phpunit/extension.neon- vendor/phpstan/phpstan-phpunit/rules.neon