From 35e41d9595f95ee3360eca0be684a700764b1902 Mon Sep 17 00:00:00 2001 From: Peter Rehm Date: Tue, 13 Jan 2015 21:58:30 +0100 Subject: [PATCH 1/2] Removed deprecated setDefaultOptions methods --- AbstractType.php | 11 ----------- AbstractTypeExtension.php | 11 ----------- FormTypeExtensionInterface.php | 11 ++++------- FormTypeInterface.php | 12 ++++-------- ResolvedFormType.php | 20 +++----------------- Tests/ResolvedFormTypeTest.php | 4 ++-- 6 files changed, 13 insertions(+), 56 deletions(-) diff --git a/AbstractType.php b/AbstractType.php index 08d6915344..e60fab0cf3 100644 --- a/AbstractType.php +++ b/AbstractType.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Form; use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; /** * @author Bernhard Schussek @@ -43,16 +42,6 @@ public function finishView(FormView $view, FormInterface $form, array $options) /** * {@inheritdoc} */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $this->configureOptions($resolver); - } - - /** - * Configures the options for this type. - * - * @param OptionsResolver $resolver The resolver for the options. - */ public function configureOptions(OptionsResolver $resolver) { } diff --git a/AbstractTypeExtension.php b/AbstractTypeExtension.php index 140fe5fdd6..9d369bf294 100644 --- a/AbstractTypeExtension.php +++ b/AbstractTypeExtension.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Form; use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; /** * @author Bernhard Schussek @@ -43,16 +42,6 @@ public function finishView(FormView $view, FormInterface $form, array $options) /** * {@inheritdoc} */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $this->configureOptions($resolver); - } - - /** - * Configures the options for this type. - * - * @param OptionsResolver $resolver The resolver for the options. - */ public function configureOptions(OptionsResolver $resolver) { } diff --git a/FormTypeExtensionInterface.php b/FormTypeExtensionInterface.php index 220eb6f4b0..deb87de79b 100644 --- a/FormTypeExtensionInterface.php +++ b/FormTypeExtensionInterface.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Form; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; /** * @author Bernhard Schussek @@ -60,15 +60,12 @@ public function buildView(FormView $view, FormInterface $form, array $options); public function finishView(FormView $view, FormInterface $form, array $options); /** - * Overrides the default options from the extended type. + * Configures the options for this type. * - * @param OptionsResolverInterface $resolver The resolver for the options. + * @param OptionsResolver $resolver The resolver for the options. * - * @deprecated Deprecated since Symfony 2.7, to be removed in Symfony 3.0. - * Use the method configureOptions instead. This method will be - * added to the FormTypeExtensionInterface with Symfony 3.0 */ - public function setDefaultOptions(OptionsResolverInterface $resolver); + public function configureOptions(OptionsResolver $resolver); /** * Returns the name of the type being extended. diff --git a/FormTypeInterface.php b/FormTypeInterface.php index fc0bb046cb..3f139aead7 100644 --- a/FormTypeInterface.php +++ b/FormTypeInterface.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Form; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; /** * @author Bernhard Schussek @@ -69,15 +69,11 @@ public function buildView(FormView $view, FormInterface $form, array $options); public function finishView(FormView $view, FormInterface $form, array $options); /** - * Sets the default options for this type. + * Configures the options for this type. * - * @param OptionsResolverInterface $resolver The resolver for the options. - * - * @deprecated Deprecated since Symfony 2.7, to be renamed in Symfony 3.0. - * Use the method configureOptions instead. This method will be - * added to the FormTypeInterface with Symfony 3.0. + * @param OptionsResolver $resolver The resolver for the options. */ - public function setDefaultOptions(OptionsResolverInterface $resolver); + public function configureOptions(OptionsResolver $resolver); /** * Returns the name of the parent type. diff --git a/ResolvedFormType.php b/ResolvedFormType.php index e3c897a981..ca832d90ce 100644 --- a/ResolvedFormType.php +++ b/ResolvedFormType.php @@ -192,7 +192,7 @@ public function finishView(FormView $view, FormInterface $form, array $options) /** * Returns the configured options resolver used for this type. * - * @return \Symfony\Component\OptionsResolver\OptionsResolverInterface The options resolver. + * @return \Symfony\Component\OptionsResolver\OptionsResolver The options resolver. */ public function getOptionsResolver() { @@ -203,24 +203,10 @@ public function getOptionsResolver() $this->optionsResolver = new OptionsResolver(); } - $this->innerType->setDefaultOptions($this->optionsResolver); - - $reflector = new \ReflectionMethod($this->innerType, 'setDefaultOptions'); - $isOverwritten = ($reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractType'); - - if (true === $isOverwritten) { - trigger_error('The FormTypeInterface::setDefaultOptions() method is deprecated since version 2.7 and will be removed in 3.0. Use configureOptions() instead. This method will be added to the FormTypeInterface with Symfony 3.0.', E_USER_DEPRECATED); - } + $this->innerType->configureOptions($this->optionsResolver); foreach ($this->typeExtensions as $extension) { - $extension->setDefaultOptions($this->optionsResolver); - - $reflector = new \ReflectionMethod($extension, 'setDefaultOptions'); - $isOverwritten = ($reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Form\AbstractTypeExtension'); - - if (true === $isOverwritten) { - trigger_error('The FormTypeExtensionInterface::setDefaultOptions() method is deprecated since version 2.7 and will be removed in 3.0. Use configureOptions() instead. This method will be added to the FormTypeExtensionInterface with Symfony 3.0.', E_USER_DEPRECATED); - } + $extension->configureOptions($this->optionsResolver); } } diff --git a/Tests/ResolvedFormTypeTest.php b/Tests/ResolvedFormTypeTest.php index e224cf31b0..01f9b6e5fb 100644 --- a/Tests/ResolvedFormTypeTest.php +++ b/Tests/ResolvedFormTypeTest.php @@ -99,7 +99,7 @@ public function testCreateBuilder() { $givenOptions = array('a' => 'a_custom', 'c' => 'c_custom'); $resolvedOptions = array('a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default'); - $optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolverInterface'); + $optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolver'); $this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType') ->setConstructorArgs(array($this->type, array($this->extension1, $this->extension2), $this->parentResolvedType)) @@ -127,7 +127,7 @@ public function testCreateBuilderWithDataClassOption() { $givenOptions = array('data_class' => 'Foo'); $resolvedOptions = array('data_class' => '\stdClass'); - $optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolverInterface'); + $optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolver'); $this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType') ->setConstructorArgs(array($this->type, array($this->extension1, $this->extension2), $this->parentResolvedType)) From d536e3e902b0f3e8122755445d190d983966d352 Mon Sep 17 00:00:00 2001 From: Peter Rehm Date: Tue, 20 Jan 2015 14:17:10 +0100 Subject: [PATCH 2/2] Remove the deprecated OptionsResolverInterface --- ResolvedFormTypeInterface.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ResolvedFormTypeInterface.php b/ResolvedFormTypeInterface.php index e6a61c753b..f8253e710c 100644 --- a/ResolvedFormTypeInterface.php +++ b/ResolvedFormTypeInterface.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Form; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; /** * A wrapper for a form type and its extensions. @@ -102,7 +102,7 @@ public function finishView(FormView $view, FormInterface $form, array $options); /** * Returns the configured options resolver used for this type. * - * @return OptionsResolverInterface The options resolver. + * @return OptionsResolver The options resolver. */ public function getOptionsResolver(); }