浏览代码

[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) {