-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[Form] add deprecation log (#12607) #12667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
trigger_error( | ||
'The constants ROUND_HALFEVEN, ROUND_HALFUP and ROUND_HALFDOWN are deprecated since version 2.4 and will be removed in 3.0. Use ROUND_HALF_EVEN, ROUND_HALF_UP and ROUND_HALF_DOWN instead.', | ||
E_USER_DEPRECATED | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably only trigger when $roundingMode
is one of the deprecated constants.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes sure ! Will fix it now !
@@ -101,6 +101,17 @@ class NumberToLocalizedStringTransformer implements DataTransformerInterface | |||
|
|||
public function __construct($precision = null, $grouping = false, $roundingMode = self::ROUND_HALF_UP) | |||
{ | |||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe in_array($roudingMode, array(SELF::ROUND_HALFEVEN), true)
would be prettier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I though about that actually but I don't know. What do you think @xabbuh ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any preferences. Let's see what the core team think about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer saving a function call
if ( | ||
self::ROUND_HALFEVEN === $roundingMode | ||
|| self::ROUND_HALFUP === $roundingMode | ||
|| self::ROUND_HALFDOWN === $roundingMode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work. The deprecated constants have the same values than their replacements, so you cannot know whether the deprecated name or the uptodate name were used when passing the option. You will always trigger the deprecation warning here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also thought about that.. Do you have any idea to guide me ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have distinct values for deprecated constants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated this PR. I've used 7, 8 and 9 values. I don't know if it's a good idea. What do you think ?
Changing the value of constants is a BC break. So this cannot be done |
case self::ROUND_HALFUP: | ||
trigger_error('The constant ROUND_HALFUP is deprecated since version 2.4 and will be removed in 3.0. Use ROUND_HALF_UP instead.', E_USER_DEPRECATED); | ||
case null: | ||
$roundingMode = self::ROUND_HALF_UP; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the case of null
is already handled later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops! Thanks!
and if you try using the deprecated constants in form types using them for the configuration, you will see that it now rejects them because of your BC-breaking value change |
Mmm I see. How to solve this so ? Any idea ? |
Cherry-picked in #12968, thanks |
👍 |
…cmorales) This PR was merged into the 2.7 branch. Discussion ---------- Deprecations | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #12625, #12605, #12628, #12622, #12642, #12609, #12651, #12604, #12607, #12667, #12648 | License | MIT | Doc PR | - Cherry-picking some pending PRs to make them move forward Commits ------- badf8fc [Form] Log deprecation of constants, fixes #12607 #12667 1d58df4 Fix deprecation notice on VirtualFormAwareIterator e2a19ee Add a deprecation note about VirtualFormAwareIterator ab4d9b8 Add a deprecation note about CsrfProviderInterface cb70632 [HttpKernel] fix deprecation notice for Kernel::init() b5a315d [HttpKernel] Added deprecated error to init() 70012c1 [Hackday] [2.7] Add a deprecation note about TypeTestCase
This adds depreciation note for those
ROUND_HALFEVEN
,ROUND_HALFUP
andROUND_HALFDOWN
constants.