From 23ba48c71f0d41bbe012d668349f6516dad527b4 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Fri, 5 Sep 2025 09:56:46 -0400 Subject: Change how files are included (#7916) 1. `include`, `include_once`, `require` and `require_once` are expressions not functions, parentheses are not necessary. 2. to move up the directory tree, it's better to use the `dirname` function instead of relying on `/..`. --- app/Controllers/updateController.php | 6 +++--- app/Controllers/userController.php | 2 +- app/Models/DatabaseDAO.php | 4 ++-- app/Models/Feed.php | 4 ++-- app/Models/Search.php | 2 +- app/Models/Share.php | 2 +- app/Models/UserDAO.php | 4 ++-- app/actualize_script.php | 2 +- app/install.php | 4 ++-- 9 files changed, 15 insertions(+), 15 deletions(-) (limited to 'app') diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php index d97b18c70..ba343c81e 100644 --- a/app/Controllers/updateController.php +++ b/app/Controllers/updateController.php @@ -128,7 +128,7 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController { Minz_Error::error(403); } - include_once(LIB_PATH . '/lib_install.php'); + include_once LIB_PATH . '/lib_install.php'; invalidateHttpCache(); @@ -277,7 +277,7 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController { if (self::isGit()) { $res = !self::hasGitUpdate(); } else { - require(UPDATE_FILENAME); + require UPDATE_FILENAME; // @phpstan-ignore function.notFound $res = do_post_update(); } @@ -299,7 +299,7 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController { if (self::isGit()) { $res = self::gitPull(); } else { - require(UPDATE_FILENAME); + require UPDATE_FILENAME; if (Minz_Request::isPost()) { // @phpstan-ignore function.notFound save_info_update(); diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php index 67a97c45a..17879f3d0 100644 --- a/app/Controllers/userController.php +++ b/app/Controllers/userController.php @@ -288,7 +288,7 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController { $customUserConfigPath = join_path(DATA_PATH, 'config-user.custom.php'); if (file_exists($customUserConfigPath)) { - $customUserConfig = include($customUserConfigPath); + $customUserConfig = include $customUserConfigPath; if (is_array($customUserConfig)) { $userConfig = $customUserConfig; } diff --git a/app/Models/DatabaseDAO.php b/app/Models/DatabaseDAO.php index 0062c23e8..8ec3ce3ca 100644 --- a/app/Models/DatabaseDAO.php +++ b/app/Models/DatabaseDAO.php @@ -21,7 +21,7 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo { public const LENGTH_INDEX_UNICODE = 191; public function create(): string { - require_once(APP_PATH . '/SQL/install.sql.' . $this->pdo->dbType() . '.php'); + require_once APP_PATH . '/SQL/install.sql.' . $this->pdo->dbType() . '.php'; $db = FreshRSS_Context::systemConf()->db; try { @@ -280,7 +280,7 @@ SQL; $catDAO = FreshRSS_Factory::createCategoryDao(); $catDAO->resetDefaultCategoryName(); - include_once(APP_PATH . '/SQL/install.sql.' . $this->pdo->dbType() . '.php'); + include_once APP_PATH . '/SQL/install.sql.' . $this->pdo->dbType() . '.php'; if (!empty($GLOBALS['SQL_UPDATE_MINOR']) && is_string($GLOBALS['SQL_UPDATE_MINOR'])) { $sql = $GLOBALS['SQL_UPDATE_MINOR']; $isMariaDB = false; diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 26f85093e..f85db0f2f 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -177,7 +177,7 @@ class FreshRSS_Feed extends Minz_Model { $attributesOnly = $contents === null && $tmpPath === ''; - require_once(LIB_PATH . '/favicons.php'); + require_once LIB_PATH . '/favicons.php'; if (!$attributesOnly && !isImgMime(is_string($contents) ? $contents : '')) { throw new FreshRSS_UnsupportedImageFormat_Exception(); } @@ -401,7 +401,7 @@ class FreshRSS_Feed extends Minz_Model { } public function faviconPrepare(bool $force = false): void { - require_once(LIB_PATH . '/favicons.php'); + require_once LIB_PATH . '/favicons.php'; if ($this->customFavicon()) { return; } diff --git a/app/Models/Search.php b/app/Models/Search.php index 539fe2a12..e88f745ce 100644 --- a/app/Models/Search.php +++ b/app/Models/Search.php @@ -1,7 +1,7 @@ pdo->dbType() . '.php'); + require APP_PATH . '/SQL/install.sql.' . $this->pdo->dbType() . '.php'; try { $sql = $GLOBALS['SQL_CREATE_TABLES']; @@ -31,7 +31,7 @@ class FreshRSS_UserDAO extends Minz_ModelPdo { fwrite(STDERR, 'Deleting SQL data for user “' . $this->current_user . "”…\n"); } - require(APP_PATH . '/SQL/install.sql.' . $this->pdo->dbType() . '.php'); + require APP_PATH . '/SQL/install.sql.' . $this->pdo->dbType() . '.php'; $sql = $GLOBALS['SQL_DROP_TABLES']; if (!is_string($sql)) { throw new Exception('SQL_DROP_TABLES is not a string!'); diff --git a/app/actualize_script.php b/app/actualize_script.php index d0ca72271..2be2a117a 100755 --- a/app/actualize_script.php +++ b/app/actualize_script.php @@ -1,7 +1,7 @@ #!/usr/bin/env php