Skip to content

Commit fce9a66

Browse files
committed
Merge branch 'release/0.8.16'
2 parents 7cd121c + 7284e2c commit fce9a66

4 files changed

Lines changed: 71 additions & 11 deletions

File tree

.version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"strategy": "semver",
33
"major": 0,
44
"minor": 8,
5-
"patch": 15,
5+
"patch": 16,
66
"build": 0
77
}

src/Application/Base.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,16 @@ protected function initSettings( ?ISettingSource $source ): void
717717

718718
try
719719
{
720-
$this->_settings = new SettingManager( $source );
720+
// If source is already a SettingManager, use it directly (avoids double-wrapping)
721+
// Otherwise wrap the raw source in a SettingManager (backward compatibility)
722+
if( $source instanceof SettingManager )
723+
{
724+
$this->_settings = $source;
725+
}
726+
else
727+
{
728+
$this->_settings = new SettingManager( $source );
729+
}
721730

722731
$basePath = $this->getSetting( 'system','base_path' ) ?? $defaultBasePath;
723732
$fallback = new Env( Data\Env::getInstance( "$basePath/.env" ) );

tests/Application/ApplicationTest.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,5 +534,62 @@ public function testInitSettingsUsesEnvVariable()
534534

535535
$this->assertNotNull($app->getSettingManager());
536536
}
537+
538+
public function testInitSettingsWithSettingManagerUsesItDirectly()
539+
{
540+
// Clear registry
541+
Registry::getInstance()->set(RegistryKeys::SETTINGS, null);
542+
543+
// Create a SettingManager with a raw source
544+
$rawSource = new Ini('examples/config/application.ini');
545+
$settingManager = new \Neuron\Data\Settings\SettingManager($rawSource);
546+
547+
// Pass the SettingManager to the app
548+
$app = new AppMock("2.0", $settingManager);
549+
550+
// The app should use the SettingManager directly (not wrap it again)
551+
$appSettings = $app->getSettingManager();
552+
$this->assertSame($settingManager, $appSettings);
553+
554+
// Verify we don't have double-wrapping by checking the internal source
555+
// If double-wrapped, getSource() would return a SettingManager instead of the raw Ini
556+
$this->assertInstanceOf(Ini::class, $appSettings->getSource());
557+
$this->assertNotInstanceOf(\Neuron\Data\Settings\SettingManager::class, $appSettings->getSource());
558+
}
559+
560+
public function testInitSettingsWithRawSourceWrapsIt()
561+
{
562+
// Clear registry
563+
Registry::getInstance()->set(RegistryKeys::SETTINGS, null);
564+
565+
// Pass a raw source (not a SettingManager)
566+
$rawSource = new Ini('examples/config/application.ini');
567+
$app = new AppMock("2.0", $rawSource);
568+
569+
// The app should wrap it in a SettingManager
570+
$appSettings = $app->getSettingManager();
571+
$this->assertInstanceOf(\Neuron\Data\Settings\SettingManager::class, $appSettings);
572+
573+
// Verify the raw source is wrapped
574+
$this->assertInstanceOf(Ini::class, $appSettings->getSource());
575+
}
576+
577+
public function testInitSettingsSetsEnvFallbackWhenNoneProvided()
578+
{
579+
// Clear registry
580+
Registry::getInstance()->set(RegistryKeys::SETTINGS, null);
581+
582+
// Create a SettingManager without a fallback
583+
$rawSource = new Ini('examples/config/application.ini');
584+
$settingManager = new \Neuron\Data\Settings\SettingManager($rawSource);
585+
586+
// Pass the SettingManager to the app
587+
$app = new AppMock("2.0", $settingManager);
588+
589+
// The app should set a fallback (env variables)
590+
$appSettings = $app->getSettingManager();
591+
$this->assertNotNull($appSettings->getFallback());
592+
$this->assertInstanceOf(\Neuron\Data\Settings\Source\Env::class, $appSettings->getFallback());
593+
}
537594
}
538595

versionlog.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
## 0.8.15 2026-01-13
1+
## 0.8.16 2026-01-15
2+
* Fix to support setting managers or sources correctly without incurring a manager that contains a manager.
23

4+
## 0.8.15 2026-01-13
35
## 0.8.14 2026-01-12
4-
56
## 0.8.13 2026-01-06
67

78
## 0.8.12 2026-01-01
89
* Added psr-11 container support.
910

1011
## 0.8.11 2025-12-26
11-
1212
## 0.8.10 2025-11-28
1313

1414
## 0.8.9 2025-11-27
@@ -23,30 +23,24 @@
2323
* Renamed config.yaml to neuron.yaml
2424

2525
## 0.8.5 2025-11-11
26-
2726
## 0.8.4 2025-11-10
28-
2927
## 0.8.3 2025-11-10
3028
* Improved error handling.
3129

3230
## 0.8.2 2025-11-08
33-
3431
## 0.8.1 2025-11-06
3532

3633
* Added getSettingManager() method to provide access to SettingManager instance
3734

3835
## 0.7.1 2025-11-04
39-
4036
## 0.7.0 2025-08-14
4137
* Refactored get/set setting methods.
4238

4339
## 0.6.33 2025-05-23
4440
* Added the Crashed state.
4541

4642
## 0.6.32 2025-05-21
47-
4843
## 0.6.31
49-
5044
## 0.6.30 2025-02-06
5145
* Transitioned from core package to application.
5246

0 commit comments

Comments
 (0)