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 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']); }