From f6b1a1824c94c6b8ff78511b118a9a25f0356cda Mon Sep 17 00:00:00 2001
From: catch <6915-catch@users.noreply.drupalcode.org>
Date: Fri, 14 Mar 2025 19:59:38 +0000
Subject: [PATCH] Issue #3497677 by sandip poddar, longwave: Widen type for
 $violations in EntityConstraintViolationList constructor

---
 core/lib/Drupal/Core/Entity/ContentEntityBase.php           | 2 +-
 .../Drupal/Core/Entity/EntityConstraintViolationList.php    | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php
index b97bb5d5d1e2..ef5669e8184e 100644
--- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php
+++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php
@@ -516,7 +516,7 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) {
   public function validate() {
     $this->validated = TRUE;
     $violations = $this->getTypedData()->validate();
-    return new EntityConstraintViolationList($this, iterator_to_array($violations));
+    return new EntityConstraintViolationList($this, $violations);
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php b/core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php
index 2537c6bfd7c2..8b711537581c 100644
--- a/core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php
+++ b/core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php
@@ -44,10 +44,10 @@ class EntityConstraintViolationList extends ConstraintViolationList implements E
    *
    * @param \Drupal\Core\Entity\FieldableEntityInterface $entity
    *   The entity that has been validated.
-   * @param array $violations
-   *   The array of violations.
+   * @param iterable $violations
+   *   The set of violations.
    */
-  public function __construct(FieldableEntityInterface $entity, array $violations = []) {
+  public function __construct(FieldableEntityInterface $entity, iterable $violations = []) {
     parent::__construct($violations);
     $this->entity = $entity;
   }
-- 
GitLab