Skip to content

Commit 2e4e299

Browse files
authored
Merge pull request #611 from dmaicher/support_doctrine_bundle_3
Add support for `doctrine/doctrine-bundle` 3.0
2 parents 7e6165d + d889fc8 commit 2e4e299

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"homepage": "https://www.doctrine-project.org",
2626
"require": {
2727
"php": "^7.2 || ^8.0",
28-
"doctrine/doctrine-bundle": "^2.4",
28+
"doctrine/doctrine-bundle": "^2.4 || ^3.0",
2929
"doctrine/migrations": "^3.2",
3030
"symfony/deprecation-contracts": "^2.1 || ^3",
3131
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0"

src/EventListener/SchemaFilterListener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Doctrine\Bundle\MigrationsBundle\EventListener;
66

77
use Doctrine\DBAL\Schema\AbstractAsset;
8+
use Doctrine\DBAL\Schema\Name\OptionallyQualifiedName;
89
use Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand;
910
use Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand;
1011
use Symfony\Component\Console\Event\ConsoleCommandEvent;
@@ -27,7 +28,7 @@ public function __construct(string $configurationTableName)
2728
/** @var bool */
2829
private $enabled = false;
2930

30-
/** @param AbstractAsset|string $asset */
31+
/** @param AbstractAsset<OptionallyQualifiedName>|string $asset */
3132
public function __invoke($asset): bool
3233
{
3334
if (! $this->enabled) {

tests/DependencyInjection/DoctrineMigrationsExtensionTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@
3737
use Symfony\Component\VarExporter\LazyGhostTrait;
3838

3939
use function assert;
40+
use function class_exists;
4041
use function interface_exists;
4142
use function sys_get_temp_dir;
4243
use function trait_exists;
4344

45+
use const PHP_VERSION_ID;
46+
4447
class DoctrineMigrationsExtensionTest extends TestCase
4548
{
4649
use ExpectDeprecationTrait;
@@ -290,7 +293,8 @@ public function testPrefersEntityManagerOverConnection(): void
290293
$config = [
291294
'migrations_paths' => ['DoctrineMigrationsTest' => 'a'],
292295
];
293-
$ormConfig = trait_exists(LazyGhostTrait::class) ? ['enable_lazy_ghost_objects' => true] : [];
296+
$ormConfig = PHP_VERSION_ID < 80400 && trait_exists(LazyGhostTrait::class) && class_exists(CacheCompatibilityPass::class)
297+
? ['enable_lazy_ghost_objects' => true] : [];
294298
if (InstalledVersions::satisfies(new VersionParser(), 'doctrine/doctrine-bundle', '^2.7.1 ')) {
295299
$ormConfig['controller_resolver'] = ['auto_mapping' => false];
296300
}
@@ -363,7 +367,7 @@ public function testCustomEntityManager(): void
363367
$ormConfig['controller_resolver'] = ['auto_mapping' => false];
364368
}
365369

366-
if (trait_exists(LazyGhostTrait::class)) {
370+
if (PHP_VERSION_ID < 80400 && trait_exists(LazyGhostTrait::class) && class_exists(CacheCompatibilityPass::class)) {
367371
$ormConfig['enable_lazy_ghost_objects'] = true;
368372
}
369373

@@ -466,6 +470,7 @@ public function testTransactionalSetToFalseReflectsInConfig(): void
466470
private function getContainer(array $config, ?array $dbalConfig = null, ?array $ormConfig = null): ContainerBuilder
467471
{
468472
$container = $this->getContainerBuilder();
473+
$container->setParameter('kernel.build_dir', '');
469474

470475
$bundle = new DoctrineMigrationsBundle();
471476
$bundle->build($container);
@@ -488,7 +493,10 @@ private function getContainer(array $config, ?array $dbalConfig = null, ?array $
488493
$container->getDefinition('doctrine_migrations.schema_filter_listener')->setPublic(true);
489494
}
490495

491-
$container->addCompilerPass(new CacheCompatibilityPass());
496+
if (class_exists(CacheCompatibilityPass::class)) {
497+
/** @phpstan-ignore argument.type */
498+
$container->addCompilerPass(new CacheCompatibilityPass());
499+
}
492500

493501
return $container;
494502
}

0 commit comments

Comments
 (0)