Skip to content

Commit 738e45f

Browse files
committed
fix(env): resolve PHPStan “left side of ?? is not nullable” for getenv()
Normalized getenv() handling to convert its false return value into null, ensuring the expression becomes nullable as required by PHPStan. Updated the environment resolution chain to use an explicit ternary for getenv() so the final ?? $default fallback remains valid. Fully resolves PHPStan warning: “Expression on left side of ?? is not nullable.”
1 parent 8515857 commit 738e45f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/Helpers/EnvHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public static function get(string $key, mixed $default = null): mixed
8484

8585
// 🔍 Search through multiple sources
8686
$value = $_ENV[$key]
87-
?? $_SERVER[$key]
88-
?? getenv($key)
87+
?? ($_SERVER[$key] ?? null)
88+
?? (($env = getenv($key)) !== false ? $env : null)
8989
?? $default;
9090

9191
// 🧠 Cache the resolved value for future requests

0 commit comments

Comments
 (0)