Pārlūkot izejas kodu

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 gadi atpakaļ
vecāks
revīzija
c6a8a8070c
1 mainītis faili ar 1 papildinājumiem un 6 dzēšanām
  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)
     {
-        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());
     }
 
     /**