From 82dd87703f7138c254632d9b6f6b4b0aaed5fc8f Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Wed, 25 Jan 2023 11:45:33 +0800 Subject: [PATCH] first argument of `option()` function is required --- app/helpers.php | 12 +----------- tests/ServicesTest/OptionTest.php | 1 - 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/app/helpers.php b/app/helpers.php index 0f9ba1e5..02e89005 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -52,21 +52,11 @@ if (!function_exists('option')) { * Get / set the specified option value. * * If an array is passed as the key, we will assume you want to set an array of values. - * - * @param array|string $key - * @param mixed $default - * @param bool $raw return raw value without convertion - * - * @return mixed */ - function option($key = null, $default = null, $raw = false) + function option(string|array $key, mixed $default = null, bool $raw = false) { $options = app('options'); - if (is_null($key)) { - return $options; - } - if (is_array($key)) { $options->set($key); diff --git a/tests/ServicesTest/OptionTest.php b/tests/ServicesTest/OptionTest.php index 505cd687..e7af95bc 100644 --- a/tests/ServicesTest/OptionTest.php +++ b/tests/ServicesTest/OptionTest.php @@ -14,7 +14,6 @@ class OptionTest extends TestCase $options = resolve(Option::class); $options->set('k1', '(null)'); $this->assertNull($options->get('k1')); - $this->assertNull(option()->get('k1')); } public function testSet()