Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Replace file_exists with is_file in hot code #33124

Merged
merged 1 commit into from
Jun 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Illuminate/Console/Scheduling/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ protected function ensureOutputIsBeingCaptured()
*/
protected function emailOutput(Mailer $mailer, $addresses, $onlyIfOutputExists = false)
{
$text = file_exists($this->output) ? file_get_contents($this->output) : '';
$text = is_file($this->output) ? file_get_contents($this->output) : '';

if ($onlyIfOutputExists && empty($text)) {
return;
Expand Down Expand Up @@ -833,7 +833,7 @@ public function onFailureWithOutput(Closure $callback, $onlyIfOutputExists = fal
protected function withOutputCallback(Closure $callback, $onlyIfOutputExists = false)
{
return function (Container $container) use ($callback, $onlyIfOutputExists) {
$output = $this->output && file_exists($this->output) ? file_get_contents($this->output) : '';
$output = $this->output && is_file($this->output) ? file_get_contents($this->output) : '';

return $onlyIfOutputExists && empty($output)
? null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ protected function loadSchemaState()
// continue with the standard migration operation as normal without errors.
if ($connection instanceof SQLiteConnection ||
$connection instanceof SqlServerConnection ||
! file_exists($path = $this->schemaPath($connection))) {
! is_file($path = $this->schemaPath($connection))) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected function getStub()
*/
protected function resolveStubPath($stub)
{
return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
return is_file($customPath = $this->laravel->basePath(trim($stub, '/')))
? $customPath
: __DIR__.$stub;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/AliasLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected function loadFacade($alias)
*/
protected function ensureFacadeExists($alias)
{
if (file_exists($path = storage_path('framework/cache/facade-'.sha1($alias).'.php'))) {
if (is_file($path = storage_path('framework/cache/facade-'.sha1($alias).'.php'))) {
return $path;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ public function getCachedPackagesPath()
*/
public function configurationIsCached()
{
return file_exists($this->getCachedConfigPath());
return is_file($this->getCachedConfigPath());
}

/**
Expand Down Expand Up @@ -1048,7 +1048,7 @@ public function addAbsoluteCachePathPrefix($prefix)
*/
public function isDownForMaintenance()
{
return file_exists($this->storagePath().'/framework/down');
return is_file($this->storagePath().'/framework/down');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function bootstrap(Application $app)
// First we will see if we have a cache configuration file. If we do, we'll load
// the configuration items from that file so that it is very quick. Otherwise
// we will need to spin through every configuration file and load them all.
if (file_exists($cached = $app->getCachedConfigPath())) {
if (is_file($cached = $app->getCachedConfigPath())) {
$items = require $cached;

$loadedFromCache = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function checkForSpecificEnvironmentFile($app)
*/
protected function setEnvironmentFilePath($app, $file)
{
if (file_exists($app->environmentPath().'/'.$file)) {
if (is_file($app->environmentPath().'/'.$file)) {
$app->loadEnvironmentFrom($file);

return true;
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Foundation/ComposerScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ protected static function clearCompiled()
{
$laravel = new Application(getcwd());

if (file_exists($servicesPath = $laravel->getCachedServicesPath())) {
if (is_file($servicesPath = $laravel->getCachedServicesPath())) {
@unlink($servicesPath);
}

if (file_exists($packagesPath = $laravel->getCachedPackagesPath())) {
if (is_file($packagesPath = $laravel->getCachedPackagesPath())) {
@unlink($packagesPath);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Foundation/Console/ClearCompiledCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ class ClearCompiledCommand extends Command
*/
public function handle()
{
if (file_exists($servicesPath = $this->laravel->getCachedServicesPath())) {
if (is_file($servicesPath = $this->laravel->getCachedServicesPath())) {
@unlink($servicesPath);
}

if (file_exists($packagesPath = $this->laravel->getCachedPackagesPath())) {
if (is_file($packagesPath = $this->laravel->getCachedPackagesPath())) {
@unlink($packagesPath);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Console/DownCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DownCommand extends Command
public function handle()
{
try {
if (file_exists(storage_path('framework/down'))) {
if (is_file(storage_path('framework/down'))) {
$this->comment('Application is already down.');

return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Console/UpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class UpCommand extends Command
public function handle()
{
try {
if (! file_exists(storage_path('framework/down'))) {
if (! is_file(storage_path('framework/down'))) {
$this->comment('Application is already up.');

return 0;
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Foundation/Mix.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __invoke($path, $manifestDirectory = '')
$manifestDirectory = "/{$manifestDirectory}";
}

if (file_exists(public_path($manifestDirectory.'/hot'))) {
if (is_file(public_path($manifestDirectory.'/hot'))) {
$url = rtrim(file_get_contents(public_path($manifestDirectory.'/hot')));

if (Str::startsWith($url, ['http://', 'https://'])) {
Expand All @@ -42,7 +42,7 @@ public function __invoke($path, $manifestDirectory = '')
$manifestPath = public_path($manifestDirectory.'/mix-manifest.json');

if (! isset($manifests[$manifestPath])) {
if (! file_exists($manifestPath)) {
if (! is_file($manifestPath)) {
throw new Exception('The Mix manifest does not exist.');
}

Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Foundation/PackageManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ protected function getManifest()
return $this->manifest;
}

if (! file_exists($this->manifestPath)) {
if (! is_file($this->manifestPath)) {
$this->build();
}

return $this->manifest = file_exists($this->manifestPath) ?
return $this->manifest = is_file($this->manifestPath) ?
$this->files->getRequire($this->manifestPath) : [];
}

Expand Down Expand Up @@ -154,7 +154,7 @@ protected function format($package)
*/
protected function packagesToIgnore()
{
if (! file_exists($this->basePath.'/composer.json')) {
if (! is_file($this->basePath.'/composer.json')) {
return [];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/View/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected function createBladeViewFromString($factory, $contents)
$directory = Container::getInstance()['config']->get('view.compiled')
);

if (! file_exists($viewFile = $directory.'/'.sha1($contents).'.blade.php')) {
if (! is_file($viewFile = $directory.'/'.sha1($contents).'.blade.php')) {
if (! is_dir($directory)) {
mkdir($directory, 0755, true);
}
Expand Down