Skip to content

Commit 23e62eb

Browse files
Use is_file() instead of file_exists() where possible
1 parent 4627980 commit 23e62eb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Dotenv.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function loadEnv(string $path, string $envKey = null, string $defaultEnv
110110
{
111111
$k = $envKey ?? $this->envKey;
112112

113-
if (file_exists($path) || !file_exists($p = "$path.dist")) {
113+
if (is_file($path) || !is_file($p = "$path.dist")) {
114114
$this->load($path);
115115
} else {
116116
$this->load($p);
@@ -120,7 +120,7 @@ public function loadEnv(string $path, string $envKey = null, string $defaultEnv
120120
$this->populate([$k => $env = $defaultEnv]);
121121
}
122122

123-
if (!\in_array($env, $testEnvs, true) && file_exists($p = "$path.local")) {
123+
if (!\in_array($env, $testEnvs, true) && is_file($p = "$path.local")) {
124124
$this->load($p);
125125
$env = $_SERVER[$k] ?? $_ENV[$k] ?? $env;
126126
}
@@ -129,11 +129,11 @@ public function loadEnv(string $path, string $envKey = null, string $defaultEnv
129129
return;
130130
}
131131

132-
if (file_exists($p = "$path.$env")) {
132+
if (is_file($p = "$path.$env")) {
133133
$this->load($p);
134134
}
135135

136-
if (file_exists($p = "$path.$env.local")) {
136+
if (is_file($p = "$path.$env.local")) {
137137
$this->load($p);
138138
}
139139
}
@@ -148,7 +148,7 @@ public function loadEnv(string $path, string $envKey = null, string $defaultEnv
148148
public function bootEnv(string $path, string $defaultEnv = 'dev', array $testEnvs = ['test']): void
149149
{
150150
$p = $path.'.local.php';
151-
$env = (\function_exists('opcache_is_script_cached') && @opcache_is_script_cached($p)) || file_exists($p) ? include $p : null;
151+
$env = is_file($p) ? include $p : null;
152152
$k = $this->envKey;
153153

154154
if (\is_array($env) && (!isset($env[$k]) || ($_SERVER[$k] ?? $_ENV[$k] ?? $env[$k]) === $env[$k])) {

0 commit comments

Comments
 (0)