Преглед на файлове

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

Fabien Potencier преди 14 години
родител
ревизия
b2efdcbad9
променени са 1 файла, в които са добавени 6 реда и са изтрити 6 реда
  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) {