diff --git a/core/tests/Drupal/KernelTests/TestServiceProvider.php b/core/tests/Drupal/KernelTests/TestServiceProvider.php
index cc4944e224..24984bc465 100644
--- a/core/tests/Drupal/KernelTests/TestServiceProvider.php
+++ b/core/tests/Drupal/KernelTests/TestServiceProvider.php
@@ -8,7 +8,11 @@
 use Symfony\Component\DependencyInjection\Definition;
 
 /**
- * Provides special routing services for tests.
+ * Provides special services for tests.
+ *
+ * This provider will trigger a rebuild of the container for TestBase-based
+ * tests. It will trigger router.rebuild to rebuild the router for
+ * KernelTestBase-based tests through RouteProvider.
  */
 class TestServiceProvider implements ServiceProviderInterface, ServiceModifierInterface {
 
@@ -44,9 +48,9 @@ public static function addRouteProvider(ContainerBuilder $container) {
     $route_provider_service_name = 'router.route_provider';
     // While $container->get() does a recursive resolve, getDefinition() does
     // not, so do it ourselves.
-    // @todo Make the code more readable in
-    //   https://www.drupal.org/node/2911498.
-    for ($id = $route_provider_service_name; $container->hasAlias($id); $id = (string) $container->getAlias($id)) {
+    $id = $route_provider_service_name;
+    while ($container->hasAlias($id)) {
+      $id = (string) $container->getAlias($id);
     }
     $definition = $container->getDefinition($id);
     $definition->clearTag('needs_destruction');
