Skip to content

Commit 226a9dc

Browse files
committed
refactor: remove legacy env restoration block from EnvironmentLoader
Eliminated the old immutability logic that re-applied the original $_ENV values after loading. The EnvironmentLoader now follows a cleaner and more predictable load flow without overriding user-injected or runtime environment variables.
1 parent 4630c91 commit 226a9dc

3 files changed

Lines changed: 13 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@
77
88
---
99

10+
## [1.0.4] - 2025-11-14
11+
### Changed
12+
- Removed legacy environment variable restoration logic from `EnvironmentLoader`.
13+
- Deleted the immutability block that re-applied original `$_ENV` values after loading.
14+
- Simplified the loader flow to avoid unintended overrides and ensure consistent variable precedence.
15+
16+
### Improved
17+
- Environment loading now behaves predictably and respects the current process environment without forced rollback.
18+
- Codebase cleanup for clarity and reduced side-effects.
19+
20+
---
21+
1022
## [1.0.3] — 2025-11-13
1123
Release 1.0.3 (fix missing VERSION update)
1224

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.3
1+
1.0.4

src/Core/EnvironmentLoader.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ public function load(): void
8888
$envFiles = ['.env.local', '.env.testing', '.env', '.env.example'];
8989
$loaded = false;
9090

91-
// Preserve pre-existing environment variables
92-
$existing = $_ENV;
93-
9491
foreach ($envFiles as $file) {
9592
$path = $this->basePath . DIRECTORY_SEPARATOR . $file;
9693

@@ -108,12 +105,6 @@ public function load(): void
108105
throw new Exception('No .env file found in ' . $this->basePath);
109106
}
110107

111-
// ♻️ Restore original environment variables (maintain immutability guarantee)
112-
foreach ($existing as $key => $value) {
113-
$_ENV[$key] = $value;
114-
putenv("$key=$value");
115-
}
116-
117108
// 🕒 Apply timezone setting (default: Africa/Cairo)
118109
$timezone = $_ENV['APP_TIMEZONE']
119110
?? $_SERVER['APP_TIMEZONE']

0 commit comments

Comments
 (0)