From fb7e4f1fedf745af1c086faec987c0734f68e24e Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 30 Jun 2024 18:17:12 +0700 Subject: [PATCH 1/2] refactor: Enable phpunit 10 attribute Rector rules --- rector.php | 12 ------------ system/Test/DatabaseTestTrait.php | 4 ++-- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/rector.php b/rector.php index df89a98bf808..f3f1f3f12bdc 100644 --- a/rector.php +++ b/rector.php @@ -42,14 +42,9 @@ use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector; use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; use Rector\Php70\Rector\FuncCall\RandomFunctionRector; -use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; use Rector\Php80\Rector\FunctionLike\MixedTypeRector; use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector; -use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\AnnotationWithValueToAttributeRector; -use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\CoversAnnotationWithValueToAttributeRector; -use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\DataProviderAnnotationToAttributeRector; -use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\DependsAnnotationWithValueToAttributeRector; use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector; use Rector\PHPUnit\Set\PHPUnitSetList; use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector; @@ -176,13 +171,6 @@ // Unnecessary (string) is inserted NullToStrictStringFuncCallArgRector::class, - - // PHPUnit 10 (requires PHP 8.1) features - DataProviderAnnotationToAttributeRector::class, - DependsAnnotationWithValueToAttributeRector::class, - AnnotationWithValueToAttributeRector::class, - AnnotationToAttributeRector::class, - CoversAnnotationWithValueToAttributeRector::class, ]) // auto import fully qualified class names ->withImportNames(removeUnusedImports: true) diff --git a/system/Test/DatabaseTestTrait.php b/system/Test/DatabaseTestTrait.php index 863ed542319d..27de14c39c60 100644 --- a/system/Test/DatabaseTestTrait.php +++ b/system/Test/DatabaseTestTrait.php @@ -13,6 +13,7 @@ namespace CodeIgniter\Test; +use PHPUnit\Framework\Attributes\AfterClass; use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Test\Constraints\SeeInDatabase; @@ -228,14 +229,13 @@ public function seed(string $name) // -------------------------------------------------------------------- // Utility // -------------------------------------------------------------------- - /** * Reset $doneMigration and $doneSeed * - * @afterClass * * @return void */ + #[AfterClass] public static function resetMigrationSeedCount() { self::$doneMigration = false; From 8ab9e40f04b35d64c697247e8a641f0d7252d019 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 30 Jun 2024 18:19:13 +0700 Subject: [PATCH 2/2] cs fix --- system/Test/DatabaseTestTrait.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/system/Test/DatabaseTestTrait.php b/system/Test/DatabaseTestTrait.php index 27de14c39c60..c0d4473c7b9e 100644 --- a/system/Test/DatabaseTestTrait.php +++ b/system/Test/DatabaseTestTrait.php @@ -13,13 +13,13 @@ namespace CodeIgniter\Test; -use PHPUnit\Framework\Attributes\AfterClass; use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Test\Constraints\SeeInDatabase; use Config\Database; use Config\Migrations; use Config\Services; +use PHPUnit\Framework\Attributes\AfterClass; /** * DatabaseTestTrait @@ -232,7 +232,6 @@ public function seed(string $name) /** * Reset $doneMigration and $doneSeed * - * * @return void */ #[AfterClass]