Skip to content

Favour bool and int over boolean and integer #2183

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

Merged
merged 1 commit into from
May 18, 2020

Conversation

malarzm
Copy link
Member

@malarzm malarzm commented May 17, 2020

Closes #2124

@malarzm malarzm added the Task label May 17, 2020
@malarzm malarzm added this to the 2.1.0 milestone May 17, 2020
@malarzm malarzm force-pushed the gh-2124 branch 2 times, most recently from 0cbb290 to f066733 Compare May 17, 2020 20:03
@malarzm malarzm requested a review from alcaeus May 17, 2020 20:29
Copy link
Member

@alcaeus alcaeus left a comment

Choose a reason for hiding this comment

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

Apart from the wording suggestion, the INTEGER and BOOLEAN constants in Doctrine\ODM\MongoDB\Types\Type should be deprecated as well.

UPGRADE-2.1.md Outdated
@@ -5,3 +5,5 @@ the `Doctrine\ODM\MongoDB\Id\IdGenerator` interface.

The `Doctrine\ODM\MongoDB\Mapping\ClassMetadata` class has been marked final. The class will no longer be extendable
in ODM 3.0.

`boolean` and `integer` types have been deprecated. Use their shorthand counterparts: `bool` and `int` respectively.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
`boolean` and `integer` types have been deprecated. Use their shorthand counterparts: `bool` and `int` respectively.
The `boolean` and `integer` mapping types have been deprecated. Use their shorthand counterparts: `bool` and `int` respectively.

@malarzm
Copy link
Member Author

malarzm commented May 18, 2020

@alcaeus also while I'm here there's also oddly looking \Doctrine\ODM\MongoDB\Types\IntIdType type registered under int_id. Do you recall anything special about it that couldn't be achieved with int? Shall I also deprecate it?

@malarzm malarzm requested a review from alcaeus May 18, 2020 18:32
Copy link
Member

@alcaeus alcaeus left a comment

Choose a reason for hiding this comment

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

One nit in the deprecation message I missed the first time around. Feel free to merge once it has been changed.

];
if (isset($deprecatedTypes[$mapping['type']])) {
@trigger_error(sprintf(
'"%s" type was deprecated in 2.1 and will be removed in 3.0. Use "%s" instead.',
Copy link
Member

Choose a reason for hiding this comment

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

Missed this the first time around: please provide the package name in the message:

Suggested change
'"%s" type was deprecated in 2.1 and will be removed in 3.0. Use "%s" instead.',
'"%s" type was deprecated in doctrine/mongodb-odm 2.1 and will be removed in 3.0. Use "%s" instead.',

Copy link
Member Author

Choose a reason for hiding this comment

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

Added in const as well 👍

@alcaeus
Copy link
Member

alcaeus commented May 18, 2020

I think deprecating it makes sense. The class itself provides no value, so deprecating it in favour of int (and using IntType in the mean time) makes sense. I decided to dig a bit and found that there's only one place where we actually use int_id:

$mapping['type'] = $this->generatorType === self::GENERATOR_TYPE_INCREMENT ? 'int_id' : 'custom_id';

I'm not sure why this uses int_id, but it may as well use int. That could easily be tested by changing it and seeing how much breaks. If that works, we can deprecate int_id entirely, just like we deprecate integer and boolean. Feel free to leave that to a separate PR since this is good to go.

@malarzm malarzm merged commit 33bd049 into doctrine:master May 18, 2020
@malarzm malarzm deleted the gh-2124 branch May 18, 2020 19:30
@malarzm malarzm mentioned this pull request May 18, 2020
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.

Deprecate integer and boolean types
2 participants