Skip to content

Commit 2b11488

Browse files
Use is_file() instead of file_exists() where possible
1 parent 84811b0 commit 2b11488

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

KernelBrowser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ protected function getScript($request)
198198
if (0 === strpos($class, 'ComposerAutoloaderInit')) {
199199
$r = new \ReflectionClass($class);
200200
$file = \dirname($r->getFileName(), 2).'/autoload.php';
201-
if (file_exists($file)) {
201+
if (is_file($file)) {
202202
$requires .= 'require_once '.var_export($file, true).";\n";
203203
}
204204
}

Secrets/DotenvVault.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function seal(string $name, string $value): void
3838
$this->validateName($name);
3939
$v = str_replace("'", "'\\''", $value);
4040

41-
$content = file_exists($this->dotenvFile) ? file_get_contents($this->dotenvFile) : '';
41+
$content = is_file($this->dotenvFile) ? file_get_contents($this->dotenvFile) : '';
4242
$content = preg_replace("/^$name=((\\\\'|'[^']++')++|.*)/m", "$name='$v'", $content, -1, $count);
4343

4444
if (!$count) {
@@ -70,7 +70,7 @@ public function remove(string $name): bool
7070
$this->lastMessage = null;
7171
$this->validateName($name);
7272

73-
$content = file_exists($this->dotenvFile) ? file_get_contents($this->dotenvFile) : '';
73+
$content = is_file($this->dotenvFile) ? file_get_contents($this->dotenvFile) : '';
7474
$content = preg_replace("/^$name=((\\\\'|'[^']++')++|.*)\n?/m", '', $content, -1, $count);
7575

7676
if ($count) {

Secrets/SodiumVault.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function generateKeys(bool $override = false): bool
5858
// ignore failures to load keys
5959
}
6060

61-
if ('' !== $this->decryptionKey && !file_exists($this->pathPrefix.'encrypt.public.php')) {
61+
if ('' !== $this->decryptionKey && !is_file($this->pathPrefix.'encrypt.public.php')) {
6262
$this->export('encrypt.public', $this->encryptionKey);
6363
}
6464

@@ -99,7 +99,7 @@ public function reveal(string $name): ?string
9999
$this->lastMessage = null;
100100
$this->validateName($name);
101101

102-
if (!file_exists($file = $this->pathPrefix.$name.'.'.substr_replace(md5($name), '.php', -26))) {
102+
if (!is_file($file = $this->pathPrefix.$name.'.'.substr_replace(md5($name), '.php', -26))) {
103103
$this->lastMessage = sprintf('Secret "%s" not found in "%s".', $name, $this->getPrettyPath(\dirname($this->pathPrefix).\DIRECTORY_SEPARATOR));
104104

105105
return null;
@@ -133,7 +133,7 @@ public function remove(string $name): bool
133133
$this->lastMessage = null;
134134
$this->validateName($name);
135135

136-
if (!file_exists($file = $this->pathPrefix.$name.'.'.substr_replace(md5($name), '.php', -26))) {
136+
if (!is_file($file = $this->pathPrefix.$name.'.'.substr_replace(md5($name), '.php', -26))) {
137137
$this->lastMessage = sprintf('Secret "%s" not found in "%s".', $name, $this->getPrettyPath(\dirname($this->pathPrefix).\DIRECTORY_SEPARATOR));
138138

139139
return false;
@@ -152,7 +152,7 @@ public function list(bool $reveal = false): array
152152
{
153153
$this->lastMessage = null;
154154

155-
if (!file_exists($file = $this->pathPrefix.'list.php')) {
155+
if (!is_file($file = $this->pathPrefix.'list.php')) {
156156
return [];
157157
}
158158

@@ -184,11 +184,11 @@ private function loadKeys(): void
184184
return;
185185
}
186186

187-
if (file_exists($this->pathPrefix.'decrypt.private.php')) {
187+
if (is_file($this->pathPrefix.'decrypt.private.php')) {
188188
$this->decryptionKey = (string) include $this->pathPrefix.'decrypt.private.php';
189189
}
190190

191-
if (file_exists($this->pathPrefix.'encrypt.public.php')) {
191+
if (is_file($this->pathPrefix.'encrypt.public.php')) {
192192
$this->encryptionKey = (string) include $this->pathPrefix.'encrypt.public.php';
193193
} elseif ('' !== $this->decryptionKey) {
194194
$this->encryptionKey = sodium_crypto_box_publickey($this->decryptionKey);

0 commit comments

Comments
 (0)