Skip to content

Commit

Permalink
Merge pull request #2185 from malarzm/deprecate-int-id
Browse files Browse the repository at this point in the history
Favour int over int_id
  • Loading branch information
malarzm committed May 19, 2020
2 parents fd0107f + 7ad7a64 commit 5a59a8a
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
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 @@ -1897,7 +1897,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 @@ -1988,6 +1988,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

0 comments on commit 5a59a8a

Please sign in to comment.