Преглед изворни кода

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 `/..`.
Alexis Degrugillier пре 6 месеци
родитељ
комит
23ba48c71f
59 измењених фајлова са 98 додато и 98 уклоњено
  1. 3 3
      app/Controllers/updateController.php
  2. 1 1
      app/Controllers/userController.php
  3. 2 2
      app/Models/DatabaseDAO.php
  4. 2 2
      app/Models/Feed.php
  5. 1 1
      app/Models/Search.php
  6. 1 1
      app/Models/Share.php
  7. 2 2
      app/Models/UserDAO.php
  8. 1 1
      app/actualize_script.php
  9. 2 2
      app/install.php
  10. 5 5
      cli/_cli.php
  11. 1 1
      cli/actualize-user.php
  12. 3 3
      cli/check.translation.php
  13. 1 1
      cli/create-user.php
  14. 1 1
      cli/db-backup.php
  15. 1 1
      cli/db-optimize.php
  16. 1 1
      cli/db-restore.php
  17. 1 1
      cli/delete-user.php
  18. 2 2
      cli/do-install.php
  19. 1 1
      cli/export-opml-for-user.php
  20. 1 1
      cli/export-sqlite-for-user.php
  21. 1 1
      cli/export-zip-for-user.php
  22. 1 1
      cli/import-for-user.php
  23. 1 1
      cli/import-sqlite-for-user.php
  24. 1 1
      cli/list-users.php
  25. 1 1
      cli/manipulate.translation.php
  26. 1 1
      cli/prepare.php
  27. 1 1
      cli/reconfigure.php
  28. 1 1
      cli/update-user.php
  29. 1 1
      cli/user-info.php
  30. 1 1
      constants.php
  31. 1 1
      index.php
  32. 1 1
      lib/Minz/Configuration.php
  33. 1 1
      lib/Minz/Extension.php
  34. 1 1
      lib/Minz/ExtensionManager.php
  35. 1 1
      lib/Minz/Migrator.php
  36. 1 1
      lib/Minz/ModelArray.php
  37. 1 1
      lib/Minz/Paginator.php
  38. 1 1
      lib/Minz/Translate.php
  39. 1 1
      lib/http-conditional.php
  40. 4 4
      lib/lib_rss.php
  41. 3 3
      p/api/fever.php
  42. 2 2
      p/api/greader.php
  43. 2 2
      p/api/index.php
  44. 2 2
      p/api/misc.php
  45. 2 2
      p/api/pshb.php
  46. 3 3
      p/api/query.php
  47. 3 3
      p/ext.php
  48. 4 4
      p/f.php
  49. 4 4
      p/i/index.php
  50. 2 2
      p/index.php
  51. 1 1
      tests/app/Models/SearchTest.php
  52. 2 2
      tests/bootstrap.php
  53. 2 2
      tests/cli/CliOptionsParserTest.php
  54. 2 2
      tests/cli/cli-parser-test.php
  55. 2 2
      tests/cli/i18n/I18nCompletionValidatorTest.php
  56. 2 2
      tests/cli/i18n/I18nDataTest.php
  57. 1 1
      tests/cli/i18n/I18nFileTest.php
  58. 2 2
      tests/cli/i18n/I18nUsageValidatorTest.php
  59. 1 1
      tests/cli/i18n/I18nValueTest.php

+ 3 - 3
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();

+ 1 - 1
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;
 			}

+ 2 - 2
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;

+ 2 - 2
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;
 		}

+ 1 - 1
app/Models/Search.php

@@ -1,7 +1,7 @@
 <?php
 declare(strict_types=1);
 
