From 83f69ca1cb88de8a4814eed36c1853b1eefd9982 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 27 Dec 2024 09:06:31 +0700 Subject: [PATCH] refactor: clean condition check --- system/Config/DotEnv.php | 2 +- system/Database/Database.php | 2 +- system/Database/MigrationRunner.php | 2 +- system/Images/Image.php | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/system/Config/DotEnv.php b/system/Config/DotEnv.php index 9c120afec523..9e890a88b051 100644 --- a/system/Config/DotEnv.php +++ b/system/Config/DotEnv.php @@ -94,7 +94,7 @@ public function parse(): ?array */ protected function setVariable(string $name, string $value = '') { - if (in_array(getenv($name, true), ['', '0'], true) || getenv($name, true) === [] || getenv($name, true) === false) { + if (in_array(getenv($name, true), ['', '0', [], false], true)) { putenv("{$name}={$value}"); } diff --git a/system/Database/Database.php b/system/Database/Database.php index 3d4840f2e595..e09dcdd27481 100644 --- a/system/Database/Database.php +++ b/system/Database/Database.php @@ -96,7 +96,7 @@ protected function parseDSN(array $params): array { $dsn = parse_url($params['DSN']); - if ($dsn === 0 || ($dsn === '' || $dsn === '0') || $dsn === [] || $dsn === false || $dsn === null) { + if ($dsn === 0 || $dsn === '' || $dsn === '0' || $dsn === [] || $dsn === false || $dsn === null) { throw new InvalidArgumentException('Your DSN connection string is invalid.'); } diff --git a/system/Database/MigrationRunner.php b/system/Database/MigrationRunner.php index bd94607d9105..f2eb33112016 100644 --- a/system/Database/MigrationRunner.php +++ b/system/Database/MigrationRunner.php @@ -725,7 +725,7 @@ public function getBatchStart(int $batch): string ->get() ->getResultObject(); - return count($migration) !== 0 ? $migration[0]->version : '0'; + return count($migration) > 0 ? $migration[0]->version : '0'; } /** diff --git a/system/Images/Image.php b/system/Images/Image.php index 1f857b00f780..ab9aa51a6ec7 100644 --- a/system/Images/Image.php +++ b/system/Images/Image.php @@ -102,8 +102,9 @@ public function copy(string $targetPath, ?string $targetName = null, int $perms public function getProperties(bool $return = false) { $path = $this->getPathname(); + $vals = getimagesize($path); - if ($vals = getimagesize($path) === [] || $vals = getimagesize($path) === false) { + if ($vals === [] || $vals === false) { throw ImageException::forFileNotSupported(); }