From ae1533e31269b0ecab121ea82cf3b77eede96ba8 Mon Sep 17 00:00:00 2001 From: Philipp Date: Mon, 2 Jan 2023 02:25:41 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Hypolite Petovan --- src/Core/Config/Model/Config.php | 4 +--- src/Core/Config/Util/ConfigFileManager.php | 2 +- src/Core/Config/ValueObject/Cache.php | 11 ++++------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/Core/Config/Model/Config.php b/src/Core/Config/Model/Config.php index 3de97158f..7829b75ff 100644 --- a/src/Core/Config/Model/Config.php +++ b/src/Core/Config/Model/Config.php @@ -32,9 +32,7 @@ use Friendica\Core\Config\ValueObject\Cache; */ class Config implements IManageConfigValues { - /** - * @var Cache - */ + /** @var Cache */ protected $configCache; /** @var ConfigFileManager */ diff --git a/src/Core/Config/Util/ConfigFileManager.php b/src/Core/Config/Util/ConfigFileManager.php index 82de4a99c..378d7fbd4 100644 --- a/src/Core/Config/Util/ConfigFileManager.php +++ b/src/Core/Config/Util/ConfigFileManager.php @@ -401,7 +401,7 @@ class ConfigFileManager private function loadConfigFile(string $filepath): array { if (file_exists($filepath)) { - $config = include($filepath); + $config = include $filepath; if (!is_array($config)) { throw new ConfigFileException('Error loading config file ' . $filepath); diff --git a/src/Core/Config/ValueObject/Cache.php b/src/Core/Config/ValueObject/Cache.php index 2bac625ad..a074414bf 100644 --- a/src/Core/Config/ValueObject/Cache.php +++ b/src/Core/Config/ValueObject/Cache.php @@ -212,13 +212,10 @@ class Cache return null; } - switch (true) { - // manage array value - case preg_match("|^a:[0-9]+:{.*}$|s", $value): - return unserialize($value); - - default: - return $value; + if (preg_match("|^a:[0-9]+:{.*}$|s", $value)) { + return unserialize($value); + } else { + return $value; } }