diff --git a/composer.json b/composer.json index 03ec27b35492..d548b7a1eddc 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "phpunit/phpcov": "^9.0.2 || ^10.0", "phpunit/phpunit": "^10.5.16 || ^11.2", "predis/predis": "^3.0", - "rector/rector": "2.1.7", + "rector/rector": "2.2.1", "shipmonk/phpstan-baseline-per-identifier": "^2.0" }, "replace": { diff --git a/rector.php b/rector.php index 44c1d838c7e4..680f422a562e 100644 --- a/rector.php +++ b/rector.php @@ -202,4 +202,4 @@ // keep '\\' prefix string on string '\Foo\Bar' StringClassNameToClassConstantRector::SHOULD_KEEP_PRE_SLASH => true, ]) - ->withCodeQualityLevel(52); + ->withCodeQualityLevel(53); diff --git a/system/BaseModel.php b/system/BaseModel.php index a1859a11b450..fdc07ba2330d 100644 --- a/system/BaseModel.php +++ b/system/BaseModel.php @@ -769,7 +769,7 @@ protected function shouldUpdate($row): bool { $id = $this->getIdValue($row); - return ! ($id === null || $id === [] || $id === ''); + return ! in_array($id, [null, [], ''], true); } /** diff --git a/system/Common.php b/system/Common.php index d604c07d6f56..41b16100c295 100644 --- a/system/Common.php +++ b/system/Common.php @@ -1121,7 +1121,7 @@ function stringify_attributes($attributes, bool $js = false): string { $atts = ''; - if ($attributes === '' || $attributes === [] || $attributes === null) { + if (in_array($attributes, ['', [], null], true)) { return $atts; } diff --git a/system/Database/Database.php b/system/Database/Database.php index 36a22862cdd4..5582e4022db5 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 (in_array($dsn, [0, '', '0', [], false, null], true)) { throw new InvalidArgumentException('Your DSN connection string is invalid.'); } diff --git a/system/Validation/FormatRules.php b/system/Validation/FormatRules.php index af075a31e713..e28ef97706f3 100644 --- a/system/Validation/FormatRules.php +++ b/system/Validation/FormatRules.php @@ -422,7 +422,7 @@ public function valid_url($str = null): bool */ public function valid_url_strict($str = null, ?string $validSchemes = null): bool { - if ($str === null || $str === '' || $str === '0') { + if (in_array($str, [null, '', '0'], true)) { return false; } diff --git a/system/View/Cell.php b/system/View/Cell.php index 8325accc7223..ccf24cbca210 100644 --- a/system/View/Cell.php +++ b/system/View/Cell.php @@ -125,7 +125,7 @@ public function render(string $library, $params = null, int $ttl = 0, ?string $c public function prepareParams($params) { if ( - ($params === null || $params === '' || $params === []) + in_array($params, [null, '', []], true) || (! is_string($params) && ! is_array($params)) ) { return []; diff --git a/tests/system/Models/UpdateModelTest.php b/tests/system/Models/UpdateModelTest.php index 2f01bb6a13f8..9e68a659cf1c 100644 --- a/tests/system/Models/UpdateModelTest.php +++ b/tests/system/Models/UpdateModelTest.php @@ -432,10 +432,7 @@ public function testUpdateSetEntity(): void public function testUpdateEntityWithPrimaryKeyCast(): void { if ( - $this->db->DBDriver === 'OCI8' - || $this->db->DBDriver === 'Postgre' - || $this->db->DBDriver === 'SQLSRV' - || $this->db->DBDriver === 'SQLite3' + in_array($this->db->DBDriver, ['OCI8', 'Postgre', 'SQLSRV', 'SQLite3'], true) ) { $this->markTestSkipped($this->db->DBDriver . ' does not work with binary data as string data.'); } @@ -464,10 +461,7 @@ public function testUpdateEntityWithPrimaryKeyCast(): void public function testUpdateBatchEntityWithPrimaryKeyCast(): void { if ( - $this->db->DBDriver === 'OCI8' - || $this->db->DBDriver === 'Postgre' - || $this->db->DBDriver === 'SQLSRV' - || $this->db->DBDriver === 'SQLite3' + in_array($this->db->DBDriver, ['OCI8', 'Postgre', 'SQLSRV', 'SQLite3'], true) ) { $this->markTestSkipped($this->db->DBDriver . ' does not work with binary data as string data.'); }