Skip to content

Commit 5e65a99

Browse files
committed
Symfony 8.0 support
1 parent 2150ce8 commit 5e65a99

18 files changed

+105
-33
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: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,22 @@ jobs:
9292
dependencies: "highest"
9393
symfony-version: "stable"
9494
proxy: "lazy-ghost"
95+
# Test with upcoming Symfony 7.4
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"
102+
proxy: "lazy-ghost"
103+
# Test with upcoming Symfony 8.0
104+
- topology: "server"
105+
php-version: "8.4"
106+
mongodb-version: "8.0"
107+
driver-version: "stable"
108+
dependencies: "highest"
109+
symfony-version: "8.0"
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"
@@ -127,7 +143,6 @@ 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"
@@ -147,6 +162,10 @@ jobs:
147162
composer require --no-update symfony/console:^${{ matrix.symfony-version }}
148163
composer require --no-update symfony/var-dumper:^${{ matrix.symfony-version }}
149164
composer require --no-update --dev symfony/cache:^${{ matrix.symfony-version }}
165+
if dpkg --compare-versions "${{ matrix.symfony-version }}" lt "8.0"; then
166+
# LazyGhostTrait was removed from symfony/var-exporter >= 8.0
167+
composer require --dev symfony/var-exporter:^${{ matrix.symfony-version }}
168+
fi
150169
151170
- name: "Install dependencies with Composer"
152171
uses: "ramsey/composer-install@v3"

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
"jean85/pretty-package-versions": "^1.3.0 || ^2.0.1",
3636
"mongodb/mongodb": "^1.21.2 || ^2.1.1",
3737
"psr/cache": "^1.0 || ^2.0 || ^3.0",
38-
"symfony/console": "^5.4 || ^6.0 || ^7.0",
38+
"symfony/console": "^5.4 || ^6.4 || ^7.0",
3939
"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"
40+
"symfony/var-dumper": "^5.4 || ^6.4 || ^7.0",
41+
"symfony/var-exporter": "^6.4 || ^7.0"
4242
},
4343
"require-dev": {
4444
"ext-bcmath": "*",
@@ -52,8 +52,8 @@
5252
"phpstan/phpstan-phpunit": "^2.0",
5353
"phpunit/phpunit": "^10.5.58",
5454
"squizlabs/php_codesniffer": "^4",
55-
"symfony/cache": "^5.4 || ^6.0 || ^7.0",
56-
"symfony/uid": "^5.4 || ^6.0 || ^7.0"
55+
"symfony/cache": "^5.4 || ^6.0 || ^7.0 || ^8.0",
56+
"symfony/uid": "^5.4 || ^6.0 || ^7.0 || ^8.0"
5757
},
5858
"conflict": {
5959
"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)