From c53c1e59296559b072bc6e71381043410b1bc34c Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 6 Dec 2022 20:13:58 +0900 Subject: [PATCH 1/2] test: fix failed tests --- tests/system/Database/Live/TransactionTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/system/Database/Live/TransactionTest.php b/tests/system/Database/Live/TransactionTest.php index 7dff9eb74329..351acfe5f6a5 100644 --- a/tests/system/Database/Live/TransactionTest.php +++ b/tests/system/Database/Live/TransactionTest.php @@ -11,10 +11,10 @@ namespace CodeIgniter\Database\Live; +use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Config\Database; -use Exception; use Tests\Support\Database\Seeds\CITestSeeder; /** @@ -78,7 +78,7 @@ public function testTransStartDBDebugTrue() $builder->insert($jobData); $this->db->transComplete(); - } catch (Exception $e) { + } catch (DatabaseException $e) { // Do nothing. // MySQLi @@ -99,7 +99,7 @@ public function testTransStartDBDebugTrue() // ErrorException: oci_execute(): ORA-00001: unique constraint (ORACLE.pk_db_job) violated } - $this->assertInstanceOf(Exception::class, $e); + $this->assertInstanceOf(DatabaseException::class, $e); $this->dontSeeInDatabase('job', ['name' => 'Grocery Sales']); } From b40ddb58b27470ad8cb7f188690373fa3b783e98 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 6 Dec 2022 20:50:49 +0900 Subject: [PATCH 2/2] chore: remove @noRector --- rector.php | 6 ++++++ system/Debug/Exceptions.php | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/rector.php b/rector.php index 16ba9ca4fdb9..1a6648862a1d 100644 --- a/rector.php +++ b/rector.php @@ -29,6 +29,7 @@ use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector; use Rector\Config\RectorConfig; use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector; +use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector; use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector; use Rector\DeadCode\Rector\MethodCall\RemoveEmptyMethodCallRector; use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector; @@ -129,6 +130,11 @@ // buggy on union mixed type, new class extends SomeClass marked as object in union, and false replaced with bool in Union TypedPropertyFromAssignsRector::class, + + // rector mistakenly removes `@return true` + RemoveUselessReturnTagRector::class => [ + __DIR__ . '/system/Debug/Exceptions.php', + ], ]); // auto import fully qualified class names diff --git a/system/Debug/Exceptions.php b/system/Debug/Exceptions.php index 830bdaafa097..a79fa484a8c6 100644 --- a/system/Debug/Exceptions.php +++ b/system/Debug/Exceptions.php @@ -379,8 +379,6 @@ private function isDeprecationError(int $error): bool } /** - * @noRector \Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector - * * @return true */ private function handleDeprecationError(string $message, ?string $file = null, ?int $line = null): bool