Skip to content

[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

Closed
wants to merge 3 commits into from
Closed

Conversation

toin0u
Copy link
Contributor

@toin0u toin0u commented Nov 29, 2014

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets #12607
License MIT
Doc PR

This adds depreciation note for those ROUND_HALFEVEN, ROUND_HALFUP and ROUND_HALFDOWN constants.

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
);
Copy link
Member

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.

Copy link
Contributor Author

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 (
Copy link
Contributor

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?

Copy link
Contributor Author

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 ?

Copy link
Member

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.

Copy link
Member

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
Copy link
Member

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

Copy link
Contributor Author

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 ?

Copy link
Member

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?

Copy link
Contributor Author

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 ?

@stof
Copy link
Member

stof commented Dec 5, 2014

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;
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops! Thanks!

@stof
Copy link
Member

stof commented Dec 5, 2014

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

@toin0u
Copy link
Contributor Author

toin0u commented Dec 5, 2014

Mmm I see. How to solve this so ? Any idea ?

@fabpot fabpot added the Form label Dec 7, 2014
nicolas-grekas added a commit to nicolas-grekas/symfony that referenced this pull request Dec 15, 2014
@nicolas-grekas nicolas-grekas mentioned this pull request Dec 15, 2014
nicolas-grekas added a commit to nicolas-grekas/symfony that referenced this pull request Dec 15, 2014
@nicolas-grekas
Copy link
Member

Cherry-picked in #12968, thanks

@toin0u
Copy link
Contributor Author

toin0u commented Dec 15, 2014

👍

fabpot added a commit that referenced this pull request Dec 20, 2014
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants