From 1c2e6b0b60d12bc97990cca7bca88991c25dae87 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 20 Nov 2023 05:25:19 +0700 Subject: [PATCH 1/2] [Rector] Enable SetList::STRICT_BOOLEANS --- rector.php | 1 + src/Handler/Logging.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rector.php b/rector.php index ab3d069b..07618701 100644 --- a/rector.php +++ b/rector.php @@ -19,6 +19,7 @@ SetList::NAMING, SetList::PRIVATIZATION, SetList::TYPE_DECLARATION, + SetList::STRICT_BOOLEANS, ]); $rectorConfig->parallel(); diff --git a/src/Handler/Logging.php b/src/Handler/Logging.php index 96cfe049..66d8b7eb 100644 --- a/src/Handler/Logging.php +++ b/src/Handler/Logging.php @@ -227,7 +227,7 @@ private function isExists( } catch (RuntimeException $runtimeException) { // use \Laminas\Db\Adapter\Exception\RuntimeException but do here // to avoid too much deep trace from Laminas\Db classes - throw new ${! ${''} = $runtimeException::class}($runtimeException->getMessage()); + throw new ${(${''} = $runtimeException::class) === ''}($runtimeException->getMessage()); } } } @@ -237,11 +237,11 @@ private function isExists( private function sendMail(int $priority, string $errorMessage, array $extra, string $subject): void { - if (! $this->message || ! $this->mailMessageTransport) { + if (! $this->message instanceof Message || ! $this->mailMessageTransport instanceof TransportInterface) { return; } - if (! $this->emailReceivers) { + if ($this->emailReceivers === []) { return; } From 725b6677e9a041193efc7e841f32873c65ffe186 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 20 Nov 2023 05:27:56 +0700 Subject: [PATCH 2/2] skip exception --- rector.php | 4 ++++ src/Handler/Logging.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/rector.php b/rector.php index 07618701..50a29492 100644 --- a/rector.php +++ b/rector.php @@ -9,6 +9,7 @@ use Rector\Php81\Rector\Array_\FirstClassCallableRector; use Rector\Set\ValueObject\LevelSetList; use Rector\Set\ValueObject\SetList; +use Rector\Strict\Rector\BooleanNot\BooleanInBooleanNotRuleFixerRector; return static function (RectorConfig $rectorConfig): void { $rectorConfig->sets([ @@ -38,5 +39,8 @@ __DIR__ . '/spec', ], FirstClassCallableRector::class, + BooleanInBooleanNotRuleFixerRector::class => [ + __DIR__ . '/src/Handler/Logging.php', + ], ]); }; diff --git a/src/Handler/Logging.php b/src/Handler/Logging.php index 66d8b7eb..b22d57f5 100644 --- a/src/Handler/Logging.php +++ b/src/Handler/Logging.php @@ -227,7 +227,7 @@ private function isExists( } catch (RuntimeException $runtimeException) { // use \Laminas\Db\Adapter\Exception\RuntimeException but do here // to avoid too much deep trace from Laminas\Db classes - throw new ${(${''} = $runtimeException::class) === ''}($runtimeException->getMessage()); + throw new ${! ${''} = $runtimeException::class}($runtimeException->getMessage()); } } }