From a6f6172e87a25dd075ee6f28fa81a0be453804f7 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 6 Oct 2023 17:17:48 +0900 Subject: [PATCH 1/2] refactor: remove deprecated CodeIgniter\Config\Config It has been deprecated since v4.0.5. https://github.com/codeigniter4/CodeIgniter4/commit/91916888 --- system/Config/Config.php | 55 ---------------------------- tests/system/Config/ConfigTest.php | 59 ------------------------------ 2 files changed, 114 deletions(-) delete mode 100644 system/Config/Config.php delete mode 100644 tests/system/Config/ConfigTest.php diff --git a/system/Config/Config.php b/system/Config/Config.php deleted file mode 100644 index 90a6b7cadef5..000000000000 --- a/system/Config/Config.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. - */ - -namespace CodeIgniter\Config; - -/** - * @deprecated Use CodeIgniter\Config\Factories::config() - * @see \CodeIgniter\Config\ConfigTest - */ -class Config -{ - /** - * Create new configuration instances or return - * a shared instance - * - * @param string $name Configuration name - * @param bool $getShared Use shared instance - * - * @return object|null - */ - public static function get(string $name, bool $getShared = true) - { - return Factories::config($name, ['getShared' => $getShared]); - } - - /** - * Helper method for injecting mock instances while testing. - * - * @param object $instance - * - * @return void - */ - public static function injectMock(string $name, $instance) - { - Factories::injectMock('config', $name, $instance); - } - - /** - * Resets the static arrays - * - * @return void - */ - public static function reset() - { - Factories::reset('config'); - } -} diff --git a/tests/system/Config/ConfigTest.php b/tests/system/Config/ConfigTest.php deleted file mode 100644 index b00bc2b9f699..000000000000 --- a/tests/system/Config/ConfigTest.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. - */ - -namespace CodeIgniter\Config; - -use CodeIgniter\Test\CIUnitTestCase; -use Config\DocTypes; -use stdClass; - -/** - * @internal - * - * @group SeparateProcess - */ -final class ConfigTest extends CIUnitTestCase -{ - public function testCreateSingleInstance(): void - { - $Config = Config::get('DocTypes', false); - $NamespaceConfig = Config::get(DocTypes::class, false); - - $this->assertInstanceOf(DocTypes::class, $Config); - $this->assertInstanceOf(DocTypes::class, $NamespaceConfig); - } - - public function testCreateInvalidInstance(): void - { - $Config = Config::get('gfnusvjai', false); - - $this->assertNull($Config); - } - - public function testCreateSharedInstance(): void - { - $Config = Config::get('DocTypes'); - $Config2 = Config::get(DocTypes::class); - - $this->assertSame($Config2, $Config); - } - - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function testInjection(): void - { - Config::reset(); - Config::injectMock('Banana', new stdClass()); - $this->assertNotNull(Config::get('Banana')); - } -} From a85774d00302db9b259ee96b8540ec9e3c332de6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 6 Oct 2023 17:19:14 +0900 Subject: [PATCH 2/2] docs: add changelog --- user_guide_src/source/changelogs/v4.5.0.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/user_guide_src/source/changelogs/v4.5.0.rst b/user_guide_src/source/changelogs/v4.5.0.rst index f109180c8009..b3a6068235f3 100644 --- a/user_guide_src/source/changelogs/v4.5.0.rst +++ b/user_guide_src/source/changelogs/v4.5.0.rst @@ -78,6 +78,11 @@ Filters - ``Router::$filterInfo`` - ``Router::getFilter()`` +Others +------ + +- **Config:** The deprecated ``CodeIgniter\Config\Config`` class has been removed. + Enhancements ************