Skip to content

Commit 3de0efb

Browse files
author
Vincent Le Henaff
committed
Merge branch '2.3.x' into support-expr-in-queries
# Conflicts: # composer.json # lib/Doctrine/ODM/MongoDB/Persisters/PersistenceBuilder.php # lib/Doctrine/ODM/MongoDB/Query/Expr.php # phpstan-baseline.neon
2 parents 06a95f1 + 0947820 commit 3de0efb

File tree

554 files changed

+11781
-4679
lines changed

Some content is hidden

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

554 files changed

+11781
-4679
lines changed

.github/workflows/coding-standards.yml

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -10,52 +10,4 @@ on:
1010
jobs:
1111
coding-standards:
1212
name: "Coding Standards"
13-
runs-on: "ubuntu-20.04"
14-
15-
strategy:
16-
matrix:
17-
php-version:
18-
- "8.0"
19-
20-
steps:
21-
- name: "Checkout"
22-
uses: "actions/checkout@v2"
23-
24-
- name: Setup cache environment
25-
id: extcache
26-
uses: shivammathur/cache-extensions@v1
27-
with:
28-
php-version: ${{ matrix.php-version }}
29-
extensions: "mongodb-${{ matrix.driver-version }}, bcmath"
30-
key: "extcache-v1"
31-
32-
- name: Cache extensions
33-
uses: actions/cache@v2
34-
with:
35-
path: ${{ steps.extcache.outputs.dir }}
36-
key: ${{ steps.extcache.outputs.key }}
37-
restore-keys: ${{ steps.extcache.outputs.key }}
38-
39-
- name: "Install PHP"
40-
uses: "shivammathur/setup-php@v2"
41-
with:
42-
coverage: "none"
43-
extensions: "mongodb, bcmath"
44-
php-version: "${{ matrix.php-version }}"
45-
tools: "cs2pr"
46-
47-
- name: "Show driver information"
48-
run: "php --ri mongodb"
49-
50-
- name: "Install dependencies with Composer"
51-
uses: "ramsey/composer-install@v1"
52-
53-
- name: "Upload composer.lock as build artifact"
54-
uses: actions/upload-artifact@v2
55-
with:
56-
name: composer.lock
57-
path: composer.lock
58-
59-
# https://github.com/doctrine/.github/issues/3
60-
- name: "Run PHP_CodeSniffer"
61-
run: "vendor/bin/phpcs -q --no-colors --report=checkstyle | cs2pr"
13+
uses: "doctrine/.github/.github/workflows/[email protected]"

.github/workflows/continuous-integration.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ jobs:
2121
- "7.3"
2222
- "7.4"
2323
- "8.0"
24+
- "8.1"
2425
mongodb-version:
26+
- "5.0"
2527
- "4.4"
2628
- "4.2"
2729
- "4.0"
@@ -32,7 +34,7 @@ jobs:
3234
dependencies:
3335
- "highest"
3436
include:
35-
- deps: "lowest"
37+
- dependencies: "lowest"
3638
php-version: "7.2"
3739
mongodb-version: "3.6"
3840
driver-version: "1.5.0"
@@ -41,7 +43,7 @@ jobs:
4143
php-version: "8.0"
4244
mongodb-version: "4.4"
4345
driver-version: "stable"
44-
deps: "highest"
46+
dependencies: "highest"
4547

4648
steps:
4749
- name: "Checkout"
@@ -76,6 +78,15 @@ jobs:
7678
- name: "Show driver information"
7779
run: "php --ri mongodb"
7880

81+
# Remove this when laminas/laminas-code 4.5 is released
82+
- name: "Use dev stability"
83+
if: "${{ matrix.php-version == '8.1' }}"
84+
run: composer config minimum-stability dev
85+
86+
# This allows installing symfony/console 3.4 and 6
87+
- name: "Remove phpbench/phpbench"
88+
run: composer remove --no-update --dev phpbench/phpbench
89+
7990
- name: "Install dependencies with Composer"
8091
uses: "ramsey/composer-install@v1"
8192
with:

