From 661fc54ba2432e7def3739050d1360af15829db3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 13 Jul 2021 16:57:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- System/Abstracts/Config.php | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/System/Abstracts/Config.php b/System/Abstracts/Config.php index 065a7c76..571f5e47 100644 --- a/System/Abstracts/Config.php +++ b/System/Abstracts/Config.php @@ -10,7 +10,6 @@ declare(strict_types=1); namespace Snowflake\Abstracts; use Exception; -use Snowflake\Core\ArrayAccess; use Snowflake\Exception\ConfigException; use Snowflake\Snowflake; @@ -24,7 +23,7 @@ class Config extends Component const ERROR_MESSAGE = 'The not find %s in app configs.'; - protected $data; + protected mixed $data; /** @@ -63,15 +62,15 @@ class Config extends Component /** * @param $key * @param bool $try - * @param mixed $default + * @param mixed|null $default * @return mixed * @throws */ - public static function get($key, $default = null, $try = FALSE): mixed + public static function get($key, mixed $default = null, bool $try = FALSE): mixed { $instance = Snowflake::app()->getConfig()->getData(); if (!str_contains($key, '.')) { - return isset($instance[$key]) ? $instance[$key] : $default; + return $instance[$key] ?? $default; } foreach (explode('.', $key) as $value) { if (empty($value)) { @@ -107,8 +106,9 @@ class Config extends Component * @param $key * @param bool $must_not_null * @return bool + * @throws Exception */ - public static function has($key, $must_not_null = false): bool + public static function has($key, bool $must_not_null = false): bool { $config = Snowflake::app()->getConfig(); if (!isset($config->data[$key])) { @@ -121,12 +121,4 @@ class Config extends Component return !empty($config); } - /** - * @param $name - * @param $value - */ - public function __set($name, $value) - { - $this->data[$name] = $value; - } }