Skip to content

Commit bf07d2e

Browse files
committed
Move attribute classes from Mapping\Annotations to Mapping\Attribute namespace
1 parent 7374131 commit bf07d2e

File tree

383 files changed

+689
-463
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

383 files changed

+689
-463
lines changed

UPGRADE-2.16.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# UPGRADE FROM 2.15 to 2.16
22

3+
## Attribute namespaces
4+
5+
Doctrine annotations are already deprecated in favor of PHP attributes. As of MongoDB ODM 2.16, the
6+
attribute namespaces have been changed from `Doctrine\ODM\MongoDB\Mapping\Annotations` to
7+
`Doctrine\ODM\MongoDB\Attributes`. The old annotation namespaces will continue to work for the time being, but
8+
they are deprecated and will be removed in 3.0.
9+
10+
```diff
11+
- use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
12+
+ use Doctrine\ODM\MongoDB\Attributes as ODM;
13+
14+
#[ODM\Document]
15+
class User
16+
{
17+
#[ODM\Id]
18+
private string $id;
19+
20+
#[ODM\Field]
21+
public string $name;
22+
}
23+
```
24+
325
## Lazy Proxy Directory
426

527
Using proxy classes with PHP 8.4+ is deprecated, only native lazy objects will

src/Mapping/Annotations/AbstractDocument.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Mapping/Annotations/Annotation.php

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Doctrine\ODM\MongoDB\Mapping\Attribute;
6+
7+
use function class_alias;
8+
9+
abstract class AbstractDocument implements Annotation
10+
{
11+
}
12+
13+
class_alias(AbstractDocument::class, \Doctrine\ODM\MongoDB\Mapping\Annotations\AbstractDocument::class);
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
declare(strict_types=1);
44

5-
namespace Doctrine\ODM\MongoDB\Mapping\Annotations;
5+
namespace Doctrine\ODM\MongoDB\Mapping\Attribute;
6+
7+
use function class_alias;
68

79
abstract class AbstractField implements Annotation
810
{
@@ -41,3 +43,5 @@ public function __construct(
4143
$this->notSaved = $notSaved;
4244
}
4345
}
46+
47+
class_alias(AbstractField::class, \Doctrine\ODM\MongoDB\Mapping\Annotations\AbstractField::class);
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
declare(strict_types=1);
44

5-
namespace Doctrine\ODM\MongoDB\Mapping\Annotations;
5+
namespace Doctrine\ODM\MongoDB\Mapping\Attribute;
6+
7+
use function class_alias;
68

79
abstract class AbstractIndex implements Annotation
810
{
@@ -57,3 +59,5 @@ public function __construct(
5759
$this->partialFilterExpression = $partialFilterExpression;
5860
}
5961
}
62+
63+
class_alias(AbstractIndex::class, \Doctrine\ODM\MongoDB\Mapping\Annotations\AbstractIndex::class);
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
declare(strict_types=1);
44

5-
namespace Doctrine\ODM\MongoDB\Mapping\Annotations;
5+
namespace Doctrine\ODM\MongoDB\Mapping\Attribute;
66

77
use Attribute;
88
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
99

10+
use function class_alias;
11+
1012
/**
1113
* Loads data from a different field if the original field is not set
1214
*
@@ -21,3 +23,5 @@ public function __construct(public $value, public ?string $name = null)
2123
{
2224
}
2325
}
26+
27+
class_alias(AlsoLoad::class, \Doctrine\ODM\MongoDB\Mapping\Annotations\AlsoLoad::class);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Doctrine\ODM\MongoDB\Mapping\Attribute;
6+
7+
use function class_alias;
8+
9+
interface Annotation
10+
{
11+
}
12+
13+
class_alias(Annotation::class, \Doctrine\ODM\MongoDB\Mapping\Annotations\Annotation::class);

src/Mapping/Annotations/ChangeTrackingPolicy.php renamed to src/Mapping/Attribute/ChangeTrackingPolicy.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
declare(strict_types=1);
44

5-
namespace Doctrine\ODM\MongoDB\Mapping\Annotations;
5+
namespace Doctrine\ODM\MongoDB\Mapping\Attribute;
66

77
use Attribute;
88
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
99

10+
use function class_alias;
11+
1012
/**
1113
* Specifies the change tracking policy for a document
1214
*
@@ -24,3 +26,5 @@ public function __construct(string $value)
2426
$this->value = $value;
2527
}
2628
}
29+
30+
class_alias(ChangeTrackingPolicy::class, \Doctrine\ODM\MongoDB\Mapping\Annotations\ChangeTrackingPolicy::class);

src/Mapping/Annotations/DefaultDiscriminatorValue.php renamed to src/Mapping/Attribute/DefaultDiscriminatorValue.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
declare(strict_types=1);
44

5-
namespace Doctrine\ODM\MongoDB\Mapping\Annotations;
5+
namespace Doctrine\ODM\MongoDB\Mapping\Attribute;
66

77
use Attribute;
88
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
99

10+
use function class_alias;
11+
1012
/**
1113
* Specifies a default discriminator value to be used when the discriminator
1214
* field is not set in a document
@@ -25,3 +27,5 @@ public function __construct(string $value)
2527
$this->value = $value;
2628
}
2729
}
30+
31+
class_alias(DefaultDiscriminatorValue::class, \Doctrine\ODM\MongoDB\Mapping\Annotations\DefaultDiscriminatorValue::class);

0 commit comments

Comments
 (0)