.github/workflows/release-on-milestone-closed.yml

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,9 @@ on:
88
jobs:
99
release:
1010
name: "Git tag, release & create merge-up PR"
11-
runs-on: "ubuntu-20.04"
12-
13-
steps:
14-
- name: "Checkout"
15-
uses: "actions/checkout@v2"
16-
17-
- name: "Release"
18-
uses: "laminas/automatic-releases@v1"
19-
with:
20-
command-name: "laminas:automatic-releases:release"
21-
env:
22-
"GITHUB_TOKEN": ${{ secrets.GITHUB_TOKEN }}
23-
"SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }}
24-
"GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }}
25-
"GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }}
26-
27-
- name: "Create Merge-Up Pull Request"
28-
uses: "laminas/automatic-releases@v1"
29-
with:
30-
command-name: "laminas:automatic-releases:create-merge-up-pull-request"
31-
env:
32-
"GITHUB_TOKEN": ${{ secrets.GITHUB_TOKEN }}
33-
"SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }}
34-
"GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }}
35-
"GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }}
36-
37-
# Uncomment this step if the repository uses a "next minor as default
38-
# branch" policy.
39-
#
40-
# - name: "Create and/or Switch to new Release Branch"
41-
# uses: "laminas/automatic-releases@v1"
42-
# with:
43-
# command-name: "laminas:automatic-releases:switch-default-branch-to-next-minor"
44-
# env:
45-
# "GITHUB_TOKEN": ${{ secrets.ORGANIZATION_ADMIN_TOKEN }}
46-
# "SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }}
47-
# "GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }}
48-
# "GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }}
49-
50-
- name: "Create new milestones"
51-
uses: "laminas/automatic-releases@v1"
52-
with:
53-
command-name: "laminas:automatic-releases:create-milestones"
54-
env:
55-
"GITHUB_TOKEN": ${{ secrets.GITHUB_TOKEN }}
56-
"SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }}
57-
"GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }}
58-
"GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }}
11+
uses: "doctrine/.github/.github/workflows/[email protected]"
12+
secrets:
13+
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
14+
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
15+
ORGANIZATION_ADMIN_TOKEN: ${{ secrets.ORGANIZATION_ADMIN_TOKEN }}
16+
SIGNING_SECRET_KEY: ${{ secrets.SIGNING_SECRET_KEY }}

.github/workflows/static-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
matrix:
1717
php-version:
18-
- "8.0"
18+
- "8.1"
1919

2020
steps:
2121
- name: "Checkout code"
@@ -65,7 +65,7 @@ jobs:
6565
strategy:
6666
matrix:
6767
php-version:
68-
- "8.0"
68+
- "8.1"
6969

7070
steps:
7171
- name: "Checkout code"

UPGRADE-2.3.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,23 @@ fetch metadata for the class and read the class using `$metadata->getName()`.
1212
The metadata layer is aware of these proxy namespace changes and how to resolve
1313
them, so users should always go through the metadata layer to retrieve mapped
1414
class names.
15+
16+
## Annotation Mapping
17+
18+
In order to make annotations usable as PHP 8 attributes, their classes no
19+
longer extend `Doctrine\Common\Annotations\Annotation` class and are now using
20+
`@NamedArgumentConstructor` which provides more type safety.
21+
This does not apply to `@Indexes` which is deprecated and can't be used as
22+
Attribute. Use `@Index` and `@UniqueIndex` instead.
23+
24+
`@Inheritance` annotation has been removed as it was never used.
25+
26+
## Deprecated: Document Namespace Aliases
27+
28+
Document namespace aliases are deprecated, use the magic ::class constant to abbreviate full class names
29+
in DocumentManager and DocumentRepository.
30+
31+
```diff
32+
- $documentManager->find('MyBundle:User', $id);
33+
+ $documentManager->find(User::class, $id);
34+
```

benchmark/BaseBench.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,12 @@ abstract class BaseBench
2828
/** @var DocumentManager */
2929
protected static $documentManager;
3030

31-
/**
32-
* @return DocumentManager
33-
*/
34-
protected function getDocumentManager()
31+
protected function getDocumentManager(): DocumentManager
3532
{
3633
return self::$documentManager;
3734
}
3835

39-
public function initDocumentManager()
36+
public function initDocumentManager(): void
4037
{
4138
$config = new Configuration();
4239

@@ -59,7 +56,7 @@ public function initDocumentManager()
5956
self::$documentManager = DocumentManager::create($client, $config);
6057
}
6158

62-
public function clearDatabase()
59+
public function clearDatabase(): void
6360
{
6461
// Check if the database exists. Calling listCollections on a non-existing
6562
// database in a sharded setup will cause an invalid command cursor to be
@@ -85,7 +82,7 @@ public function clearDatabase()
8582
}
8683
}
8784

88-
protected static function createMetadataDriverImpl()
85+
protected static function createMetadataDriverImpl(): AnnotationDriver
8986
{
9087
return AnnotationDriver::create(__DIR__ . '/../tests/Documents');
9188
}

benchmark/Document/HydrateDocumentBench.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class HydrateDocumentBench extends BaseBench
3535
/** @var HydratorInterface */
3636
private static $hydrator;
3737

