From 46e609b2623dac338e4bcd115df909c9c4ced640 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 27 Sep 2020 06:23:37 +0200 Subject: [PATCH] Fix wrong merge --- .../Form/Extension/Core/Type/DateTimeType.php | 22 +++++------------- .../Form/Extension/Core/Type/DateType.php | 23 +++++-------------- 2 files changed, 12 insertions(+), 33 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php index c63afa6337..ec1e7fe387 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php @@ -26,7 +26,6 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; use Symfony\Component\Form\ReversedTransformer; use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; -use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -339,22 +338,13 @@ class DateTimeType extends AbstractType return $timeWidget; }); - foreach (['html5', 'format'] as $option) { - $resolver->setDeprecated($option, static function (Options $options, $value) use ($option): string { - try { - $html5 = 'html5' === $option ? $value : $options['html5']; - $format = 'format' === $option ? $value : $options['format']; - } catch (OptionDefinitionException $e) { - return ''; - } + $resolver->setNormalizer('html5', function (Options $options, $html5) { + if ($html5 && self::HTML5_FORMAT !== $options['format']) { + throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is enabled.', self::class)); + } - if ($html5 && self::HTML5_FORMAT !== $format) { - throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is disabled.', self::class)); - } - - return $html5; - }); - } + return $html5; + }); } /** diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php index e6cbe88ff0..f7a55ffe74 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php @@ -23,7 +23,6 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; use Symfony\Component\Form\ReversedTransformer; use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; -use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -324,23 +323,13 @@ class DateType extends AbstractType $resolver->setAllowedTypes('days', 'array'); $resolver->setAllowedTypes('input_format', 'string'); - foreach (['html5', 'widget', 'format'] as $option) { - $resolver->setDeprecated($option, static function (Options $options, $value) use ($option): string { - try { - $html5 = 'html5' === $option ? $value : $options['html5']; - $widget = 'widget' === $option ? $value : $options['widget']; - $format = 'format' === $option ? $value : $options['format']; - } catch (OptionDefinitionException $e) { - return ''; - } + $resolver->setNormalizer('html5', function (Options $options, $html5) { + if ($html5 && 'single_text' === $options['widget'] && self::HTML5_FORMAT !== $options['format']) { + throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is enabled.', self::class)); + } - if ($html5 && 'single_text' === $widget && self::HTML5_FORMAT !== $format) { - throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is disabled.', self::class)); - } - - return $html5; - }); - } + return $html5; + }); } /**