Skip to content

Commit 8c9b6ac

Browse files
feat: composer prefer-stable, doctrine/orm 3, doctrine/doctrine-bundle 3 (#353)
* feat: composer prefer-stable dev allow doctrine/orm 3, doctrine/annotations 2 and doctrine/doctrine-bundle 3 * feat: composer prefer-stable dev allow doctrine/orm 3, doctrine/annotations 2 and doctrine/doctrine-bundle 3 * feat: composer prefer-stable dev allow doctrine/orm 3, doctrine/annotations 2 and doctrine/doctrine-bundle 3 * feat: composer prefer-stable dev allow doctrine/orm 3, doctrine/annotations 2 and doctrine/doctrine-bundle 3 * feat: composer prefer-stable dev allow doctrine/orm 3, doctrine/annotations 2 and doctrine/doctrine-bundle 3 * feat: composer prefer-stable dev allow doctrine/orm 3, doctrine/annotations 2 and doctrine/doctrine-bundle 3 * feat: composer prefer-stable dev allow doctrine/orm 3, doctrine/annotations 2 and doctrine/doctrine-bundle 3 * feat: composer prefer-stable dev allow doctrine/orm 3, doctrine/annotations 2 and doctrine/doctrine-bundle 3 * feat: composer prefer-stable dev allow doctrine/orm 3, doctrine/annotations 2 and doctrine/doctrine-bundle 3 * feat: composer prefer-stable dev allow doctrine/orm 3, doctrine/annotations 2 and doctrine/doctrine-bundle 3 * feat: composer prefer-stable dev allow doctrine/orm 3, doctrine/annotations 2 and doctrine/doctrine-bundle 3 * Update doctrine/doctrine-bundle version constraint * Update doctrine/doctrine-bundle version requirement --------- Co-authored-by: Christopher Georg <[email protected]>
1 parent 8e5f8f8 commit 8c9b6ac

File tree

3 files changed

+30
-22
lines changed

3 files changed

+30
-22
lines changed

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"type": "symfony-bundle",
55
"license": "MIT",
66
"minimum-stability": "dev",
7+
"prefer-stable": true,
78
"require": {
89
"php": ">=8.1.10",
910
"symfony/config": "^5.4 | ^6.0 | ^7.0 | ^8.0",
@@ -12,11 +13,11 @@
1213
"symfony/http-kernel": "^5.4 | ^6.0 | ^7.0 | ^8.0"
1314
},
1415
"require-dev": {
15-
"doctrine/orm": "^2.13",
16+
"doctrine/orm": "^2.20 | ^3.0",
1617
"symfony/framework-bundle": "^5.4 | ^6.0 | ^7.0 | ^8.0",
1718
"symfony/phpunit-bridge": "^5.4 | ^6.0 | ^7.0 | ^8.0",
18-
"doctrine/doctrine-bundle": "^2.8",
19-
"doctrine/annotations": "^1.0",
19+
"doctrine/doctrine-bundle": "^2.13 | ^3.0",
20+
"doctrine/annotations": "^1.0 | ^2.0",
2021
"symfony/process": "^6.4 | ^7.0 | ^8.0",
2122
"symfonycasts/internal-test-helpers": "dev-main"
2223
},

phpstan-baseline.neon

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ parameters:
55
count: 1
66
path: src/Command/ResetPasswordRemoveExpiredCommand.php
77

8-
-
9-
message: "#^Method SymfonyCasts\\\\Bundle\\\\ResetPassword\\\\DependencyInjection\\\\Configuration\\:\\:getConfigTreeBuilder\\(\\) return type with generic class Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\TreeBuilder does not specify its types\\: T$#"
10-
count: 1
11-
path: src/DependencyInjection/Configuration.php
12-
138
-
149
message: "#^Property SymfonyCasts\\\\Bundle\\\\ResetPassword\\\\Exception\\\\TooManyPasswordRequestsException\\:\\:\\$availableAt has no type specified\\.$#"
1510
count: 1

tests/ResetPasswordTestKernel.php

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace SymfonyCasts\Bundle\ResetPassword\Tests;
1111

12+
use Composer\InstalledVersions;
1213
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
1314
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
1415
use Symfony\Component\Config\Loader\LoaderInterface;
@@ -80,24 +81,33 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
8081
]
8182
);
8283

84+
$orm = [
85+
'mappings' => [
86+
'App' => [
87+
'is_bundle' => false,
88+
'type' => self::shouldUseAttributes() ? 'attribute' : 'annotation',
89+
'dir' => 'tests/Fixtures/Entity/',
90+
'prefix' => 'SymfonyCasts\Bundle\ResetPassword\Tests\Fixtures\Entity',
91+
'alias' => 'App',
92+
],
93+
],
94+
];
95+
96+
// doctrine-bundle
97+
if (null !== $doctrineBundleVersion = InstalledVersions::getVersion('doctrine/doctrine-bundle')) {
98+
// v2
99+
if (version_compare($doctrineBundleVersion, '3.0.0', '<')) {
100+
$orm['auto_generate_proxy_classes'] = true;
101+
$orm['report_fields_where_declared'] = true;
102+
}
103+
}
104+
83105
$container->loadFromExtension('doctrine', [
84106
'dbal' => [
85107
'driver' => 'pdo_sqlite',
86108
'url' => 'sqlite:///'.$this->getCacheDir().'/app.db',
87109
],
88-
'orm' => [
89-
'auto_generate_proxy_classes' => true,
90-
'auto_mapping' => true,
91-
'mappings' => [
92-
'App' => [
93-
'is_bundle' => false,
94-
'type' => self::shouldUseAttributes() ? 'attribute' : 'annotation',
95-
'dir' => 'tests/Fixtures/Entity/',
96-
'prefix' => 'SymfonyCasts\Bundle\ResetPassword\Tests\Fixtures\Entity',
97-
'alias' => 'App',
98-
],
99-
],
100-
],
110+
'orm' => $orm,
101111
]);
102112

103113
$container->register(ResetPasswordTestFixtureRequestRepository::class)
@@ -144,6 +154,8 @@ public function getLogDir(): string
144154

145155
public static function shouldUseAttributes(): bool
146156
{
147-
return Kernel::VERSION_ID >= 70000;
157+
$ormVersion = InstalledVersions::getVersion('doctrine/orm');
158+
159+
return Kernel::VERSION_ID >= 70000 || version_compare($ormVersion, '3.0.0', '>=');
148160
}
149161
}

0 commit comments

Comments
 (0)