From 9d36d02846c2b396c0861e22fd97b140b01cfbcb Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Mon, 20 Sep 2021 11:50:20 +0100
Subject: [PATCH] Issue #3231682 by daffie, larowlan: [Symfony 6] Add
 "ConstraintViolationListInterface" type hint to
 Drupal\Core\TypedData\Validation\RecursiveValidator::validate(),
 ::validateProperty() and ::validatePropertyValue()

---
 .../Core/TypedData/Validation/RecursiveValidator.php       | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/core/lib/Drupal/Core/TypedData/Validation/RecursiveValidator.php b/core/lib/Drupal/Core/TypedData/Validation/RecursiveValidator.php
index e72dea2b7b05..f1ed53f6ecaf 100644
--- a/core/lib/Drupal/Core/TypedData/Validation/RecursiveValidator.php
+++ b/core/lib/Drupal/Core/TypedData/Validation/RecursiveValidator.php
@@ -5,6 +5,7 @@
 use Drupal\Core\TypedData\TypedDataInterface;
 use Drupal\Core\TypedData\TypedDataManagerInterface;
 use Symfony\Component\Validator\ConstraintValidatorFactoryInterface;
+use Symfony\Component\Validator\ConstraintViolationListInterface;
 use Symfony\Component\Validator\Context\ExecutionContextFactoryInterface;
 use Symfony\Component\Validator\Context\ExecutionContextInterface;
 use Symfony\Component\Validator\Mapping\MetadataInterface;
@@ -87,7 +88,7 @@ public function hasMetadataFor($value): bool {
   /**
    * {@inheritdoc}
    */
-  public function validate($value, $constraints = NULL, $groups = NULL) {
+  public function validate($value, $constraints = NULL, $groups = NULL): ConstraintViolationListInterface {
     return $this->startContext($value)
       ->validate($value, $constraints, $groups)
       ->getViolations();
@@ -96,7 +97,7 @@ public function validate($value, $constraints = NULL, $groups = NULL) {
   /**
    * {@inheritdoc}
    */
-  public function validateProperty($object, $propertyName, $groups = NULL) {
+  public function validateProperty($object, $propertyName, $groups = NULL): ConstraintViolationListInterface {
     return $this->startContext($object)
       ->validateProperty($object, $propertyName, $groups)
       ->getViolations();
@@ -105,7 +106,7 @@ public function validateProperty($object, $propertyName, $groups = NULL) {
   /**
    * {@inheritdoc}
    */
-  public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = NULL) {
+  public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = NULL): ConstraintViolationListInterface {
     // Just passing a class name is not supported.
     if (!is_object($objectOrClass)) {
       throw new \LogicException('Typed data validation does not support passing the class name only.');
-- 
GitLab