]> git.mxchange.org Git - friendica.git/commitdiff
Added string type-hint for get() and a test case for it
authorPhilipp Holzer <admin+github@philipp.info>
Sun, 14 Jul 2019 21:23:20 +0000 (23:23 +0200)
committerPhilipp Holzer <admin+github@philipp.info>
Sun, 14 Jul 2019 21:23:20 +0000 (23:23 +0200)
src/Core/Config/Cache/ConfigCache.php
src/Core/Config/Cache/PConfigCache.php
tests/src/Core/Config/Cache/ConfigCacheTest.php
tests/src/Core/Config/Cache/PConfigCacheTest.php

index bafb3fc95738d7c58f41a86c3b5063b0219d22fb..3119b5db123c4d1665c587b907cb6363fd8d0d56 100644 (file)
@@ -68,7 +68,7 @@ class ConfigCache
         *
         * @return null|mixed Returns the value of the Config entry or null if not set
         */
-       public function get(string $cat, $key = null)
+       public function get(string $cat, string $key = null)
        {
                if (isset($this->config[$cat][$key])) {
                        return $this->config[$cat][$key];
index 4ee2bfae72b1e8b82fce30b4e29a6330ca44c5bc..b03d86f41ee63faf14c997058a46b8b7b8393fd4 100644 (file)
@@ -62,7 +62,7 @@ class PConfigCache
         *
         * @return null|string The value of the config entry or null if not set
         */
-       public function get(int $uid, string $cat, $key = null)
+       public function get(int $uid, string $cat, string $key = null)
        {
                if (isset($this->config[$uid][$cat][$key])) {
                        return $this->config[$uid][$cat][$key];
index db92cc74365430da33a2e70f7a49ac2f5967f918..d8ac3eaea4d8cbe2aa63c5d22ae3eb57d5d635a7 100644 (file)
@@ -157,6 +157,12 @@ class ConfigCacheTest extends MockedTest
                        'key1' => 'value1',
                        'key2' => 'value2',
                ], $configCache->get('system'));
+
+               // explicit null as key
+               $this->assertEquals([
+                       'key1' => 'value1',
+                       'key2' => 'value2',
+               ], $configCache->get('system', null));
        }
 
        /**
index e0e100bbacf9b4d6342ed09f4466051f81d6d2b9..22beccf6019a295850549dec9ab902b6a98680cc 100644 (file)
@@ -79,6 +79,12 @@ class PConfigCacheTest extends MockedTest
                        'key1' => 'value1',
                        'key2' => 'value2',
                ], $configCache->get($uid, 'system'));
+
+               // test explicit cat with null as key
+               $this->assertEquals([
+                       'key1' => 'value1',
+                       'key2' => 'value2',
+               ], $configCache->get($uid, 'system', null));
        }
 
        /**