From 1de08fa47e0cc465330aa1b13659088b830d5e38 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 27 Oct 2023 13:22:26 +0700 Subject: [PATCH] [Rector] Apply SingleInArrayToCompareRector --- rector.php | 2 ++ system/Config/BaseService.php | 2 +- tests/system/Database/Live/GroupTest.php | 16 ++++++++-------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/rector.php b/rector.php index 89b92f15e58d..747cd4ce8bbd 100644 --- a/rector.php +++ b/rector.php @@ -16,6 +16,7 @@ use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector; use Rector\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector; use Rector\CodeQuality\Rector\FuncCall\SimplifyStrposLowerRector; +use Rector\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector; use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector; use Rector\CodeQuality\Rector\If_\CombineIfRector; use Rector\CodeQuality\Rector\If_\ShortenElseIfRector; @@ -142,4 +143,5 @@ $rectorConfig->rule(PrivatizeFinalClassPropertyRector::class); $rectorConfig->rule(CompleteDynamicPropertiesRector::class); $rectorConfig->rule(BooleanInIfConditionRuleFixerRector::class); + $rectorConfig->rule(SingleInArrayToCompareRector::class); }; diff --git a/system/Config/BaseService.php b/system/Config/BaseService.php index 22daf7b69e4b..1c80c80d77c6 100644 --- a/system/Config/BaseService.php +++ b/system/Config/BaseService.php @@ -343,7 +343,7 @@ protected static function discoverServices(string $name, array $arguments) foreach ($files as $file) { $classname = $locator->getClassname($file); - if (! in_array($classname, [Services::class], true)) { + if ($classname !== Services::class) { static::$services[] = new $classname(); } } diff --git a/tests/system/Database/Live/GroupTest.php b/tests/system/Database/Live/GroupTest.php index c953645dcab4..b509229ece08 100644 --- a/tests/system/Database/Live/GroupTest.php +++ b/tests/system/Database/Live/GroupTest.php @@ -40,7 +40,7 @@ public function testGroupBy(): void public function testHavingBy(): void { - $isANSISQL = in_array($this->db->DBDriver, ['OCI8'], true); + $isANSISQL = $this->db->DBDriver === 'OCI8'; if ($isANSISQL) { $result = $this->db->table('job') @@ -63,7 +63,7 @@ public function testHavingBy(): void public function testOrHavingBy(): void { - $isANSISQL = in_array($this->db->DBDriver, ['OCI8'], true); + $isANSISQL = $this->db->DBDriver === 'OCI8'; if ($isANSISQL) { $result = $this->db->table('user') @@ -134,7 +134,7 @@ public function testHavingNotIn(): void public function testOrHavingNotIn(): void { - $isANSISQL = in_array($this->db->DBDriver, ['OCI8'], true); + $isANSISQL = $this->db->DBDriver === 'OCI8'; if ($isANSISQL) { $result = $this->db->table('job') @@ -207,7 +207,7 @@ public function testOrHavingLike(): void public function testOrNotHavingLike(): void { - $isANSISQL = in_array($this->db->DBDriver, ['OCI8'], true); + $isANSISQL = $this->db->DBDriver === 'OCI8'; if ($isANSISQL) { $result = $this->db->table('job') @@ -237,7 +237,7 @@ public function testOrNotHavingLike(): void public function testAndHavingGroupStart(): void { - $isANSISQL = in_array($this->db->DBDriver, ['OCI8'], true); + $isANSISQL = $this->db->DBDriver === 'OCI8'; if ($isANSISQL) { $result = $this->db->table('job') @@ -271,7 +271,7 @@ public function testAndHavingGroupStart(): void public function testOrHavingGroupStart(): void { - $isANSISQL = in_array($this->db->DBDriver, ['OCI8'], true); + $isANSISQL = $this->db->DBDriver === 'OCI8'; if ($isANSISQL) { $result = $this->db->table('job') @@ -306,7 +306,7 @@ public function testOrHavingGroupStart(): void public function testNotHavingGroupStart(): void { - $isANSISQL = in_array($this->db->DBDriver, ['OCI8'], true); + $isANSISQL = $this->db->DBDriver === 'OCI8'; if ($isANSISQL) { $result = $this->db->table('job') @@ -340,7 +340,7 @@ public function testNotHavingGroupStart(): void public function testOrNotHavingGroupStart(): void { - $isANSISQL = in_array($this->db->DBDriver, ['OCI8'], true); + $isANSISQL = $this->db->DBDriver === 'OCI8'; if ($isANSISQL) { $result = $this->db->table('job')