diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e91132..3578c8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. This projec to [Semantic Versioning] (http://semver.org/). For change log format, use [Keep a Changelog] (http://keepachangelog.com/). -## [2.0.0-alpha3] - In progress +## [2.0.0-beta1] - In progress ### Added @@ -19,6 +19,7 @@ use [Keep a Changelog] (http://keepachangelog.com/). - Fixed null returned value - Fixed returning type of ConfigFunction to mixed +- Fixed default value returned in `AbstractAdapter` ## [2.0.0-alpha2] - 2021-03-12 diff --git a/src/Adapter/AbstractAdapter.php b/src/Adapter/AbstractAdapter.php index 176d30a..da33728 100644 --- a/src/Adapter/AbstractAdapter.php +++ b/src/Adapter/AbstractAdapter.php @@ -33,7 +33,7 @@ public function __construct(int $priority = 0) */ public function get(string $key = null, mixed $default = null): mixed { - return b_array_traverse_get($this->configuration, $key); + return b_array_traverse_get($this->configuration, $key, $default); } /** diff --git a/tests/Adapter/ArrayAdapterTest.php b/tests/Adapter/ArrayAdapterTest.php index ad9ffc0..7ac1987 100644 --- a/tests/Adapter/ArrayAdapterTest.php +++ b/tests/Adapter/ArrayAdapterTest.php @@ -37,6 +37,7 @@ public function testLoadArray() $this->assertEquals('value', $adapter->get('section.foo')); $this->assertEquals('value2', $adapter->get('section.qux')); $this->assertEquals(['bar' => 'value3'], $adapter->get('section2')); + $this->assertEquals('bar', $adapter->get('foo', 'bar')); $this->assertFalse($adapter->has('baz')); $this->assertTrue($adapter->has('section.foo')); diff --git a/tests/Adapter/IniAdapterTest.php b/tests/Adapter/IniAdapterTest.php index 8781ebc..bc15142 100644 --- a/tests/Adapter/IniAdapterTest.php +++ b/tests/Adapter/IniAdapterTest.php @@ -37,6 +37,7 @@ public function testLoadString() $this->assertEquals('value', $adapter->get('section.foo')); $this->assertEquals('value2', $adapter->get('section.qux')); $this->assertEquals(['bar' => 'value3'], $adapter->get('section2')); + $this->assertEquals('bar', $adapter->get('foo', 'bar')); } public function testLoadStringFailed() diff --git a/tests/Adapter/JsonAdapterTest.php b/tests/Adapter/JsonAdapterTest.php index 01988b3..f8e51e7 100644 --- a/tests/Adapter/JsonAdapterTest.php +++ b/tests/Adapter/JsonAdapterTest.php @@ -40,6 +40,7 @@ public function testLoadString() $this->assertEquals('value', $adapter->get('section.foo')); $this->assertEquals('value2', $adapter->get('section.qux')); $this->assertEquals(['bar' => 'value3'], $adapter->get('section2')); + $this->assertEquals('bar', $adapter->get('foo', 'bar')); $this->assertFalse($adapter->has('baz')); $this->assertTrue($adapter->has('section.foo'));