-require_once(LIB_PATH . '/lib_date.php');
+require_once LIB_PATH . '/lib_date.php';
 
 /**
  * Contains a search from the search form.

+ 1 - 1
app/Models/Share.php

@@ -40,7 +40,7 @@ class FreshRSS_Share {
 	 * @param string $filename the name of the file to load.
 	 */
 	public static function load(string $filename): void {
-		$shares_from_file = @include($filename);
+		$shares_from_file = @include $filename;
 		if (!is_array($shares_from_file)) {
 			$shares_from_file = [];
 		}

+ 2 - 2
app/Models/UserDAO.php

@@ -4,7 +4,7 @@ declare(strict_types=1);
 class FreshRSS_UserDAO extends Minz_ModelPdo {
 
 	public function createUser(): bool {
-		require(APP_PATH . '/SQL/install.sql.' . $this->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!');

+ 1 - 1
app/actualize_script.php

@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/../cli/_cli.php');
+require dirname(__DIR__) . '/cli/_cli.php';
 
 session_cache_limiter('');
 ob_implicit_flush(false);

+ 2 - 2
app/install.php

@@ -7,7 +7,7 @@ if (function_exists('opcache_reset')) {
 header("Content-Security-Policy: default-src 'self'; frame-ancestors 'none'");
 header('Referrer-Policy: same-origin');
 
-require(LIB_PATH . '/lib_install.php');
+require LIB_PATH . '/lib_install.php';
 
 Minz_Session::init('FreshRSS');
 
@@ -144,7 +144,7 @@ function saveStep2(): void {
 
 		$customConfigPath = DATA_PATH . '/config.custom.php';
 		if (file_exists($customConfigPath)) {
-			$customConfig = include($customConfigPath);
+			$customConfig = include $customConfigPath;
 			if (is_array($customConfig)) {
 				$config_array = array_merge($customConfig, $config_array);
 				if (!is_string($config_array['default_user'] ?? null)) {

+ 5 - 5
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();

+ 1 - 1
cli/actualize-user.php

@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/_cli.php');
+require __DIR__ . '/_cli.php';
 
 performRequirementCheck(FreshRSS_Context::systemConf()->db['type'] ?? '');
 

+ 3 - 3
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<int,string> $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 = '<!-- This file is automatically generated by `cli/check.translation.php -g` -->' . "\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);

+ 1 - 1
cli/create-user.php

@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/_cli.php');
+require __DIR__ . '/_cli.php';
 
 $cliOptions = new class extends CliOptionsParser {
 	public string $user;

+ 1 - 1
cli/db-backup.php

@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/_cli.php');
+require __DIR__ . '/_cli.php';
 
 performRequirementCheck(FreshRSS_Context::systemConf()->db['type'] ?? '');
 $ok = true;

+ 1 - 1
cli/db-optimize.php

@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/_cli.php');
+require __DIR__ . '/_cli.php';
 
 performRequirementCheck(FreshRSS_Context::systemConf()->db['type'] ?? '');
 

+ 1 - 1
cli/db-restore.php

@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/_cli.php');
+require __DIR__ . '/_cli.php';
 
 performRequirementCheck(FreshRSS_Context::systemConf()->db['type'] ?? '');
 

+ 1 - 1
cli/delete-user.php

@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/_cli.php');
+require __DIR__ . '/_cli.php';
 
 performRequirementCheck(FreshRSS_Context::systemConf()->db['type'] ?? '');
 

+ 2 - 2
cli/do-install.php

@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/_cli.php');
+require __DIR__ . '/_cli.php';
 
 if (file_exists(DATA_PATH . '/applied_migrations.txt')) {
 	fail('FreshRSS seems to be already installed!' . "\n" . 'Please use `./cli/reconfigure.php` instead.', EXIT_CODE_ALREADY_EXISTS);
@@ -99,7 +99,7 @@ $config = [
 
 $customConfigPath = DATA_PATH . '/config.custom.php';
 if (file_exists($customConfigPath)) {
-	$customConfig = include($customConfigPath);
+	$customConfig = include $customConfigPath;
 	if (is_array($customConfig) && is_array_keys_string($customConfig)) {
 		$config = array_merge($customConfig, $config);
 	}

+ 1 - 1
cli/export-opml-for-user.php

@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/_cli.php');
+require __DIR__ . '/_cli.php';
 
 performRequirementCheck(FreshRSS_Context::systemConf()->db['type'] ?? '');
 

+ 1 - 1
cli/export-sqlite-for-user.php

@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/_cli.php');
+require __DIR__ . '/_cli.php';
 
 performRequirementCheck(FreshRSS_Context::systemConf()->db['type'] ?? '');
 

+ 1 - 1
cli/export-zip-for-user.php

@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/_cli.php');
+require __DIR__ . '/_cli.php';
 
 performRequirementCheck(FreshRSS_Context::systemConf()->db['type'] ?? '');
 

+ 1 - 1
cli/import-for-user.php

@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/_cli.php');
+require __DIR__ . '/_cli.php';
 
 performRequirementCheck(FreshRSS_Context::systemConf()->db['type'] ?? '');
 

+ 1 - 1
cli/import-sqlite-for-user.php

@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/_cli.php');
+require __DIR__ . '/_cli.php';
 
 performRequirementCheck(FreshRSS_Context::systemConf()->db['type'] ?? '');
 

+ 1 - 1
cli/list-users.php

@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/_cli.php');
+require __DIR__ . '/_cli.php';
 
 $users = listUsers();
 sort($users);

+ 1 - 1
cli/manipulate.translation.php

@@ -4,7 +4,7 @@ declare(strict_types=1);
 require_once __DIR__ . '/_cli.php';
 require_once __DIR__ . '/i18n/I18nData.php';
 require_once __DIR__ . '/i18n/I18nFile.php';
-require_once __DIR__ . '/../constants.php';
+require_once dirname(__DIR__) . '/constants.php';
 
 $cliOptions = new class extends CliOptionsParser {
 	public string $action;

+ 1 - 1
cli/prepare.php

@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/_cli.php');
+require __DIR__ . '/_cli.php';
 
 $dirs = [
 	'/',

+ 1 - 1
cli/reconfigure.php

@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/_cli.php');
+require __DIR__ . '/_cli.php';
 
 $cliOptions = new class extends CliOptionsParser {
 	public string $defaultUser;

+ 1 - 1
cli/update-user.php

@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/_cli.php');
+require __DIR__ . '/_cli.php';
 
 $cliOptions = new class extends CliOptionsParser {
 	public string $user;

+ 1 - 1
cli/user-info.php

@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/_cli.php');
+require __DIR__ . '/_cli.php';
 
 const DATA_FORMAT = "%-7s | %-20s | %-5s | %-7s | %-25s | %-15s | %-10s | %-10s | %-10s | %-10s | %-10s | %-10s | %-5s | %-10s\n";
 

+ 1 - 1
constants.php

@@ -41,7 +41,7 @@ if (version_compare(PHP_VERSION, FRESHRSS_MIN_PHP_VERSION, '<')) {
 
 if (file_exists(__DIR__ . '/constants.local.php')) {
 	//Include custom / local settings:
-	include(__DIR__ . '/constants.local.php');
+	include __DIR__ . '/constants.local.php';
 }
 
 defined('FRESHRSS_USERAGENT') or define('FRESHRSS_USERAGENT', 'FreshRSS/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ')');

+ 1 - 1
index.php

@@ -2,4 +2,4 @@
 declare(strict_types=1);
 
 header('Location: p/', true, 301);
-include('index.html');
+include 'index.html';

+ 1 - 1
lib/Minz/Configuration.php

@@ -44,7 +44,7 @@ class Minz_Configuration {
 	 * @throws Minz_FileNotExistException if the file does not exist or is invalid.
 	 */
 	public static function load(string $filename): array {
-		$data = @include($filename);
+		$data = @include $filename;
 		if (is_array($data) && is_array_keys_string($data)) {
 			return $data;
 		} else {

+ 1 - 1
lib/Minz/Extension.php

@@ -116,7 +116,7 @@ abstract class Minz_Extension {
 		}
 
 		ob_start();
-		include($filename);
+		include $filename;
 		return ob_get_clean();
 	}
 

+ 1 - 1
lib/Minz/ExtensionManager.php

@@ -224,7 +224,7 @@ final class Minz_ExtensionManager {
 		$entry_point_filename = $info['path'] . '/' . self::$ext_entry_point;
 		$ext_class_name = $info['entrypoint'] . 'Extension';
 
-		include_once($entry_point_filename);
+		include_once $entry_point_filename;
 
 		// Test if the given extension class exists.
 		if (!class_exists($ext_class_name)) {

+ 1 - 1
lib/Minz/Migrator.php

@@ -138,7 +138,7 @@ class Minz_Migrator
 			$migration_class = APP_NAME . "_Migration_" . $migration_version;
 			$migration_callback = $migration_class . '::migrate';
 
-			$include_result = @include_once($filepath);
+			$include_result = @include_once $filepath;
 			if (!$include_result) {
 				Minz_Log::error(
 					"{$filepath} migration file cannot be loaded.",

+ 1 - 1
lib/Minz/ModelArray.php

@@ -35,7 +35,7 @@ class Minz_ModelArray {
 		} elseif (($handle = $this->getLock()) === false) {
 			throw new Minz_PermissionDeniedException($this->filename);
 		} else {
-			$data = include($this->filename);
+			$data = include $this->filename;
 			$this->releaseLock($handle);
 
 			if ($data === false) {

+ 1 - 1
lib/Minz/Paginator.php

@@ -55,7 +55,7 @@ class Minz_Paginator {
 		$view = APP_PATH . '/views/helpers/' . $view;
 
 		if (file_exists($view)) {
-			include($view);
+			include $view;
 		}
 	}
 

+ 1 - 1
lib/Minz/Translate.php

@@ -172,7 +172,7 @@ class Minz_Translate {
 		self::$translates[$key] = [];
 
 		foreach (self::$lang_files[$key] as $lang_pathname) {
-			$i18n_array = include($lang_pathname);
+			$i18n_array = include $lang_pathname;
 			if (!is_array($i18n_array)) {
 				Minz_Log::warning('`' . $lang_pathname . '` does not contain a PHP array');
 				continue;

+ 1 - 1
lib/http-conditional.php

@@ -16,7 +16,7 @@ declare(strict_types=1);
 
 ```php
 <?php
-	require_once('http-conditional.php');
+	require_once 'http-conditional.php';
 	//Date of the last modification of the content (Unix Timestamp format).
 	//Examples: query the database, or last modification of a static file.
 	$dateLastModification = ...;

+ 4 - 4
lib/lib_rss.php

@@ -43,17 +43,17 @@ function classAutoloader(string $class): void {
 		$components = explode('_', $class);
 		switch (count($components)) {
 			case 1:
-				include(APP_PATH . '/' . $components[0] . '.php');
+				include APP_PATH . '/' . $components[0] . '.php';
 				return;
 			case 2:
-				include(APP_PATH . '/Models/' . $components[1] . '.php');
+				include APP_PATH . '/Models/' . $components[1] . '.php';
 				return;
 			case 3:	//Controllers, Exceptions
-				include(APP_PATH . '/' . $components[2] . 's/' . $components[1] . $components[2] . '.php');
+				include APP_PATH . '/' . $components[2] . 's/' . $components[1] . $components[2] . '.php';
 				return;
 		}
 	} elseif (strpos($class, 'Minz') === 0) {
-		include(LIB_PATH . '/' . str_replace('_', '/', $class) . '.php');
+		include LIB_PATH . '/' . str_replace('_', '/', $class) . '.php';
 	} elseif (str_starts_with($class, 'SimplePie\\')) {
 		$prefix = 'SimplePie\\';
 		$base_dir = LIB_PATH . '/simplepie/simplepie/src/';

+ 3 - 3
p/api/fever.php

@@ -16,8 +16,8 @@ header('X-Content-Type-Options: nosniff');
 
 // ================================================================================================
 // BOOTSTRAP FreshRSS
-require(__DIR__ . '/../../constants.php');
-require(LIB_PATH . '/lib_rss.php');	//Includes class autoloader
+require dirname(__DIR__, 2) . '/constants.php';
+require LIB_PATH . '/lib_rss.php';	//Includes class autoloader
 FreshRSS_Context::initSystem();
 
 // check if API is enabled globally
@@ -355,7 +355,7 @@ final class FeverAPI
 			return [];
 		}
 
-		require_once(LIB_PATH . '/favicons.php');
+		require_once LIB_PATH . '/favicons.php';
 
 		$favicons = [];
 		$salt = FreshRSS_Context::systemConf()->salt;

+ 2 - 2
p/api/greader.php

@@ -25,8 +25,8 @@ Server-side API compatible with Google Reader API layer 2
 * https://github.com/bazqux/bazqux-api
 */
 
-require(__DIR__ . '/../../constants.php');
-require(LIB_PATH . '/lib_rss.php');	//Includes class autoloader
+require dirname(__DIR__, 2) . '/constants.php';
+require LIB_PATH . '/lib_rss.php';	//Includes class autoloader
 
 header("Content-Security-Policy: default-src 'none'; frame-ancestors 'none'; sandbox");
 header('X-Content-Type-Options: nosniff');

+ 2 - 2
p/api/index.php

@@ -13,8 +13,8 @@
 <script src="../scripts/api.js" defer="defer"></script>
 <script id="jsonVars" type="application/json">
 <?php
-require(__DIR__ . '/../../constants.php');
-require(LIB_PATH . '/lib_rss.php');	//Includes class autoloader
+require dirname(__DIR__, 2) . '/constants.php';
+require LIB_PATH . '/lib_rss.php';	//Includes class autoloader
 FreshRSS_Context::initSystem();
 echo json_encode([
 	'greader' => Minz_Url::display('/api/greader.php', 'php', true),

+ 2 - 2
p/api/misc.php

@@ -5,8 +5,8 @@ declare(strict_types=1);
  * `/api/misc.php/Extension%20name/` or `/api/misc.php?ext=Extension%20name`
  */
 
-require(__DIR__ . '/../../constants.php');
-require(LIB_PATH . '/lib_rss.php');	//Includes class autoloader
+require dirname(__DIR__, 2) . '/constants.php';
+require LIB_PATH . '/lib_rss.php';	//Includes class autoloader
 
 function badRequest(): never {
 	header('HTTP/1.1 400 Bad Request');

+ 2 - 2
p/api/pshb.php

@@ -1,7 +1,7 @@
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/../../constants.php');
-require(LIB_PATH . '/lib_rss.php');	//Includes class autoloader
+require dirname(__DIR__, 2) . '/constants.php';
+require LIB_PATH . '/lib_rss.php';	//Includes class autoloader
 
 const MAX_PAYLOAD = 3_145_728;
 

+ 3 - 3
p/api/query.php

@@ -3,8 +3,8 @@ declare(strict_types=1);
 
 header('X-Content-Type-Options: nosniff');
 
-require(__DIR__ . '/../../constants.php');
-require(LIB_PATH . '/lib_rss.php');	//Includes class autoloader
+require dirname(__DIR__, 2) . '/constants.php';
+require LIB_PATH . '/lib_rss.php';	//Includes class autoloader
 
 Minz_Request::init();
 
@@ -48,7 +48,7 @@ if (!FreshRSS_Context::hasUserConf() || !FreshRSS_Context::userConf()->enabled)
 	usleep(rand(20, 200));
 }
 
-require(LIB_PATH . '/http-conditional.php');
+require LIB_PATH . '/http-conditional.php';
 $dateLastModification = max(
 	FreshRSS_UserDAO::ctime($user),
 	FreshRSS_UserDAO::mtime($user),

+ 3 - 3
p/ext.php

@@ -1,7 +1,7 @@
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/../constants.php');
-require(LIB_PATH . '/lib_rss.php');	//Includes class autoloader
+require dirname(__DIR__) . '/constants.php';
+require LIB_PATH . '/lib_rss.php';	//Includes class autoloader
 
 function get_absolute_filename(string $file_name): string {
 	$core_extension = realpath(CORE_EXTENSIONS_PATH . '/' . $file_name);
@@ -103,7 +103,7 @@ if ($mtime === false) {
 	sendNotFoundResponse();
 }
 
-require(LIB_PATH . '/http-conditional.php');
+require LIB_PATH . '/http-conditional.php';
 
 if (file_exists(DATA_PATH . '/no-cache.txt') || !httpConditional($mtime, 604800, 2)) {
 	readfile($absolute_filename);

+ 4 - 4
p/f.php

@@ -1,9 +1,9 @@
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/../constants.php');
-require(LIB_PATH . '/lib_rss.php');	//Includes class autoloader
-require(LIB_PATH . '/favicons.php');
-require(LIB_PATH . '/http-conditional.php');
+require dirname(__DIR__) . '/constants.php';
+require LIB_PATH . '/lib_rss.php';	//Includes class autoloader
+require LIB_PATH . '/favicons.php';
+require LIB_PATH . '/http-conditional.php';
 
 header("Content-Security-Policy: default-src 'none'; frame-ancestors 'none'; sandbox");
 header('X-Content-Type-Options: nosniff');

+ 4 - 4
p/i/index.php

@@ -22,20 +22,20 @@ declare(strict_types=1);
 #
 # ***** END LICENSE BLOCK *****
 
-require(__DIR__ . '/../../constants.php');
-require(LIB_PATH . '/lib_rss.php');	//Includes class autoloader
+require dirname(__DIR__, 2) . '/constants.php';
+require LIB_PATH . '/lib_rss.php';	//Includes class autoloader
 
 $migrations_path = APP_PATH . '/migrations';
 $applied_migrations_path = DATA_PATH . '/applied_migrations.txt';
 
 if (!file_exists($applied_migrations_path)) {
-	require(APP_PATH . '/install.php');
+	require APP_PATH . '/install.php';
 } else {
 	session_cache_limiter('');
 	Minz_Session::init('FreshRSS');
 	Minz_Session::_param('keepAlive', 1);	//To prevent the PHP session from expiring
 
-	require(LIB_PATH . '/http-conditional.php');
+	require LIB_PATH . '/http-conditional.php';
 	$currentUser = Minz_User::name();
 	$dateLastModification = $currentUser === null ? time() : max(
 		FreshRSS_UserDAO::ctime($currentUser),

+ 2 - 2
p/index.php

@@ -1,7 +1,7 @@
 <?php
 declare(strict_types=1);
-require(__DIR__ . '/../constants.php');
-require(LIB_PATH . '/lib_rss.php');	//Includes class autoloader
+require dirname(__DIR__) . '/constants.php';
+require LIB_PATH . '/lib_rss.php';	//Includes class autoloader
 
 FreshRSS_Context::initSystem();
 Minz_Request::forward(['c' => 'index', 'a' => 'index'], true);

+ 1 - 1
tests/app/Models/SearchTest.php

@@ -3,7 +3,7 @@ declare(strict_types=1);
 
 use PHPUnit\Framework\Attributes\DataProvider;
 
-require_once(LIB_PATH . '/lib_date.php');
+require_once LIB_PATH . '/lib_date.php';
 
 class SearchTest extends PHPUnit\Framework\TestCase {
 

+ 2 - 2
tests/bootstrap.php

@@ -5,5 +5,5 @@ ini_set('display_errors', '1');
 
 const COPY_LOG_TO_SYSLOG = false;
 
-require(__DIR__ . '/../constants.php');
-require(LIB_PATH . '/lib_rss.php');	//Includes class autoloader
+require dirname(__DIR__) . '/constants.php';
+require LIB_PATH . '/lib_rss.php';	//Includes class autoloader

+ 2 - 2
tests/cli/CliOptionsParserTest.php

@@ -2,8 +2,8 @@
 declare(strict_types=1);
 
 use PHPUnit\Framework\TestCase;
-require_once __DIR__ . '/../../cli/CliOption.php';
-require_once __DIR__ . '/../../cli/CliOptionsParser.php';
+require_once dirname(__DIR__, 2) . '/cli/CliOption.php';
+require_once dirname(__DIR__, 2) . '/cli/CliOptionsParser.php';
 
 final class CliOptionsOptionalTest extends CliOptionsParser {
 	public string $string = '';

+ 2 - 2
tests/cli/cli-parser-test.php

@@ -2,8 +2,8 @@
 <?php
 declare(strict_types=1);
 
-require(__DIR__ . '/../../vendor/autoload.php');
-require(__DIR__ . '/CliOptionsParserTest.php');
+require dirname(__DIR__, 2) . '/vendor/autoload.php';
+require __DIR__ . '/CliOptionsParserTest.php';
 
 $optionsClass = getenv('CLI_PARSER_TEST_OPTIONS_CLASS');
 if (!is_string($optionsClass) || !class_exists($optionsClass)) {

+ 2 - 2
tests/cli/i18n/I18nCompletionValidatorTest.php

@@ -1,7 +1,7 @@
 <?php
 declare(strict_types=1);
-require_once __DIR__ . '/../../../cli/i18n/I18nCompletionValidator.php';
-require_once __DIR__ . '/../../../cli/i18n/I18nValue.php';
+require_once dirname(__DIR__, 3) . '/cli/i18n/I18nCompletionValidator.php';
+require_once dirname(__DIR__, 3) . '/cli/i18n/I18nValue.php';
 
 class I18nCompletionValidatorTest extends PHPUnit\Framework\TestCase {
 	/** @var I18nValue&PHPUnit\Framework\MockObject\MockObject */

+ 2 - 2
tests/cli/i18n/I18nDataTest.php

@@ -1,7 +1,7 @@
 <?php
 declare(strict_types=1);
-require_once __DIR__ . '/../../../cli/i18n/I18nData.php';
-require_once __DIR__ . '/../../../cli/i18n/I18nValue.php';
+require_once dirname(__DIR__, 3) . '/cli/i18n/I18nData.php';
+require_once dirname(__DIR__, 3) . '/cli/i18n/I18nValue.php';
 
 class I18nDataTest extends PHPUnit\Framework\TestCase {
 	/** @var array<string,array<string,array<string,I18nValue>>> */

+ 1 - 1
tests/cli/i18n/I18nFileTest.php

@@ -1,6 +1,6 @@
 <?php
 declare(strict_types=1);
-require_once __DIR__ . '/../../../cli/i18n/I18nFile.php';
+require_once dirname(__DIR__, 3) . '/cli/i18n/I18nFile.php';
 
 class I18nFileTest extends PHPUnit\Framework\TestCase {
 	public function test(): void {

+ 2 - 2
tests/cli/i18n/I18nUsageValidatorTest.php

@@ -1,7 +1,7 @@
 <?php
 declare(strict_types=1);
-require_once __DIR__ . '/../../../cli/i18n/I18nValue.php';
-require_once __DIR__ . '/../../../cli/i18n/I18nUsageValidator.php';
+require_once dirname(__DIR__, 3) . '/cli/i18n/I18nValue.php';
+require_once dirname(__DIR__, 3) . '/cli/i18n/I18nUsageValidator.php';
 
 class I18nUsageValidatorTest extends PHPUnit\Framework\TestCase {
 

+ 1 - 1
tests/cli/i18n/I18nValueTest.php

@@ -1,6 +1,6 @@
 <?php
 declare(strict_types=1);
-require_once __DIR__ . '/../../../cli/i18n/I18nValue.php';
+require_once dirname(__DIR__, 3) . '/cli/i18n/I18nValue.php';
 
 class I18nValueTest extends PHPUnit\Framework\TestCase {
 	public static function testConstructorWithoutState(): void {