Skip to content

Favour int over int_id #2185

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 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions UPGRADE-2.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,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.

The `boolean` and `integer` mapping types have been deprecated. Use their shorthand counterparts: `bool` and `int`
respectively.
The `boolean`, `integer`, and `int_id` mapping types have been deprecated. Use their shorthand counterparts: `bool` and
`int` respectively. The `int_id` and `int` types are working exactly the same.
2 changes: 1 addition & 1 deletion lib/Doctrine/ODM/MongoDB/Id/AbstractIdGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Doctrine\ODM\MongoDB\Id;

/**
* @deprecated AbstractIdGenerator was deprecated in 2.1 and will be removed in 3.0. Implement IdGenerator interface instead.
* @deprecated AbstractIdGenerator was deprecated in doctrine/mongodb-odm 2.1 and will be removed in 3.0. Implement IdGenerator interface instead.
*/
abstract class AbstractIdGenerator implements IdGenerator
{
Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -1896,7 +1896,7 @@ public function mapField(array $mapping) : array
if (! empty($this->generatorOptions['type'])) {
$mapping['type'] = $this->generatorOptions['type'];
} elseif (empty($mapping['type'])) {
$mapping['type'] = $this->generatorType === self::GENERATOR_TYPE_INCREMENT ? 'int_id' : 'custom_id';
$mapping['type'] = $this->generatorType === self::GENERATOR_TYPE_INCREMENT ? Type::INT : Type::CUSTOMID;
}
}
unset($this->generatorOptions['type']);
Expand Down Expand Up @@ -1987,6 +1987,7 @@ public function mapField(array $mapping) : array
$deprecatedTypes = [
Type::BOOLEAN => Type::BOOL,
Type::INTEGER => Type::INT,
Type::INTID => Type::INT,
];
if (isset($deprecatedTypes[$mapping['type']])) {
@trigger_error(sprintf(
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/ODM/MongoDB/Types/IntIdType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

/**
* The Integer Id type.
*
* @deprecated IntIdType was deprecated in doctrine/mongodb-odm 2.1 and will be removed in 3.0. Use IntType instead.
*/
class IntIdType extends IntType
{
Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/ODM/MongoDB/Types/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
*/
abstract class Type
{
public const ID = 'id';
public const ID = 'id';
/** @deprecated const was deprecated in doctrine/mongodb-odm 2.1 and will be removed in 3.0. Use Type::INT instead */
public const INTID = 'int_id';
public const CUSTOMID = 'custom_id';
public const BOOL = 'bool';
Expand Down
4 changes: 2 additions & 2 deletions tests/Doctrine/ODM/MongoDB/Tests/UnitOfWorkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ class NotifyChangedDocument implements NotifyPropertyChanged
{
private $_listeners = [];

/** @ODM\Id(type="int_id", strategy="none") */
/** @ODM\Id(type="int", strategy="none") */
private $id;

/** @ODM\Field(type="string") */
Expand Down Expand Up @@ -611,7 +611,7 @@ protected function _onPropertyChanged($propName, $oldValue, $newValue)
/** @ODM\Document */
class NotifyChangedRelatedItem
{
/** @ODM\Id(type="int_id", strategy="none") */
/** @ODM\Id(type="int", strategy="none") */
private $id;

/** @ODM\ReferenceOne(targetDocument=NotifyChangedDocument::class) */
Expand Down