@@ -40,7 +40,7 @@ public function __construct(
4040
4141 public static function fromEnv (string $ alias , ?array $ env = null )
4242 {
43- $ env = is_null ( $ env) ? $ _ENV : $ env ;
43+ $ env = $ env ?? getenv () ;
4444 $ alias = strtoupper ($ alias );
4545
4646 $ driver = DriverManager::fromEnv ($ alias , $ env );
@@ -53,16 +53,16 @@ public static function fromEnv(string $alias, ?array $env = null)
5353 $ pwflKey = "DATABASE_ {$ alias }_PSWD_FILE " ;
5454 $ instKey = "DATABASE_ {$ alias }_INST " ;
5555
56- $ host = getenv ( $ hostKey) ?? $ driver ->getDefaultHost ();
57- $ port = getenv ( $ portKey) ?? $ driver ->getDefaultPort ();
58- $ user = getenv ( $ userKey) ?? $ driver ->getDefaultUser ();
59- $ name = getenv ( $ nameKey) ?? $ alias ;
60- $ encd = getenv ( $ encdKey) ?? null ;
61- $ inst = getenv ( $ instKey) ?? null ;
56+ $ host = $ env [ $ hostKey] ?? $ driver ->getDefaultHost ();
57+ $ port = $ env [ $ portKey] ?? $ driver ->getDefaultPort ();
58+ $ user = $ env [ $ userKey] ?? $ driver ->getDefaultUser ();
59+ $ name = $ env [ $ nameKey] ?? $ alias ;
60+ $ encd = $ env [ $ encdKey] ?? null ;
61+ $ inst = $ env [ $ instKey] ?? null ;
6262
63- $ pswd = getenv ( $ pswdKey) ?? $ driver ->getDefaultPswd ();
64- if (!empty (getenv ( $ pwflKey)) && file_exists (getenv ( $ pwflKey) )) {
65- $ pswd = file_get_contents (getenv ( $ pwflKey) );
63+ $ pswd = $ env [ $ pswdKey] ?? $ driver ->getDefaultPswd ();
64+ if (!empty ($ env [ $ pwflKey]) && file_exists ($ env [ $ pwflKey] )) {
65+ $ pswd = file_get_contents ($ env [ $ pwflKey] );
6666 }
6767
6868 return new ConnectParams ($ driver , $ host , $ user , $ pswd , $ name , $ port , $ encd , $ inst );
0 commit comments