diff --git a/core/lib/Drupal/Core/TypedData/Validation/RecursiveValidator.php b/core/lib/Drupal/Core/TypedData/Validation/RecursiveValidator.php
index 4dded17145f84ff68713f56739397bca1bb3b4c2..e72dea2b7b05d2d5736c157d7d8c2dca976d8279 100644
--- a/core/lib/Drupal/Core/TypedData/Validation/RecursiveValidator.php
+++ b/core/lib/Drupal/Core/TypedData/Validation/RecursiveValidator.php
@@ -7,6 +7,7 @@
 use Symfony\Component\Validator\ConstraintValidatorFactoryInterface;
 use Symfony\Component\Validator\Context\ExecutionContextFactoryInterface;
 use Symfony\Component\Validator\Context\ExecutionContextInterface;
+use Symfony\Component\Validator\Mapping\MetadataInterface;
 use Symfony\Component\Validator\Validator\ContextualValidatorInterface;
 use Symfony\Component\Validator\Validator\ValidatorInterface;
 
@@ -69,7 +70,7 @@ public function inContext(ExecutionContextInterface $context): ContextualValidat
    * @param \Drupal\Core\TypedData\TypedDataInterface $typed_data
    *   A typed data object containing the value to validate.
    */
-  public function getMetadataFor($typed_data) {
+  public function getMetadataFor($typed_data): MetadataInterface {
     if (!$typed_data instanceof TypedDataInterface) {
       throw new \InvalidArgumentException('The passed value must be a typed data object.');
     }
@@ -79,7 +80,7 @@ public function getMetadataFor($typed_data) {
   /**
    * {@inheritdoc}
    */
-  public function hasMetadataFor($value) {
+  public function hasMetadataFor($value): bool {
     return $value instanceof TypedDataInterface;
   }