diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php
index 0ccee09bbe52126d3ed64a4d219f66177dfe7996..94ee7a7d8746a6a03605cabe88432b90b24d3705 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBase.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
@@ -27,6 +27,7 @@
 use Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait;
 use Drupal\TestTools\Extension\SchemaInspector;
 use Drupal\TestTools\TestVarDumper;
+use PHPUnit\Framework\Attributes\After;
 use PHPUnit\Framework\Exception;
 use PHPUnit\Framework\TestCase;
 use Prophecy\PhpUnit\ProphecyTrait;
@@ -697,10 +698,9 @@ protected function tearDown(): void {
   }
 
   /**
-   * @after
-   *
    * Additional tear down method to close the connection at the end.
    */
+  #[After]
   public function tearDownCloseDatabaseConnection() {
     // Destroy the database connection, which for example removes the memory
     // from sqlite in memory.
diff --git a/core/tests/Drupal/TestTools/Extension/RequiresComposerTrait.php b/core/tests/Drupal/TestTools/Extension/RequiresComposerTrait.php
index 39eb33dfcd34c0ad287b2514a08982ede2d468d1..8166cd9a05a5f31c32d7d9d5a1b8dc1a54c4d200 100644
--- a/core/tests/Drupal/TestTools/Extension/RequiresComposerTrait.php
+++ b/core/tests/Drupal/TestTools/Extension/RequiresComposerTrait.php
@@ -4,6 +4,7 @@
 
 namespace Drupal\TestTools\Extension;
 
+use PHPUnit\Framework\Attributes\BeforeClass;
 use Symfony\Component\Process\ExecutableFinder;
 
 /**
@@ -11,9 +12,7 @@
  */
 trait RequiresComposerTrait {
 
-  /**
-   * @beforeClass
-   */
+  #[BeforeClass]
   public static function requiresComposer(): void {
     if (!((new ExecutableFinder())->find('composer'))) {
       static::markTestSkipped('This test requires the Composer executable to be accessible.');