From fa26b4806585ebc166229e48eaee41aaf1bb47da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Jun 2023 15:57:05 +0000 Subject: [PATCH 1/4] build(deps-dev): update rector/rector requirement from 0.16.0 to 0.17.0 Updates the requirements on [rector/rector](https://github.com/rectorphp/rector) to permit the latest version. - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/0.16.0...0.17.0) --- updated-dependencies: - dependency-name: rector/rector dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 08af7d632a0f..49e50bfc7413 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "phpunit/phpcov": "^8.2", "phpunit/phpunit": "^9.1", "predis/predis": "^1.1 || ^2.0", - "rector/rector": "0.16.0", + "rector/rector": "0.17.0", "vimeo/psalm": "^5.0" }, "suggest": { From c988fd712e62bfe529be49d21f7a9b97357f6a84 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 2 Jun 2023 06:55:10 +0700 Subject: [PATCH 2/4] Remove ForToForeachRector and AddPregQuoteDelimiterRector and re-run rector --- rector.php | 4 ---- system/Common.php | 6 +----- system/Model.php | 6 +----- tests/system/Database/Live/ForgeTest.php | 3 +-- tests/system/HTTP/RedirectResponseTest.php | 2 +- tests/system/Language/LanguageTest.php | 2 +- 6 files changed, 5 insertions(+), 18 deletions(-) diff --git a/rector.php b/rector.php index d79d47cb3fee..6cb5a5c7e451 100644 --- a/rector.php +++ b/rector.php @@ -12,9 +12,7 @@ use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector; use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector; use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector; -use Rector\CodeQuality\Rector\For_\ForToForeachRector; use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector; -use Rector\CodeQuality\Rector\FuncCall\AddPregQuoteDelimiterRector; use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector; use Rector\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector; use Rector\CodeQuality\Rector\FuncCall\SimplifyStrposLowerRector; @@ -125,7 +123,6 @@ $rectorConfig->rule(RemoveAlwaysElseRector::class); $rectorConfig->rule(PassStrictParameterToFunctionParameterRector::class); $rectorConfig->rule(CountArrayToEmptyArrayComparisonRector::class); - $rectorConfig->rule(ForToForeachRector::class); $rectorConfig->rule(ChangeNestedForeachIfsToEarlyContinueRector::class); $rectorConfig->rule(ChangeIfElseValueAssignToEarlyReturnRector::class); $rectorConfig->rule(SimplifyStrposLowerRector::class); @@ -140,7 +137,6 @@ $rectorConfig->rule(UnnecessaryTernaryExpressionRector::class); $rectorConfig->rule(RemoveErrorSuppressInTryCatchStmtsRector::class); $rectorConfig->rule(RemoveVarTagFromClassConstantRector::class); - $rectorConfig->rule(AddPregQuoteDelimiterRector::class); $rectorConfig->rule(SimplifyRegexPatternRector::class); $rectorConfig->rule(FuncGetArgsToVariadicParamRector::class); $rectorConfig->rule(MakeInheritedMethodVisibilitySameAsParentRector::class); diff --git a/system/Common.php b/system/Common.php index 2a98253cb6b4..8d366973f14d 100644 --- a/system/Common.php +++ b/system/Common.php @@ -744,11 +744,7 @@ function is_windows(?bool $mock = null): bool $mocked = $mock; } - if (isset($mocked)) { - return $mocked; - } - - return DIRECTORY_SEPARATOR === '\\'; + return $mocked ?? DIRECTORY_SEPARATOR === '\\'; } } diff --git a/system/Model.php b/system/Model.php index 2df1bb2f5132..80e4bb48a34c 100644 --- a/system/Model.php +++ b/system/Model.php @@ -800,11 +800,7 @@ public function __get(string $name) return parent::__get($name); } - if (isset($this->builder()->{$name})) { - return $this->builder()->{$name}; - } - - return null; + return $this->builder()->{$name} ?? null; } /** diff --git a/tests/system/Database/Live/ForgeTest.php b/tests/system/Database/Live/ForgeTest.php index 54704a79e4c1..d6ee4ee31f88 100644 --- a/tests/system/Database/Live/ForgeTest.php +++ b/tests/system/Database/Live/ForgeTest.php @@ -1519,8 +1519,7 @@ public function testAddTextColumnWithConstraint() $this->assertTrue($this->db->fieldExists('text_with_constraint', 'user')); - // SQLSRV requires dropping default constraint before dropping column - $result = $this->forge->dropColumn('user', 'text_with_constraint'); + $this->forge->dropColumn('user', 'text_with_constraint'); $this->db->resetDataCache(); diff --git a/tests/system/HTTP/RedirectResponseTest.php b/tests/system/HTTP/RedirectResponseTest.php index 65fc0e62d03c..5f95b307d8cf 100644 --- a/tests/system/HTTP/RedirectResponseTest.php +++ b/tests/system/HTTP/RedirectResponseTest.php @@ -293,7 +293,7 @@ public function testWithHeadersWithEmptyHeaders() } $response = new RedirectResponse(new App()); - $response = $response->withHeaders(); + $response->withHeaders(); $this->assertEmpty($baseResponse->headers()); } diff --git a/tests/system/Language/LanguageTest.php b/tests/system/Language/LanguageTest.php index 4148a0f4a500..8006ad6cf133 100644 --- a/tests/system/Language/LanguageTest.php +++ b/tests/system/Language/LanguageTest.php @@ -179,7 +179,7 @@ public function testLanguageFileLoadingReturns() $this->assertNotContains('More', $this->lang->loaded()); $this->assertCount(3, $result); - $result = $this->lang->loadem('More', 'en'); + $this->lang->loadem('More', 'en'); $this->assertContains('More', $this->lang->loaded()); $this->assertCount(1, $this->lang->loaded()); } From 4900d7a92127a322594c9514092e82a99d3e7fe1 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 2 Jun 2023 06:58:13 +0700 Subject: [PATCH 3/4] rollback comment on removed on run rector --- tests/system/Database/Live/ForgeTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/system/Database/Live/ForgeTest.php b/tests/system/Database/Live/ForgeTest.php index d6ee4ee31f88..6dc792760ac4 100644 --- a/tests/system/Database/Live/ForgeTest.php +++ b/tests/system/Database/Live/ForgeTest.php @@ -1519,6 +1519,7 @@ public function testAddTextColumnWithConstraint() $this->assertTrue($this->db->fieldExists('text_with_constraint', 'user')); + // SQLSRV requires dropping default constraint before dropping column $this->forge->dropColumn('user', 'text_with_constraint'); $this->db->resetDataCache(); From a5958bd738289597d330996785609fe487bb03c2 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 2 Jun 2023 07:10:42 +0700 Subject: [PATCH 4/4] remove unused variable on ForgeTest --- tests/system/Database/Live/ForgeTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/Database/Live/ForgeTest.php b/tests/system/Database/Live/ForgeTest.php index 6dc792760ac4..90b42aec7de8 100644 --- a/tests/system/Database/Live/ForgeTest.php +++ b/tests/system/Database/Live/ForgeTest.php @@ -1513,7 +1513,7 @@ public function testDropKey() public function testAddTextColumnWithConstraint() { // some DBMS do not allow a constraint for type TEXT - $result = $this->forge->addColumn('user', [ + $this->forge->addColumn('user', [ 'text_with_constraint' => ['type' => 'text', 'constraint' => 255, 'default' => ''], ]);