Bladeren bron

[Form] added a missing check (the code calls isset() and unset() and so the data must implements ArrayAccess and Traversable)

Fabien Potencier 14 jaren geleden
bovenliggende
commit
b2efdcbad9
1 gewijzigde bestanden met toevoegingen van 6 en 6 verwijderingen
  1. 6 6
      src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php

+ 6 - 6
src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php

@@ -79,8 +79,8 @@ class ResizeFormListener implements EventSubscriberInterface
             $data = array();
         }
 
-        if (!is_array($data) && !$data instanceof \Traversable) {
-            throw new UnexpectedTypeException($data, 'array or \Traversable');
+        if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
+            throw new UnexpectedTypeException($data, 'array or \Traversable or \ArrayAccess');
         }
 
         // First remove all rows
@@ -105,8 +105,8 @@ class ResizeFormListener implements EventSubscriberInterface
             $data = array();
         }
 
-        if (!is_array($data) && !$data instanceof \Traversable) {
-            throw new UnexpectedTypeException($data, 'array or \Traversable');
+        if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
+            throw new UnexpectedTypeException($data, 'array or \Traversable or \ArrayAccess');
         }
 
         // Remove all empty rows
@@ -139,8 +139,8 @@ class ResizeFormListener implements EventSubscriberInterface
             $data = array();
         }
 
-        if (!is_array($data) && !$data instanceof \Traversable) {
-            throw new UnexpectedTypeException($data, 'array or \Traversable');
+        if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
+            throw new UnexpectedTypeException($data, 'array or \Traversable or \ArrayAccess');
         }
 
         if ($this->allowDelete) {