Skip to content

Commit e74e5c1

Browse files
committed
Remove increment type
1 parent 3f195e5 commit e74e5c1

File tree

6 files changed

+0
-116
lines changed

6 files changed

+0
-116
lines changed

docs/en/reference/annotations-reference.rst

-47
Original file line numberDiff line numberDiff line change
@@ -726,53 +726,6 @@ via the :ref:`strategy <basic_mapping_identifiers>` attribute.
726726
protected $id;
727727
}
728728
729-
@Increment
730-
----------
731-
732-
The increment type is just like an integer field, except that it will be updated
733-
using the ``$inc`` operator instead of ``$set``:
734-
735-
.. code-block:: php
736-
737-
<?php
738-
739-
class Package
740-
{
741-
/** @Increment */
742-
private $downloads = 0;
743-
744-
public function incrementDownloads()
745-
{
746-
$this->downloads++;
747-
}
748-
749-
// ...
750-
}
751-
752-
Now, update a Package instance like so:
753-
754-
.. code-block:: php
755-
756-
<?php
757-
758-
$package->incrementDownloads();
759-
$dm->flush();
760-
761-
The query sent to Mongo would resemble the following:
762-
763-
.. code-block:: json
764-
765-
{ "$inc": { "downloads": 1 } }
766-
767-
The field will be incremented by the difference between the new and old values.
768-
This is useful if many requests are attempting to update the field concurrently.
769-
770-
.. note::
771-
772-
This annotation is deprecated and will be removed in ODM 2.0. Please use the
773-
`@Field`_ annotation with type "int" or "float" and use the "increment"
774-
strategy.
775-
776729
@Index
777730
------
778731

lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataInfo.php

-4
Original file line numberDiff line numberDiff line change
@@ -1264,9 +1264,6 @@ public function mapField(array $mapping)
12641264
if (isset($mapping['type']) && $mapping['type'] === 'file') {
12651265
$mapping['file'] = true;
12661266
}
1267-
if (isset($mapping['type']) && $mapping['type'] === 'increment') {
1268-
$mapping['strategy'] = self::STORAGE_STRATEGY_INCREMENT;
1269-
}
12701267
if (isset($mapping['file']) && $mapping['file'] === true) {
12711268
$this->file = $mapping['fieldName'];
12721269
$mapping['name'] = 'file';
@@ -1399,7 +1396,6 @@ private function applyStorageStrategy(array &$mapping)
13991396
switch (true) {
14001397
case $mapping['type'] == 'int':
14011398
case $mapping['type'] == 'float':
1402-
case $mapping['type'] == 'increment':
14031399
$defaultStrategy = self::STORAGE_STRATEGY_SET;
14041400
$allowedStrategies = [self::STORAGE_STRATEGY_SET, self::STORAGE_STRATEGY_INCREMENT];
14051401
break;

lib/Doctrine/ODM/MongoDB/Types/IncrementType.php

-49
This file was deleted.

lib/Doctrine/ODM/MongoDB/Types/Type.php

-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ abstract class Type
5151
const FILE = 'file';
5252
const HASH = 'hash';
5353
const COLLECTION = 'collection';
54-
const INCREMENT = 'increment';
5554
const OBJECTID = 'object_id';
5655
const RAW = 'raw';
5756

@@ -82,7 +81,6 @@ abstract class Type
8281
self::FILE => Types\FileType::class,
8382
self::HASH => Types\HashType::class,
8483
self::COLLECTION => Types\CollectionType::class,
85-
self::INCREMENT => Types\IncrementType::class,
8684
self::OBJECTID => Types\ObjectIdType::class,
8785
self::RAW => Types\RawType::class,
8886
);

tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataInfoTest.php

-12
Original file line numberDiff line numberDiff line change
@@ -361,18 +361,6 @@ public function testReferenceManySortMustNotBeUsedWithNonSetCollectionStrategy()
361361
));
362362
}
363363

364-
public function testIncrementTypeAutomaticallyAssumesIncrementStrategy()
365-
{
366-
$cm = new ClassMetadataInfo('stdClass');
367-
$cm->mapField([
368-
'fieldName' => 'incrementField',
369-
'type' => 'increment',
370-
]);
371-
372-
$mapping = $cm->fieldMappings['incrementField'];
373-
$this->assertSame(ClassMetadataInfo::STORAGE_STRATEGY_INCREMENT, $mapping['strategy']);
374-
}
375-
376364
public function testSetShardKeyForClassWithoutInheritance()
377365
{
378366
$cm = new ClassMetadataInfo('stdClass');

tests/Doctrine/ODM/MongoDB/Tests/Types/TypeTest.php

-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ public function provideTypes()
4242
array(Type::getType(Type::FILE), new GridFSFile()),
4343
array(Type::getType(Type::HASH), array('foo' => 'bar')),
4444
array(Type::getType(Type::COLLECTION), array('foo', 'bar')),
45-
array(Type::getType(Type::INCREMENT), 1),
46-
array(Type::getType(Type::INCREMENT), 1.1),
4745
array(Type::getType(Type::OBJECTID), "507f1f77bcf86cd799439011"),
4846
array(Type::getType(Type::RAW), (object) array('foo' => 'bar')),
4947
);

0 commit comments

Comments
 (0)