Skip to content

Commit 257a0a2

Browse files
authored
Symfony 8.0 support (#2791)
* Symfony 8.0 support * Use symfony/flex for version constraint in CI
1 parent 2f1298c commit 257a0a2

18 files changed

+114
-51
lines changed

.github/workflows/atlas-ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ jobs:
1818
symfony:
1919
- "stable"
2020
proxy:
21-
- "lazy-ghost"
21+
- "native"
2222
include:
23+
# Test with LazyGhostObject
24+
- php-version: "8.2"
25+
symfony: "7.4"
26+
proxy: "lazy-ghost"
27+
os: "ubuntu-latest"
2328
# Test with ProxyManager
2429
- php-version: "8.1"
2530
symfony: "6.4"

.github/workflows/continuous-integration.yml

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
dependencies:
3535
- "highest"
3636
symfony-version:
37-
- "stable"
37+
- "locked"
3838
proxy:
3939
- "lazy-ghost"
4040
include:
@@ -44,7 +44,7 @@ jobs:
4444
mongodb-version: "6.0"
4545
driver-version: "1.21.0"
4646
topology: "server"
47-
symfony-version: "stable"
47+
symfony-version: "locked"
4848
proxy: "lazy-ghost"
4949
# Test with Symfony 6.4
5050
- topology: "server"
@@ -60,46 +60,62 @@ jobs:
6060
mongodb-version: "6.0"
6161
driver-version: "stable"
6262
dependencies: "highest"
63-
symfony-version: "stable"
63+
symfony-version: "locked"
6464
proxy: "lazy-ghost"
6565
# Test with a 8.0 replica set
6666
- topology: "replica_set"
6767
php-version: "8.2"
6868
mongodb-version: "8.0"
6969
driver-version: "stable"
7070
dependencies: "highest"
71-
symfony-version: "stable"
71+
symfony-version: "locked"
7272
proxy: "lazy-ghost"
7373
# Test with ProxyManager
7474
- php-version: "8.2"
7575
mongodb-version: "6.0"
7676
driver-version: "stable"
7777
dependencies: "highest"
78-
symfony-version: "stable"
78+
symfony-version: "locked"
7979
proxy: "proxy-manager"
8080
# Test with Native Lazy Objects
8181
- php-version: "8.4"
8282
mongodb-version: "8.0"
8383
driver-version: "stable"
8484
dependencies: "highest"
85-
symfony-version: "stable"
85+
symfony-version: "locked"
8686
proxy: "native"
8787
# Test with extension 1.21
8888
- topology: "server"
8989
php-version: "8.2"
9090
mongodb-version: "8.0"
9191
driver-version: "1.21.0"
9292
dependencies: "highest"
93-
symfony-version: "stable"
93+
symfony-version: "locked"
94+
proxy: "lazy-ghost"
95+
# Test with Symfony 7.4 LTS
96+
- topology: "server"
97+
php-version: "8.2"
98+
mongodb-version: "8.0"
99+
driver-version: "stable"
100+
dependencies: "highest"
101+
symfony-version: "7.4"
94102
proxy: "lazy-ghost"
103+
# Test with Symfony 8
104+
- topology: "server"
105+
php-version: "8.4"
106+
mongodb-version: "8.0"
107+
driver-version: "stable"
108+
dependencies: "highest"
109+
symfony-version: false
110+
proxy: "native"
95111
# Test with a sharded cluster
96112
# Currently disabled due to a bug where MongoDB reports "sharding status unknown"
97113
# - topology: "sharded_cluster"
98114
# php-version: "8.2"
99115
# mongodb-version: "6.0"
100116
# driver-version: "stable"
101117
# dependencies: "highest"
102-
# symfony-version: "stable"
118+
# symfony-version: "locked"
103119
# proxy: "lazy-ghost"
104120

105121
steps:
@@ -127,32 +143,24 @@ jobs:
127143
uses: "shivammathur/setup-php@v2"
128144
with:
129145
php-version: "${{ matrix.php-version }}"
130-
tools: "pecl"
131146
extensions: "mongodb-${{ matrix.driver-version }}, bcmath"
132147
coverage: "none"
133148
ini-values: "zend.assertions=1"
134149

135150
- name: "Show driver information"
136151
run: "php --ri mongodb"
137152

138-
# Not used, skip transient dependencies
153+
# Not used for tests, skip transient dependencies
139154
- name: "Remove phpbench/phpbench"
140155
run: composer remove --no-update --dev phpbench/phpbench
141156

142-
- name: "Configure Symfony ${{ matrix.symfony-version }}"
143-
if: "${{ matrix.symfony-version != 'stable' }}"
144-
run: |
145-
composer config minimum-stability dev
146-
# update symfony deps
147-
composer require --no-update symfony/console:^${{ matrix.symfony-version }}
148-
composer require --no-update symfony/var-dumper:^${{ matrix.symfony-version }}
149-
composer require --no-update --dev symfony/cache:^${{ matrix.symfony-version }}
150-
151157
- name: "Install dependencies with Composer"
152158
uses: "ramsey/composer-install@v3"
153159
with:
154160
dependency-versions: "${{ matrix.dependencies }}"
155161
composer-options: "--prefer-dist"
162+
env:
163+
SYMFONY_REQUIRE: ${{ matrix.symfony-version }}
156164

157165
- name: "Install latest Python version"
158166
uses: actions/setup-python@v6

composer.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"mapping",
1212
"object"
1313
],
14+
"minimum-stability": "dev",
15+
"prefer-stable": true,
1416
"homepage": "https://www.doctrine-project.org/projects/mongodb-odm.html",
1517
"license": "MIT",
1618
"authors": [
@@ -35,10 +37,10 @@
3537
"jean85/pretty-package-versions": "^1.3.0 || ^2.0.1",
3638
"mongodb/mongodb": "^1.21.2 || ^2.1.1",
3739
"psr/cache": "^1.0 || ^2.0 || ^3.0",
38-
"symfony/console": "^5.4 || ^6.0 || ^7.0",
40+
"symfony/console": "^5.4 || ^6.4 || ^7.0 || ^8.0",
3941
"symfony/deprecation-contracts": "^2.2 || ^3.0",
40-
"symfony/var-dumper": "^5.4 || ^6.0 || ^7.0",
41-
"symfony/var-exporter": "^6.2 || ^7.0"
42+
"symfony/var-dumper": "^5.4 || ^6.4 || ^7.0 || ^8.0",
43+
"symfony/var-exporter": "^6.4 || ^7.0"
4244
},
4345
"require-dev": {
4446
"ext-bcmath": "*",
@@ -52,8 +54,8 @@
5254
"phpstan/phpstan-phpunit": "^2.0",
5355
"phpunit/phpunit": "^10.5.58",
5456
"squizlabs/php_codesniffer": "^4",
55-
"symfony/cache": "^5.4 || ^6.0 || ^7.0",
56-
"symfony/uid": "^5.4 || ^6.0 || ^7.0"
57+
"symfony/cache": "^5.4 || ^6.0 || ^7.0 || ^8.0",
58+
"symfony/uid": "^5.4 || ^6.0 || ^7.0 || ^8.0"
5759
},
5860
"conflict": {
5961
"doctrine/annotations": "<1.12 || >=3.0"

docs/en/reference/console-commands.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Console Commands
22
================
33

4-
Doctrine MongoDB ODM offers some console commands, which utilize Symfony2's
4+
Doctrine MongoDB ODM offers some console commands, which utilize Symfony's
55
Console component, to ease your development process:
66

77
- ``odm:clear-cache:metadata`` - Clear all metadata cache of the various cache drivers.

phpcs.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses">
6969
<exclude-pattern>src/Mapping/Driver/CompatibilityAnnotationDriver.php</exclude-pattern>
7070
<exclude-pattern>src/Tools/Console/Command/CommandCompatibility.php</exclude-pattern>
71+
<exclude-pattern>src/Tools/Console/Command/Schema/AbstractCommandCompatibility.php</exclude-pattern>
7172
<exclude-pattern>src/Tools/Console/Helper/DocumentManagerHelper.php</exclude-pattern>
7273
<exclude-pattern>tests/*</exclude-pattern>
7374
</rule>

src/Tools/Console/Command/ClearCache/MetadataCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ class MetadataCommand extends Command
2222
{
2323
use CommandCompatibility;
2424

25-
/** @return void */
26-
protected function configure()
25+
private function doConfigure(): void
2726
{
2827
$this
2928
->setName('odm:clear-cache:metadata')

src/Tools/Console/Command/CommandCompatibility.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,32 @@
99
use Symfony\Component\Console\Input\InputInterface;
1010
use Symfony\Component\Console\Output\OutputInterface;
1111

12-
if ((new ReflectionMethod(Command::class, 'execute'))->hasReturnType()) {
12+
// Symfony 8
13+
if ((new ReflectionMethod(Command::class, 'configure'))->hasReturnType()) {
1314
/** @internal */
1415
trait CommandCompatibility
1516
{
17+
protected function configure(): void
18+
{
19+
$this->doConfigure();
20+
}
21+
22+
protected function execute(InputInterface $input, OutputInterface $output): int
23+
{
24+
return $this->doExecute($input, $output);
25+
}
26+
}
27+
// Symfony 7
28+
} elseif ((new ReflectionMethod(Command::class, 'execute'))->hasReturnType()) {
29+
/** @internal */
30+
trait CommandCompatibility
31+
{
32+
/** @return void */
33+
protected function configure()
34+
{
35+
$this->doConfigure();
36+
}
37+
1638
protected function execute(InputInterface $input, OutputInterface $output): int
1739
{
1840
return $this->doExecute($input, $output);
@@ -22,6 +44,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
2244
/** @internal */
2345
trait CommandCompatibility
2446
{
47+
/** @return void */
48+
protected function configure()
49+
{
50+
$this->doConfigure();
51+
}
52+
2553
/**
2654
* {@inheritDoc}
2755
*

src/Tools/Console/Command/GenerateHydratorsCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ class GenerateHydratorsCommand extends Command
3131
{
3232
use CommandCompatibility;
3333

34-
/** @return void */
35-
protected function configure()
34+
private function doConfigure(): void
3635
{
3736
$this
3837
->setName('odm:generate:hydrators')

src/Tools/Console/Command/GeneratePersistentCollectionsCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ class GeneratePersistentCollectionsCommand extends Command
3131
{
3232
use CommandCompatibility;
3333

34-
/** @return void */
35-
protected function configure()
34+
private function doConfigure(): void
3635
{
3736
$this
3837
->setName('odm:generate:persistent-collections')

src/Tools/Console/Command/GenerateProxiesCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ class GenerateProxiesCommand extends Command
3535
{
3636
use CommandCompatibility;
3737

38-
/** @return void */
39-
protected function configure()
38+
private function doConfigure(): void
4039
{
4140
$this
4241
->setName('odm:generate:proxies')

0 commit comments

Comments
 (0)