Prefer is_file

This commit is contained in:
MGatner 2022-05-24 16:53:04 +00:00
parent a20aa88c1a
commit e3a00ee5f6
No known key found for this signature in database
GPG Key ID: 9CA44105713F5A12
13 changed files with 18 additions and 18 deletions

View File

@ -7,7 +7,7 @@ $routes = Services::routes();
// Load the system's routing file first, so that the app and ENVIRONMENT
// can override as needed.
if (file_exists(SYSTEMPATH . 'Config/Routes.php')) {
if (is_file(SYSTEMPATH . 'Config/Routes.php')) {
require SYSTEMPATH . 'Config/Routes.php';
}
@ -50,6 +50,6 @@ $routes->get('/', 'Home::index');
* You will have access to the $routes object within that file without
* needing to reload it.
*/
if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) {
if (is_file(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) {
require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
}

View File

@ -246,7 +246,7 @@ class CodeIgniter
$file = SYSTEMPATH . 'ThirdParty/Kint/' . implode('/', $class) . '.php';
if (file_exists($file)) {
if (is_file($file)) {
require_once $file;
}
});

View File

@ -151,8 +151,8 @@ class GenerateKey extends BaseCommand
$baseEnv = ROOTPATH . 'env';
$envFile = ROOTPATH . '.env';
if (! file_exists($envFile)) {
if (! file_exists($baseEnv)) {
if (! is_file($envFile)) {
if (! is_file($baseEnv)) {
CLI::write('Both default shipped `env` file and custom `.env` are missing.', 'yellow');
CLI::write('Here\'s your new key instead: ' . CLI::color($newKey, 'yellow'));
CLI::newLine();

View File

@ -53,7 +53,7 @@ defined('COMPOSER_PATH') || define('COMPOSER_PATH', realpath(HOMEPATH . 'vendor/
defined('VENDORPATH') || define('VENDORPATH', realpath(HOMEPATH . 'vendor') . DIRECTORY_SEPARATOR);
// Load Common.php from App then System
if (file_exists(APPPATH . 'Common.php')) {
if (is_file(APPPATH . 'Common.php')) {
require_once APPPATH . 'Common.php';
}

View File

@ -47,7 +47,7 @@ final class CommandGeneratorTest extends CIUnitTestCase
protected function getFileContents(string $filepath): string
{
if (! file_exists($filepath)) {
if (! is_file($filepath)) {
return '';
}

View File

@ -42,7 +42,7 @@ final class ControllerGeneratorTest extends CIUnitTestCase
protected function getFileContents(string $filepath): string
{
if (! file_exists($filepath)) {
if (! is_file($filepath)) {
return '';
}

View File

@ -39,7 +39,7 @@ final class CreateDatabaseTest extends CIUnitTestCase
if ($this->connection instanceof SQLite3Connection) {
$file = WRITEPATH . 'foobar.db';
if (file_exists($file)) {
if (is_file($file)) {
unlink($file);
}
} else {

View File

@ -36,7 +36,7 @@ final class GenerateKeyTest extends CIUnitTestCase
$this->envPath = ROOTPATH . '.env';
$this->backupEnvPath = ROOTPATH . '.env.backup';
if (file_exists($this->envPath)) {
if (is_file($this->envPath)) {
rename($this->envPath, $this->backupEnvPath);
}
@ -47,11 +47,11 @@ final class GenerateKeyTest extends CIUnitTestCase
{
stream_filter_remove($this->streamFilter);
if (file_exists($this->envPath)) {
if (is_file($this->envPath)) {
unlink($this->envPath);
}
if (file_exists($this->backupEnvPath)) {
if (is_file($this->backupEnvPath)) {
rename($this->backupEnvPath, $this->envPath);
}

View File

@ -35,7 +35,7 @@ final class MigrationGeneratorTest extends CIUnitTestCase
$result = str_replace(["\033[0;32m", "\033[0m", "\n"], '', CITestStreamFilter::$buffer);
$file = str_replace('APPPATH' . DIRECTORY_SEPARATOR, APPPATH, trim(substr($result, 14)));
if (file_exists($file)) {
if (is_file($file)) {
unlink($file);
}
}

View File

@ -42,7 +42,7 @@ final class ScaffoldGeneratorTest extends CIUnitTestCase
protected function getFileContents(string $filepath): string
{
if (! file_exists($filepath)) {
if (! is_file($filepath)) {
return '';
}

View File

@ -35,7 +35,7 @@ final class SeederGeneratorTest extends CIUnitTestCase
$result = str_replace(["\033[0;32m", "\033[0m", "\n"], '', CITestStreamFilter::$buffer);
$file = str_replace('APPPATH' . DIRECTORY_SEPARATOR, APPPATH, trim(substr($result, 14)));
if (file_exists($file)) {
if (is_file($file)) {
unlink($file);
}
}

View File

@ -326,11 +326,11 @@ final class FileMovingTest extends CIUnitTestCase
function is_uploaded_file($filename)
{
if (! file_exists($filename)) {
if (! is_file($filename)) {
file_put_contents($filename, 'data');
}
return file_exists($filename);
return is_file($filename);
}
/*

View File

@ -78,7 +78,7 @@ final class BootstrapFCPATHTest extends CIUnitTestCase
private function deleteFiles(): void
{
if (file_exists($this->file1)) {
if (is_file($this->file1)) {
unlink($this->file1);
}
}