38-
public function init()
38+
public function init(): void
3939
{
4040
self::$data = [
4141
'_id' => new ObjectId(),
@@ -83,39 +83,39 @@ public function init()
8383
/**
8484
* @Warmup(2)
8585
*/
86-
public function benchHydrateDocument()
86+
public function benchHydrateDocument(): void
8787
{
8888
self::$hydrator->hydrate(new User(), self::$data);
8989
}
9090

9191
/**
9292
* @Warmup(2)
9393
*/
94-
public function benchHydrateDocumentWithEmbedOne()
94+
public function benchHydrateDocumentWithEmbedOne(): void
9595
{
9696
self::$hydrator->hydrate(new User(), self::$data + self::$embedOneData);
9797
}
9898

9999
/**
100100
* @Warmup(2)
101101
*/
102-
public function benchHydrateDocumentWithEmbedMany()
102+
public function benchHydrateDocumentWithEmbedMany(): void
103103
{
104104
self::$hydrator->hydrate(new User(), self::$data + self::$embedManyData);
105105
}
106106

107107
/**
108108
* @Warmup(2)
109109
*/
110-
public function benchHydrateDocumentWithReferenceOne()
110+
public function benchHydrateDocumentWithReferenceOne(): void
111111
{
112112
self::$hydrator->hydrate(new User(), self::$data + self::$referenceOneData);
113113
}
114114

115115
/**
116116
* @Warmup(2)
117117
*/
118-
public function benchHydrateDocumentWithReferenceMany()
118+
public function benchHydrateDocumentWithReferenceMany(): void
119119
{
120120
self::$hydrator->hydrate(new User(), self::$data + self::$referenceManyData);
121121
}

benchmark/Document/LoadDocumentBench.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class LoadDocumentBench extends BaseBench
2525
/** @var ObjectId */
2626
private static $userId;
2727

28-
public function init()
28+
public function init(): void
2929
{
3030
self::$userId = new ObjectId();
3131

@@ -58,44 +58,44 @@ public function init()
5858
/**
5959
* @Warmup(2)
6060
*/
61-
public function benchLoadDocument()
61+
public function benchLoadDocument(): void
6262
{
6363
$this->loadDocument();
6464
}
6565

6666
/**
6767
* @Warmup(2)
6868
*/
69-
public function benchLoadEmbedOne()
69+
public function benchLoadEmbedOne(): void
7070
{
7171
$this->loadDocument()->getAddress()->getCity();
7272
}
7373

7474
/**
7575
* @Warmup(2)
7676
*/
77-
public function benchLoadEmbedMany()
77+
public function benchLoadEmbedMany(): void
7878
{
79-
$this->loadDocument()->getPhonenumbers()->forAll(static function ($key, Phonenumber $element) {
80-
return $element->getPhoneNumber();
79+
$this->loadDocument()->getPhonenumbers()->forAll(static function (int $key, Phonenumber $element) {
80+
return $element->getPhoneNumber() !== null;
8181
});
8282
}
8383

8484
/**
8585
* @Warmup(2)
8686
*/
87-
public function benchLoadReferenceOne()
87+
public function benchLoadReferenceOne(): void
8888
{
8989
$this->loadDocument()->getAccount()->getName();
9090
}
9191

9292
/**
9393
* @Warmup(2)
9494
*/
95-
public function benchLoadReferenceMany()
95+
public function benchLoadReferenceMany(): void
9696
{
97-
$this->loadDocument()->getGroups()->forAll(static function ($key, Group $group) {
98-
return $group->getName();
97+
$this->loadDocument()->getGroups()->forAll(static function (int $key, Group $group) {
98+
return $group->getName() !== null;
9999
});
100100
}
101101

benchmark/Document/StoreDocumentBench.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ final class StoreDocumentBench extends BaseBench
1818
/**
1919
* @Warmup(2)
2020
*/
21-
public function benchStoreDocument()
21+
public function benchStoreDocument(): void
2222
{
2323
$user = new User();
2424
$user->setUsername('alcaeus');
@@ -32,7 +32,7 @@ public function benchStoreDocument()
3232
/**
3333
* @Warmup(2)
3434
*/
35-
public function benchStoreDocumentWithEmbedOne()
35+
public function benchStoreDocumentWithEmbedOne(): void
3636
{
3737
$address = new Address();
3838
$address->setAddress('Redacted');
@@ -51,7 +51,7 @@ public function benchStoreDocumentWithEmbedOne()
5151
/**
5252
* @Warmup(2)
5353
*/
54-
public function benchStoreDocumentWithEmbedMany()
54+
public function benchStoreDocumentWithEmbedMany(): void
5555
{
5656
$user = new User();
5757
$user->setUsername('alcaeus');
@@ -67,7 +67,7 @@ public function benchStoreDocumentWithEmbedMany()
6767
/**
6868
* @Warmup(2)
6969
*/
70-
public function benchStoreDocumentWithReferenceOne()
70+
public function benchStoreDocumentWithReferenceOne(): void
7171
{
7272
$account = new Account();
7373
$account->setName('alcaeus');
@@ -85,7 +85,7 @@ public function benchStoreDocumentWithReferenceOne()
8585
/**
8686
* @Warmup(2)
8787
*/
88-
public function benchStoreDocumentWithReferenceMany()
88+
public function benchStoreDocumentWithReferenceMany(): void
8989
{
9090
$group1 = new Group('One');
9191
$group2 = new Group('Two');

0 commit comments

Comments
 (0)