Skip to content

Commit

Permalink
Fix Container aware migration
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 committed Apr 26, 2024
1 parent 7addec2 commit f230478
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 1 addition & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ parameters:

excludePaths:
- tests/Fixture/ContainerAwareMigration
- tests/Factory/ContainerAwareVersionFactoryTest.php

ignoreErrors:
- '/Call to method setContainer\(\) on an unknown class Symfony\\Component\\DependencyInjection\\ContainerAwareInterface./'
- '/Class Symfony\\Component\\DependencyInjection\\ContainerAwareInterface not found./'
5 changes: 4 additions & 1 deletion src/Factory/ContainerAwareVersionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ public function createVersion(string $migrationClassName): AbstractMigration
{
$instance = $this->migrationFactory->createVersion($migrationClassName);

if ($instance instanceof ContainerAwareInterface) {
if (
interface_exists(ContainerAwareInterface::class)
&& $instance instanceof ContainerAwareInterface
) {
$instance->setContainer($this->container);
}

Expand Down

0 comments on commit f230478

Please sign in to comment.