diff --git a/docs/en/reference/annotations-reference.rst b/docs/en/reference/annotations-reference.rst index b55b1ab5da..8e16b83abf 100644 --- a/docs/en/reference/annotations-reference.rst +++ b/docs/en/reference/annotations-reference.rst @@ -726,53 +726,6 @@ via the :ref:`strategy ` attribute. protected $id; } -@Increment ----------- - -The increment type is just like an integer field, except that it will be updated -using the ``$inc`` operator instead of ``$set``: - -.. code-block:: php - - downloads++; - } - - // ... - } - -Now, update a Package instance like so: - -.. code-block:: php - - incrementDownloads(); - $dm->flush(); - -The query sent to Mongo would resemble the following: - -.. code-block:: json - - { "$inc": { "downloads": 1 } } - -The field will be incremented by the difference between the new and old values. -This is useful if many requests are attempting to update the field concurrently. - -.. note:: - - This annotation is deprecated and will be removed in ODM 2.0. Please use the - `@Field`_ annotation with type "int" or "float" and use the "increment" - strategy. - @Index ------ diff --git a/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataInfo.php index d7924910b7..675bd1decc 100644 --- a/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataInfo.php @@ -1264,9 +1264,6 @@ public function mapField(array $mapping) if (isset($mapping['type']) && $mapping['type'] === 'file') { $mapping['file'] = true; } - if (isset($mapping['type']) && $mapping['type'] === 'increment') { - $mapping['strategy'] = self::STORAGE_STRATEGY_INCREMENT; - } if (isset($mapping['file']) && $mapping['file'] === true) { $this->file = $mapping['fieldName']; $mapping['name'] = 'file'; @@ -1399,7 +1396,6 @@ private function applyStorageStrategy(array &$mapping) switch (true) { case $mapping['type'] == 'int': case $mapping['type'] == 'float': - case $mapping['type'] == 'increment': $defaultStrategy = self::STORAGE_STRATEGY_SET; $allowedStrategies = [self::STORAGE_STRATEGY_SET, self::STORAGE_STRATEGY_INCREMENT]; break; diff --git a/lib/Doctrine/ODM/MongoDB/Types/IncrementType.php b/lib/Doctrine/ODM/MongoDB/Types/IncrementType.php deleted file mode 100644 index 8c5d8d53f9..0000000000 --- a/lib/Doctrine/ODM/MongoDB/Types/IncrementType.php +++ /dev/null @@ -1,49 +0,0 @@ -. - */ - -namespace Doctrine\ODM\MongoDB\Types; - -/** - * The Increment type. - * - * @since 1.0 - * @deprecated This type will be removed in ODM 2.0. Please use int or float instead - */ -class IncrementType extends Type -{ - public function convertToDatabaseValue($value) - { - return $value !== null ? (is_float($value) ? (float) $value : (int) $value) : null; - } - - public function convertToPHPValue($value) - { - return $value !== null ? (is_float($value) ? (float) $value : (int) $value) : null; - } - - public function closureToMongo() - { - return '$return = is_float($value) ? (float) $value : (int) $value;'; - } - - public function closureToPHP() - { - return '$return = is_float($value) ? (float) $value : (int) $value;'; - } -} diff --git a/lib/Doctrine/ODM/MongoDB/Types/Type.php b/lib/Doctrine/ODM/MongoDB/Types/Type.php index c7f2ff8991..2a945cd1a6 100644 --- a/lib/Doctrine/ODM/MongoDB/Types/Type.php +++ b/lib/Doctrine/ODM/MongoDB/Types/Type.php @@ -51,7 +51,6 @@ abstract class Type const FILE = 'file'; const HASH = 'hash'; const COLLECTION = 'collection'; - const INCREMENT = 'increment'; const OBJECTID = 'object_id'; const RAW = 'raw'; @@ -82,7 +81,6 @@ abstract class Type self::FILE => Types\FileType::class, self::HASH => Types\HashType::class, self::COLLECTION => Types\CollectionType::class, - self::INCREMENT => Types\IncrementType::class, self::OBJECTID => Types\ObjectIdType::class, self::RAW => Types\RawType::class, ); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataInfoTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataInfoTest.php index 2783bdc5d7..afed8e7fb8 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataInfoTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataInfoTest.php @@ -361,18 +361,6 @@ public function testReferenceManySortMustNotBeUsedWithNonSetCollectionStrategy() )); } - public function testIncrementTypeAutomaticallyAssumesIncrementStrategy() - { - $cm = new ClassMetadataInfo('stdClass'); - $cm->mapField([ - 'fieldName' => 'incrementField', - 'type' => 'increment', - ]); - - $mapping = $cm->fieldMappings['incrementField']; - $this->assertSame(ClassMetadataInfo::STORAGE_STRATEGY_INCREMENT, $mapping['strategy']); - } - public function testSetShardKeyForClassWithoutInheritance() { $cm = new ClassMetadataInfo('stdClass'); diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Types/TypeTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Types/TypeTest.php index 04c20e9822..c202d1beeb 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Types/TypeTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Types/TypeTest.php @@ -42,8 +42,6 @@ public function provideTypes() array(Type::getType(Type::FILE), new GridFSFile()), array(Type::getType(Type::HASH), array('foo' => 'bar')), array(Type::getType(Type::COLLECTION), array('foo', 'bar')), - array(Type::getType(Type::INCREMENT), 1), - array(Type::getType(Type::INCREMENT), 1.1), array(Type::getType(Type::OBJECTID), "507f1f77bcf86cd799439011"), array(Type::getType(Type::RAW), (object) array('foo' => 'bar')), );