Browse Source

Improve FormBuilderIterator: Remove reflection

The property 'children' is not always accessible or even available because several implementations of other FormBuilders do not have this property.
Accessing private properties is never a good idea. Only rely on the given FormBuilderInterface.
Mike Meier 9 years ago
parent
commit
c6a8a8070c
1 changed files with 1 additions and 6 deletions
  1. 1 6
      Util/FormBuilderIterator.php

+ 1 - 6
Util/FormBuilderIterator.php

@@ -65,12 +65,7 @@ class FormBuilderIterator extends \RecursiveArrayIterator
      */
      */
     private static function getKeys(FormBuilderInterface $formBuilder)
     private static function getKeys(FormBuilderInterface $formBuilder)
     {
     {
-        if (!self::$reflection) {
-            self::$reflection = new \ReflectionProperty(get_class($formBuilder), 'children');
-            self::$reflection->setAccessible(true);
-        }
-
-        return array_keys(self::$reflection->getValue($formBuilder));
+        return array_keys($formBuilder->all());
     }
     }
 
 
     /**
     /**