From 6060b939cebce393d14fdda4d36509351462920a Mon Sep 17 00:00:00 2001 From: Mike Meier Date: Mon, 11 Apr 2016 14:55:49 +0200 Subject: [PATCH] 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. --- Util/FormBuilderIterator.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Util/FormBuilderIterator.php b/Util/FormBuilderIterator.php index c67d68aed3d..2742afde642 100644 --- a/Util/FormBuilderIterator.php +++ b/Util/FormBuilderIterator.php @@ -65,12 +65,7 @@ public function __construct(FormBuilderInterface $formBuilder, $prefix = false) */ 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()); } /**