From badf8fcc16e8545966a8c7ecf576020827e2ebf4 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 15 Dec 2014 09:12:18 +0100 Subject: [PATCH] [Form] Log deprecation of constants, fixes #12607 #12667 --- .../Component/Form/Deprecated/FormEvents.php | 28 ++++++++++++++++++ .../NumberToLocalizedStringTransformer.php | 29 +++++++++++++++++++ .../NumberToLocalizedStringTransformer.php | 7 +++-- src/Symfony/Component/Form/FormEvents.php | 8 +++-- 4 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 src/Symfony/Component/Form/Deprecated/FormEvents.php create mode 100644 src/Symfony/Component/Form/Deprecated/NumberToLocalizedStringTransformer.php diff --git a/src/Symfony/Component/Form/Deprecated/FormEvents.php b/src/Symfony/Component/Form/Deprecated/FormEvents.php new file mode 100644 index 0000000000..862879e75a --- /dev/null +++ b/src/Symfony/Component/Form/Deprecated/FormEvents.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Deprecated; + +trigger_error('Constants PRE_BIND, BIND and POST_BIND on class Symfony\Component\Form\FormEvents were deprecated in Symfony 2.3 and will be removed in 3.0. Use PRE_SUBMIT, SUBMIT and POST_SUBMIT instead.', E_USER_DEPRECATED); + +/** + * @deprecated since 2.7, to be removed in 3.0. + * @internal + */ +final class FormEvents +{ + const PRE_BIND = 'form.pre_bind'; + const BIND = 'form.bind'; + const POST_BIND = 'form.post_bind'; + + private function __construct() + { + } +} diff --git a/src/Symfony/Component/Form/Deprecated/NumberToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Deprecated/NumberToLocalizedStringTransformer.php new file mode 100644 index 0000000000..9b94c4e6cf --- /dev/null +++ b/src/Symfony/Component/Form/Deprecated/NumberToLocalizedStringTransformer.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Deprecated; + +trigger_error('Constants ROUND_HALFEVEN, ROUND_HALFUP and ROUND_HALFDOWN on class NumberToLocalizedStringTransformer were deprecated in Symfony 2.4 and will be removed in 3.0. Use ROUND_HALF_EVEN, ROUND_HALF_UP and ROUND_HALF_DOWN instead.', E_USER_DEPRECATED); + +/** + * @deprecated since 2.7, to be removed in 3.0. + * @internal + */ +final class NumberToLocalizedStringTransformer +{ + const ROUND_HALFEVEN = \NumberFormatter::ROUND_HALFEVEN; + const ROUND_HALFUP = \NumberFormatter::ROUND_HALFUP; + const ROUND_HALFDOWN = \NumberFormatter::ROUND_HALFDOWN; + + private function __construct() + { + } +} diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php index 92f9e63bb9..1d70af9148 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php @@ -13,6 +13,7 @@ namespace Symfony\Component\Form\Extension\Core\DataTransformer; use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\Exception\TransformationFailedException; +use Symfony\Component\Form\Deprecated\NumberToLocalizedStringTransformer as Deprecated; /** * Transforms between a number type and a localized number with grouping @@ -77,21 +78,21 @@ class NumberToLocalizedStringTransformer implements DataTransformerInterface * * @deprecated Deprecated as of Symfony 2.4, to be removed in Symfony 3.0. */ - const ROUND_HALFEVEN = self::ROUND_HALF_EVEN; + const ROUND_HALFEVEN = Deprecated::ROUND_HALFEVEN; /** * Alias for {@link self::ROUND_HALF_UP}. * * @deprecated Deprecated as of Symfony 2.4, to be removed in Symfony 3.0. */ - const ROUND_HALFUP = self::ROUND_HALF_UP; + const ROUND_HALFUP = Deprecated::ROUND_HALFUP; /** * Alias for {@link self::ROUND_HALF_DOWN}. * * @deprecated Deprecated as of Symfony 2.4, to be removed in Symfony 3.0. */ - const ROUND_HALFDOWN = self::ROUND_HALF_DOWN; + const ROUND_HALFDOWN = Deprecated::ROUND_HALFDOWN; protected $precision; diff --git a/src/Symfony/Component/Form/FormEvents.php b/src/Symfony/Component/Form/FormEvents.php index 54c72271c7..317472c8a0 100644 --- a/src/Symfony/Component/Form/FormEvents.php +++ b/src/Symfony/Component/Form/FormEvents.php @@ -10,6 +10,8 @@ namespace Symfony\Component\Form; +use Symfony\Component\Form\Deprecated\FormEvents as Deprecated; + /** * @author Bernhard Schussek */ @@ -77,7 +79,7 @@ final class FormEvents * * @Event */ - const PRE_BIND = 'form.pre_bind'; + const PRE_BIND = Deprecated::PRE_BIND; /** * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use @@ -85,7 +87,7 @@ final class FormEvents * * @Event */ - const BIND = 'form.bind'; + const BIND = Deprecated::BIND; /** * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use @@ -93,7 +95,7 @@ final class FormEvents * * @Event */ - const POST_BIND = 'form.post_bind'; + const POST_BIND = Deprecated::POST_BIND; private function __construct() {