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 `/..`. --- cli/_cli.php | 10 +++++----- cli/actualize-user.php | 2 +- cli/check.translation.php | 6 +++--- cli/create-user.php | 2 +- cli/db-backup.php | 2 +- cli/db-optimize.php | 2 +- cli/db-restore.php | 2 +- cli/delete-user.php | 2 +- cli/do-install.php | 4 ++-- cli/export-opml-for-user.php | 2 +- cli/export-sqlite-for-user.php | 2 +- cli/export-zip-for-user.php | 2 +- cli/import-for-user.php | 2 +- cli/import-sqlite-for-user.php | 2 +- cli/list-users.php | 2 +- cli/manipulate.translation.php | 2 +- cli/prepare.php | 2 +- cli/reconfigure.php | 2 +- cli/update-user.php | 2 +- cli/user-info.php | 2 +- 20 files changed, 27 insertions(+), 27 deletions(-) (limited to 'cli') diff --git a/cli/_cli.php b/cli/_cli.php index b4df51dd8..fc7c206f5 100644 --- a/cli/_cli.php +++ b/cli/_cli.php @@ -7,11 +7,11 @@ if (php_sapi_name() !== 'cli') { const EXIT_CODE_ALREADY_EXISTS = 3; -require(__DIR__ . '/../constants.php'); -require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader -require(LIB_PATH . '/lib_install.php'); -require_once(__DIR__ . '/CliOption.php'); -require_once(__DIR__ . '/CliOptionsParser.php'); +require dirname(__DIR__) . '/constants.php'; +require LIB_PATH . '/lib_rss.php'; //Includes class autoloader +require LIB_PATH . '/lib_install.php'; +require_once __DIR__ . '/CliOption.php'; +require_once __DIR__ . '/CliOptionsParser.php'; Minz_Session::init('FreshRSS', true); FreshRSS_Context::initSystem(); diff --git a/cli/actualize-user.php b/cli/actualize-user.php index 29514769b..d5633766f 100755 --- a/cli/actualize-user.php +++ b/cli/actualize-user.php @@ -1,7 +1,7 @@ #!/usr/bin/env php db['type'] ?? ''); diff --git a/cli/check.translation.php b/cli/check.translation.php index 151a6084f..01e90a631 100755 --- a/cli/check.translation.php +++ b/cli/check.translation.php @@ -6,7 +6,7 @@ require_once __DIR__ . '/i18n/I18nCompletionValidator.php'; require_once __DIR__ . '/i18n/I18nData.php'; require_once __DIR__ . '/i18n/I18nFile.php'; require_once __DIR__ . '/i18n/I18nUsageValidator.php'; -require_once __DIR__ . '/../constants.php'; +require_once dirname(__DIR__) . '/constants.php'; $cliOptions = new class extends CliOptionsParser { /** @var array $language */ @@ -104,7 +104,7 @@ function embedSvg(string $contents): string { if ($cliOptions->generateReadme) { $supportedFormats = ['txt', 'svg']; - $flagsDir = __DIR__ . '/../docs/i18n/flags'; + $flagsDir = dirname(__DIR__) . '/docs/i18n/flags'; $markdownImgStr = ''; foreach ($percentage as $lang => $value) { @@ -131,7 +131,7 @@ if ($cliOptions->generateReadme) { $template = '' . "\n"; if ($svg === '') { - $i18nGen = include __DIR__ . "/../app/i18n/$lang/gen.php"; + $i18nGen = include dirname(__DIR__) . "/app/i18n/$lang/gen.php"; if (!is_array($i18nGen) || !is_string($i18nGen['flag'] ?? null)) { echo 'Error: No Unicode flag found for language ' . $lang, PHP_EOL; exit(1); diff --git a/cli/create-user.php b/cli/create-user.php index 0276e80b3..4de0ced1d 100755 --- a/cli/create-user.php +++ b/cli/create-user.php @@ -1,7 +1,7 @@ #!/usr/bin/env php db['type'] ?? ''); $ok = true; diff --git a/cli/db-optimize.php b/cli/db-optimize.php index f6d3884b9..8f37dbca6 100755 --- a/cli/db-optimize.php +++ b/cli/db-optimize.php @@ -1,7 +1,7 @@ #!/usr/bin/env php db['type'] ?? ''); diff --git a/cli/db-restore.php b/cli/db-restore.php index 8e4ffcc12..0de624519 100755 --- a/cli/db-restore.php +++ b/cli/db-restore.php @@ -1,7 +1,7 @@ #!/usr/bin/env php db['type'] ?? ''); diff --git a/cli/delete-user.php b/cli/delete-user.php index 18efa4253..efb36a0ed 100755 --- a/cli/delete-user.php +++ b/cli/delete-user.php @@ -1,7 +1,7 @@ #!/usr/bin/env php db['type'] ?? ''); diff --git a/cli/do-install.php b/cli/do-install.php index cab4b1462..57a5121d4 100755 --- a/cli/do-install.php +++ b/cli/do-install.php @@ -1,7 +1,7 @@ #!/usr/bin/env php db['type'] ?? ''); diff --git a/cli/export-sqlite-for-user.php b/cli/export-sqlite-for-user.php index 98e05da22..01b364b51 100755 --- a/cli/export-sqlite-for-user.php +++ b/cli/export-sqlite-for-user.php @@ -1,7 +1,7 @@ #!/usr/bin/env php db['type'] ?? ''); diff --git a/cli/export-zip-for-user.php b/cli/export-zip-for-user.php index e030274d2..ca7de28fe 100755 --- a/cli/export-zip-for-user.php +++ b/cli/export-zip-for-user.php @@ -1,7 +1,7 @@ #!/usr/bin/env php db['type'] ?? ''); diff --git a/cli/import-for-user.php b/cli/import-for-user.php index 17dc9750e..26c69a118 100755 --- a/cli/import-for-user.php +++ b/cli/import-for-user.php @@ -1,7 +1,7 @@ #!/usr/bin/env php db['type'] ?? ''); diff --git a/cli/import-sqlite-for-user.php b/cli/import-sqlite-for-user.php index 2eb3e2965..f671151c2 100755 --- a/cli/import-sqlite-for-user.php +++ b/cli/import-sqlite-for-user.php @@ -1,7 +1,7 @@ #!/usr/bin/env php db['type'] ?? ''); diff --git a/cli/list-users.php b/cli/list-users.php index f9e63f4f6..b4c185e03 100755 --- a/cli/list-users.php +++ b/cli/list-users.php @@ -1,7 +1,7 @@ #!/usr/bin/env php