Skip to content

Commit 990e0e7

Browse files
Replace file_exists with is_file in hot code (#33124)
1 parent 1ae3e0b commit 990e0e7

File tree

14 files changed

+21
-21
lines changed

14 files changed

+21
-21
lines changed

src/Illuminate/Console/Scheduling/Event.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ protected function ensureOutputIsBeingCaptured()
475475
*/
476476
protected function emailOutput(Mailer $mailer, $addresses, $onlyIfOutputExists = false)
477477
{
478-
$text = file_exists($this->output) ? file_get_contents($this->output) : '';
478+
$text = is_file($this->output) ? file_get_contents($this->output) : '';
479479

480480
if ($onlyIfOutputExists && empty($text)) {
481481
return;
@@ -833,7 +833,7 @@ public function onFailureWithOutput(Closure $callback, $onlyIfOutputExists = fal
833833
protected function withOutputCallback(Closure $callback, $onlyIfOutputExists = false)
834834
{
835835
return function (Container $container) use ($callback, $onlyIfOutputExists) {
836-
$output = $this->output && file_exists($this->output) ? file_get_contents($this->output) : '';
836+
$output = $this->output && is_file($this->output) ? file_get_contents($this->output) : '';
837837

838838
return $onlyIfOutputExists && empty($output)
839839
? null

src/Illuminate/Database/Console/Migrations/MigrateCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ protected function loadSchemaState()
129129
// continue with the standard migration operation as normal without errors.
130130
if ($connection instanceof SQLiteConnection ||
131131
$connection instanceof SqlServerConnection ||
132-
! file_exists($path = $this->schemaPath($connection))) {
132+
! is_file($path = $this->schemaPath($connection))) {
133133
return;
134134
}
135135

src/Illuminate/Database/Console/Seeds/SeederMakeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected function getStub()
5555
*/
5656
protected function resolveStubPath($stub)
5757
{
58-
return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
58+
return is_file($customPath = $this->laravel->basePath(trim($stub, '/')))
5959
? $customPath
6060
: __DIR__.$stub;
6161
}

src/Illuminate/Foundation/AliasLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ protected function loadFacade($alias)
100100
*/
101101
protected function ensureFacadeExists($alias)
102102
{
103-
if (file_exists($path = storage_path('framework/cache/facade-'.sha1($alias).'.php'))) {
103+
if (is_file($path = storage_path('framework/cache/facade-'.sha1($alias).'.php'))) {
104104
return $path;
105105
}
106106

src/Illuminate/Foundation/Application.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ public function getCachedPackagesPath()
957957
*/
958958
public function configurationIsCached()
959959
{
960-
return file_exists($this->getCachedConfigPath());
960+
return is_file($this->getCachedConfigPath());
961961
}
962962

963963
/**
@@ -1048,7 +1048,7 @@ public function addAbsoluteCachePathPrefix($prefix)
10481048
*/
10491049
public function isDownForMaintenance()
10501050
{
1051-
return file_exists($this->storagePath().'/framework/down');
1051+
return is_file($this->storagePath().'/framework/down');
10521052
}
10531053

10541054
/**

src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function bootstrap(Application $app)
2424
// First we will see if we have a cache configuration file. If we do, we'll load
2525
// the configuration items from that file so that it is very quick. Otherwise
2626
// we will need to spin through every configuration file and load them all.
27-
if (file_exists($cached = $app->getCachedConfigPath())) {
27+
if (is_file($cached = $app->getCachedConfigPath())) {
2828
$items = require $cached;
2929

3030
$loadedFromCache = true;

src/Illuminate/Foundation/Bootstrap/LoadEnvironmentVariables.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected function checkForSpecificEnvironmentFile($app)
6868
*/
6969
protected function setEnvironmentFilePath($app, $file)
7070
{
71-
if (file_exists($app->environmentPath().'/'.$file)) {
71+
if (is_file($app->environmentPath().'/'.$file)) {
7272
$app->loadEnvironmentFrom($file);
7373

7474
return true;

src/Illuminate/Foundation/ComposerScripts.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ protected static function clearCompiled()
5454
{
5555
$laravel = new Application(getcwd());
5656

57-
if (file_exists($servicesPath = $laravel->getCachedServicesPath())) {
57+
if (is_file($servicesPath = $laravel->getCachedServicesPath())) {
5858
@unlink($servicesPath);
5959
}
6060

61-
if (file_exists($packagesPath = $laravel->getCachedPackagesPath())) {
61+
if (is_file($packagesPath = $laravel->getCachedPackagesPath())) {
6262
@unlink($packagesPath);
6363
}
6464
}

src/Illuminate/Foundation/Console/ClearCompiledCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ class ClearCompiledCommand extends Command
2727
*/
2828
public function handle()
2929
{
30-
if (file_exists($servicesPath = $this->laravel->getCachedServicesPath())) {
30+
if (is_file($servicesPath = $this->laravel->getCachedServicesPath())) {
3131
@unlink($servicesPath);
3232
}
3333

34-
if (file_exists($packagesPath = $this->laravel->getCachedPackagesPath())) {
34+
if (is_file($packagesPath = $this->laravel->getCachedPackagesPath())) {
3535
@unlink($packagesPath);
3636
}
3737

src/Illuminate/Foundation/Console/DownCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class DownCommand extends Command
3434
public function handle()
3535
{
3636
try {
37-
if (file_exists(storage_path('framework/down'))) {
37+
if (is_file(storage_path('framework/down'))) {
3838
$this->comment('Application is already down.');
3939

4040
return 0;

0 commit comments

Comments
 (0)