Skip to content

Commit 0573a45

Browse files
committed
Symfony 8.0 support
1 parent 7abdc70 commit 0573a45

17 files changed

+98
-30
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ jobs:
8585
dependencies: "highest"
8686
symfony-version: "stable"
8787
proxy: "lazy-ghost"
88+
# Test with upcoming Symfony 7.4
89+
- topology: "server"
90+
php-version: "8.2"
91+
mongodb-version: "8.0"
92+
driver-version: "stable"
93+
dependencies: "highest"
94+
symfony-version: "7.4"
95+
proxy: "lazy-ghost"
96+
# Test with upcoming Symfony 8.0
97+
- topology: "server"
98+
php-version: "8.4"
99+
mongodb-version: "8.0"
100+
driver-version: "stable"
101+
dependencies: "highest"
102+
symfony-version: "8.0"
103+
proxy: "lazy-ghost"
88104
# Test with a sharded cluster
89105
# Currently disabled due to a bug where MongoDB reports "sharding status unknown"
90106
# - topology: "sharded_cluster"
@@ -140,6 +156,10 @@ jobs:
140156
composer require --no-update symfony/console:^${{ matrix.symfony-version }}
141157
composer require --no-update symfony/var-dumper:^${{ matrix.symfony-version }}
142158
composer require --no-update --dev symfony/cache:^${{ matrix.symfony-version }}
159+
if dpkg --compare-versions "${{ matrix.symfony-version }}" lt "8.0"; then
160+
# LazyGhostTrait was removed from symfony/var-exporter >= 8.0
161+
composer require --no-update --dev symfony/var-exporter:^${{ matrix.symfony-version }}
162+
fi
143163
144164
- name: "Install dependencies with Composer"
145165
uses: "ramsey/composer-install@v3"

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
"jean85/pretty-package-versions": "^1.3.0 || ^2.0.1",
3333
"mongodb/mongodb": "^1.21.2 || ^2.1.1",
3434
"psr/cache": "^1.0 || ^2.0 || ^3.0",
35-
"symfony/console": "^5.4 || ^6.0 || ^7.0",
35+
"symfony/console": "^5.4 || ^6.4 || ^7.0",
3636
"symfony/deprecation-contracts": "^2.2 || ^3.0",
37-
"symfony/var-dumper": "^5.4 || ^6.0 || ^7.0",
38-
"symfony/var-exporter": "^6.2 || ^7.0"
37+
"symfony/var-dumper": "^5.4 || ^6.4 || ^7.0",
38+
"symfony/var-exporter": "^6.4 || ^7.0"
3939
},
4040
"require-dev": {
4141
"ext-bcmath": "*",
@@ -49,7 +49,7 @@
4949
"phpstan/phpstan-phpunit": "^2.0",
5050
"phpunit/phpunit": "^10.4",
5151
"squizlabs/php_codesniffer": "^3.5",
52-
"symfony/cache": "^5.4 || ^6.0 || ^7.0"
52+
"symfony/cache": "^5.4 || ^6.4 || ^7.0"
5353
},
5454
"conflict": {
5555
"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.

lib/Doctrine/ODM/MongoDB/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')

lib/Doctrine/ODM/MongoDB/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
*

lib/Doctrine/ODM/MongoDB/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')

lib/Doctrine/ODM/MongoDB/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')

lib/Doctrine/ODM/MongoDB/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')

lib/Doctrine/ODM/MongoDB/Tools/Console/Command/QueryCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ class QueryCommand extends Command
2727
{
2828
use CommandCompatibility;
2929

30-
/** @return void */
31-
protected function configure()
30+
private function doConfigure(): void
3231
{
3332
$this
3433
->setName('odm:query')

lib/Doctrine/ODM/MongoDB/Tools/Console/Command/Schema/AbstractCommand.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@
1919

2020
abstract class AbstractCommand extends Command
2121
{
22+
use AbstractCommandCompatibility;
23+
2224
public const DB = 'db';
2325
public const COLLECTION = 'collection';
2426
public const INDEX = 'index';
2527
public const SEARCH_INDEX = 'search-index';
2628

27-
/** @return void */
28-
protected function configure()
29+
private function configureCommonOptions(): void
2930
{
30-
parent::configure();
31-
3231
$this
3332
->addOption('maxTimeMs', null, InputOption::VALUE_REQUIRED, 'An optional maxTimeMs that will be used for all schema operations.')
3433
->addOption('w', null, InputOption::VALUE_REQUIRED, 'An optional w option for the write concern that will be used for all schema operations.')

0 commit comments

Comments
 (0)