Skip to content

Commit 57fd658

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

File tree

385 files changed

+747
-470
lines changed

Some content is hidden

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

385 files changed

+747
-470
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\Attribute`. 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\Attribute 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

phpstan-baseline.neon

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,10 @@ parameters:
379379
path: src/Iterator/IterableResult.php
380380

381381
-
382-
message: '#^Method Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\SearchIndex\:\:__construct\(\) has parameter \$fields with no value type specified in iterable type array\.$#'
382+
message: '#^Method Doctrine\\ODM\\MongoDB\\Mapping\\Attribute\\SearchIndex\:\:__construct\(\) has parameter \$fields with no value type specified in iterable type array\.$#'
383383
identifier: missingType.iterableValue
384384
count: 1
385-
path: src/Mapping/Annotations/SearchIndex.php
385+
path: src/Mapping/Attribute/SearchIndex.php
386386

387387
-
388388
message: '#^Method Doctrine\\ODM\\MongoDB\\Mapping\\ClassMetadata\:\:addInheritedAssociationMapping\(\) has Doctrine\\ODM\\MongoDB\\Mapping\\MappingException in PHPDoc @throws tag but it''s not thrown\.$#'
@@ -469,7 +469,7 @@ parameters:
469469
path: src/Mapping/Driver/XmlDriver.php
470470

471471
-
472-
message: '#^Parameter \#2 \$mapping of method Doctrine\\ODM\\MongoDB\\Mapping\\Driver\\XmlDriver\:\:addFieldMapping\(\) expects array\{type\?\: string, fieldName\?\: string, name\?\: string, strategy\?\: string, association\?\: int, id\?\: bool, isOwningSide\?\: bool, collectionClass\?\: class\-string, \.\.\.\}, array\<string, array\<''contention''\|''max''\|''min''\|''precision''\|''queryType''\|''sparsity''\|''trimFactor''\|int\<0, max\>, Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\EncryptQuery\|float\|int\|MongoDB\\BSON\\Decimal128\|MongoDB\\BSON\\Int64\|MongoDB\\BSON\\UTCDateTime\|string\|null\>\|bool\|string\> given\.$#'
472+
message: '#^Parameter \#2 \$mapping of method Doctrine\\ODM\\MongoDB\\Mapping\\Driver\\XmlDriver\:\:addFieldMapping\(\) expects array\{type\?\: string, fieldName\?\: string, name\?\: string, strategy\?\: string, association\?\: int, id\?\: bool, isOwningSide\?\: bool, collectionClass\?\: class\-string, \.\.\.\}, array\<string, array\<''contention''\|''max''\|''min''\|''precision''\|''queryType''\|''sparsity''\|''trimFactor''\|int\<0, max\>, Doctrine\\ODM\\MongoDB\\Mapping\\Attribute\\EncryptQuery\|float\|int\|MongoDB\\BSON\\Decimal128\|MongoDB\\BSON\\Int64\|MongoDB\\BSON\\UTCDateTime\|string\|null\>\|bool\|string\> given\.$#'
473473
identifier: argument.type
474474
count: 1
475475
path: src/Mapping/Driver/XmlDriver.php
@@ -1057,13 +1057,13 @@ parameters:
10571057
path: tests/Tests/Functional/QueryableEncryptionTest.php
10581058

10591059
-
1060-
message: '#^Parameter \$discriminatorMap of attribute class Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\ReferenceOne constructor expects array\<string, class\-string\>\|null, array\<string, string\> given\.$#'
1060+
message: '#^Parameter \$discriminatorMap of attribute class Doctrine\\ODM\\MongoDB\\Mapping\\Attribute\\ReferenceOne constructor expects array\<string, class\-string\>\|null, array\<string, string\> given\.$#'
10611061
identifier: argument.type
10621062
count: 1
10631063
path: tests/Tests/Functional/TargetDocumentTest.php
10641064

10651065
-
1066-
message: '#^Parameter \$targetDocument of attribute class Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\ReferenceOne constructor expects class\-string\|null, string given\.$#'
1066+
message: '#^Parameter \$targetDocument of attribute class Doctrine\\ODM\\MongoDB\\Mapping\\Attribute\\ReferenceOne constructor expects class\-string\|null, string given\.$#'
10671067
identifier: argument.type
10681068
count: 1
10691069
path: tests/Tests/Functional/TargetDocumentTest.php

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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
// @phpstan-ignore class.notFound
14+
class_alias(AbstractDocument::class, \Doctrine\ODM\MongoDB\Mapping\Annotations\AbstractDocument::class);
Lines changed: 6 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,6 @@ public function __construct(
4143
$this->notSaved = $notSaved;
4244
}
4345
}
46+
47+
// @phpstan-ignore class.notFound
48+
class_alias(AbstractField::class, \Doctrine\ODM\MongoDB\Mapping\Annotations\AbstractField::class);
Lines changed: 6 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,6 @@ public function __construct(
5759
$this->partialFilterExpression = $partialFilterExpression;
5860
}
5961
}
62+
63+
// @phpstan-ignore class.notFound
64+
class_alias(AbstractIndex::class, \Doctrine\ODM\MongoDB\Mapping\Annotations\AbstractIndex::class);
Lines changed: 6 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,6 @@ public function __construct(public $value, public ?string $name = null)
2123
{
2224
}
2325
}
26+
27+
// @phpstan-ignore class.notFound
28+
class_alias(AlsoLoad::class, \Doctrine\ODM\MongoDB\Mapping\Annotations\AlsoLoad::class);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
// @phpstan-ignore class.notFound
14+
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: 6 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,6 @@ public function __construct(string $value)
2426
$this->value = $value;
2527
}
2628
}
29+
30+
// @phpstan-ignore class.notFound
31+
class_alias(ChangeTrackingPolicy::class, \Doctrine\ODM\MongoDB\Mapping\Annotations\ChangeTrackingPolicy::class);

0 commit comments

Comments
 (0)