Skip to content

Commit

Permalink
Fix deprecated container injection in migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
pablothedude committed Nov 26, 2024
1 parent 8a0f7c0 commit 4186b13
Show file tree
Hide file tree
Showing 20 changed files with 199 additions and 395 deletions.
4 changes: 2 additions & 2 deletions bin/doctrine-migrations-diff.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash

bin/console doctrine:migrations:diff --em=middleware --filter-expression='~^(?!event_stream).*$~'
bin/console doctrine:migrations:diff --em=middleware --env=dev --filter-expression='~^(?!event_stream).*$~'
sleep 1
bin/console doctrine:migrations:diff --em=gateway
bin/console doctrine:migrations:diff --em=gateway --env=dev
210 changes: 0 additions & 210 deletions ci/qa/phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,185 +1,5 @@
parameters:
ignoreErrors:
-
message: "#^Cannot call method getParameter\\(\\) on Symfony\\\\Component\\\\DependencyInjection\\\\ContainerInterface\\|null\\.$#"
count: 2
path: ../../src/Surfnet/Migrations/Version20141125173004.php

-
message: "#^Method Surfnet\\\\Migrations\\\\Version20141125173004\\:\\:getGatewaySchema\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20141125173004.php

-
message: "#^Method Surfnet\\\\Migrations\\\\Version20141125173004\\:\\:getMiddlewareUser\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20141125173004.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, array\\|bool\\|float\\|int\\|string\\|null given\\.$#"
count: 4
path: ../../src/Surfnet/Migrations/Version20141125173004.php

-
message: "#^Parameter \\#3 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, array\\|bool\\|float\\|int\\|string\\|null given\\.$#"
count: 2
path: ../../src/Surfnet/Migrations/Version20141125173004.php

-
message: "#^Cannot call method getParameter\\(\\) on Symfony\\\\Component\\\\DependencyInjection\\\\ContainerInterface\\|null\\.$#"
count: 2
path: ../../src/Surfnet/Migrations/Version20141209150426.php

-
message: "#^Method Surfnet\\\\Migrations\\\\Version20141209150426\\:\\:getGatewaySchema\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20141209150426.php

-
message: "#^Method Surfnet\\\\Migrations\\\\Version20141209150426\\:\\:getMiddlewareUser\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20141209150426.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, array\\|bool\\|float\\|int\\|string\\|null given\\.$#"
count: 3
path: ../../src/Surfnet/Migrations/Version20141209150426.php

-
message: "#^Parameter \\#3 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, array\\|bool\\|float\\|int\\|string\\|null given\\.$#"
count: 2
path: ../../src/Surfnet/Migrations/Version20141209150426.php

-
message: "#^Cannot call method getParameter\\(\\) on Symfony\\\\Component\\\\DependencyInjection\\\\ContainerInterface\\|null\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20141210174213.php

-
message: "#^Method Surfnet\\\\Migrations\\\\Version20141210174213\\:\\:getGatewaySchema\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20141210174213.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, array\\|bool\\|float\\|int\\|string\\|null given\\.$#"
count: 7
path: ../../src/Surfnet/Migrations/Version20141210174213.php

-
message: "#^Cannot call method getParameter\\(\\) on Symfony\\\\Component\\\\DependencyInjection\\\\ContainerInterface\\|null\\.$#"
count: 2
path: ../../src/Surfnet/Migrations/Version20150312162849.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, array\\|bool\\|float\\|int\\|string\\|null given\\.$#"
count: 2
path: ../../src/Surfnet/Migrations/Version20150312162849.php

-
message: "#^Cannot call method getParameter\\(\\) on Symfony\\\\Component\\\\DependencyInjection\\\\ContainerInterface\\|null\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20150508085838.php

-
message: "#^Method Surfnet\\\\Migrations\\\\Version20150508085838\\:\\:getGatewaySchema\\(\\) should return string but returns array\\|bool\\|float\\|int\\|string\\|null\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20150508085838.php

-
message: "#^Cannot call method getParameter\\(\\) on Symfony\\\\Component\\\\DependencyInjection\\\\ContainerInterface\\|null\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20150522163053.php

-
message: "#^Method Surfnet\\\\Migrations\\\\Version20150522163053\\:\\:getGatewaySchema\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20150522163053.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, array\\|bool\\|float\\|int\\|string\\|null given\\.$#"
count: 8
path: ../../src/Surfnet/Migrations/Version20150522163053.php

-
message: "#^Cannot call method getParameter\\(\\) on Symfony\\\\Component\\\\DependencyInjection\\\\ContainerInterface\\|null\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20150522164907.php

-
message: "#^Method Surfnet\\\\Migrations\\\\Version20150522164907\\:\\:getGatewaySchema\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20150522164907.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, array\\|bool\\|float\\|int\\|string\\|null given\\.$#"
count: 2
path: ../../src/Surfnet/Migrations/Version20150522164907.php

-
message: "#^Cannot call method getParameter\\(\\) on Symfony\\\\Component\\\\DependencyInjection\\\\ContainerInterface\\|null\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20150528154959.php

-
message: "#^Method Surfnet\\\\Migrations\\\\Version20150528154959\\:\\:getGatewaySchema\\(\\) should return string but returns array\\|bool\\|float\\|int\\|string\\|null\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20150528154959.php

-
message: "#^Cannot call method getParameter\\(\\) on Symfony\\\\Component\\\\DependencyInjection\\\\ContainerInterface\\|null\\.$#"
count: 3
path: ../../src/Surfnet/Migrations/Version20150615114646.php

-
message: "#^Method Surfnet\\\\Migrations\\\\Version20150615114646\\:\\:getGatewaySchema\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20150615114646.php

-
message: "#^Method Surfnet\\\\Migrations\\\\Version20150615114646\\:\\:getMiddlewareSchema\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20150615114646.php

-
message: "#^Method Surfnet\\\\Migrations\\\\Version20150615114646\\:\\:getMiddlewareUser\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20150615114646.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, array\\|bool\\|float\\|int\\|string\\|null given\\.$#"
count: 6
path: ../../src/Surfnet/Migrations/Version20150615114646.php

-
message: "#^Parameter \\#3 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, array\\|bool\\|float\\|int\\|string\\|null given\\.$#"
count: 2
path: ../../src/Surfnet/Migrations/Version20150615114646.php

-
message: "#^Cannot call method getParameter\\(\\) on Symfony\\\\Component\\\\DependencyInjection\\\\ContainerInterface\\|null\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20180131150800.php

-
message: "#^Method Surfnet\\\\Migrations\\\\Version20180131150800\\:\\:getGatewaySchema\\(\\) should return string but returns array\\|bool\\|float\\|int\\|string\\|null\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20180131150800.php

-
message: "#^Cannot call method getParameter\\(\\) on Symfony\\\\Component\\\\DependencyInjection\\\\ContainerInterface\\|null\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20200114161618.php

-
message: "#^Method Surfnet\\\\Migrations\\\\Version20200114161618\\:\\:getGatewaySchema\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20200114161618.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, array\\|bool\\|float\\|int\\|string\\|null given\\.$#"
count: 2
path: ../../src/Surfnet/Migrations/Version20200114161618.php

-
message: "#^Cannot access offset 'payload' on mixed\\.$#"
count: 1
Expand Down Expand Up @@ -210,36 +30,6 @@ parameters:
count: 1
path: ../../src/Surfnet/Migrations/Version20210610131957.php

-
message: "#^Cannot call method getParameter\\(\\) on Symfony\\\\Component\\\\DependencyInjection\\\\ContainerInterface\\|null\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20220519134637.php

-
message: "#^Method Surfnet\\\\Migrations\\\\Version20220519134637\\:\\:getGatewaySchema\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20220519134637.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, array\\|bool\\|float\\|int\\|string\\|null given\\.$#"
count: 2
path: ../../src/Surfnet/Migrations/Version20220519134637.php

-
message: "#^Cannot call method getParameter\\(\\) on Symfony\\\\Component\\\\DependencyInjection\\\\ContainerInterface\\|null\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20221102143350.php

-
message: "#^Method Surfnet\\\\Migrations\\\\Version20221102143350\\:\\:getGatewaySchema\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: ../../src/Surfnet/Migrations/Version20221102143350.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, array\\|bool\\|float\\|int\\|string\\|null given\\.$#"
count: 2
path: ../../src/Surfnet/Migrations/Version20221102143350.php

-
message: "#^Cannot access offset 'email_templates' on mixed\\.$#"
count: 1
Expand Down
2 changes: 2 additions & 0 deletions config/packages/doctrine_migrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ doctrine_migrations:
table_name: 'migration_versions'
version_column_name: 'version'
version_column_length: 192
services:
Doctrine\Migrations\Version\MigrationFactory: 'Surfnet\Stepup\MigrationsFactory\ConfigurationMigrationFactory'
7 changes: 7 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,10 @@ services:
- location
- contactInformation
- [] # Allowed functions

Surfnet\Stepup\MigrationsFactory\ConfigurationMigrationFactory:
arguments:
- "@doctrine.migrations.migrations_factory"
- "%database_gateway_name%"
- "%database_middleware_name%"
- "%database_middleware_user%"
23 changes: 4 additions & 19 deletions src/Surfnet/Migrations/Version20141125173004.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,15 @@

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Surfnet\Stepup\MigrationsFactory\ConfigurationAwareMigrationInterface;
use Surfnet\Stepup\MigrationsFactory\ConfigurationAwareMigrationTrait;

/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20141125173004 extends AbstractMigration implements ContainerAwareInterface
class Version20141125173004 extends AbstractMigration implements ConfigurationAwareMigrationInterface
{
private ?ContainerInterface $container = null;

public function setContainer(ContainerInterface $container = null): void
{
$this->container = $container;
}
use ConfigurationAwareMigrationTrait;

public function up(Schema $schema): void
{
Expand Down Expand Up @@ -73,14 +68,4 @@ public function down(Schema $schema): void
);
$this->addSql(sprintf('DROP TABLE %s.saml_entity', $gatewaySchema));
}

private function getGatewaySchema(): float|array|bool|int|string|null
{
return $this->container->getParameter('database_gateway_name');
}

private function getMiddlewareUser(): float|array|bool|int|string|null
{
return $this->container->getParameter('database_middleware_user');
}
}
20 changes: 4 additions & 16 deletions src/Surfnet/Migrations/Version20141209150426.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,18 @@

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Surfnet\Stepup\MigrationsFactory\ConfigurationAwareMigrationInterface;
use Surfnet\Stepup\MigrationsFactory\ConfigurationAwareMigrationTrait;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20141209150426 extends AbstractMigration implements ContainerAwareInterface
class Version20141209150426 extends AbstractMigration implements ConfigurationAwareMigrationInterface
{
private ?ContainerInterface $container = null;
use ConfigurationAwareMigrationTrait;

public function setContainer(ContainerInterface $container = null): void
{
$this->container = $container;
}

public function up(Schema $schema): void
{
Expand Down Expand Up @@ -78,14 +76,4 @@ public function down(Schema $schema): void
);
$this->addSql('DROP TABLE second_factor');
}

private function getGatewaySchema(): float|array|bool|int|string|null
{
return $this->container->getParameter('database_gateway_name');
}

private function getMiddlewareUser(): float|array|bool|int|string|null
{
return $this->container->getParameter('database_middleware_user');
}
}
16 changes: 4 additions & 12 deletions src/Surfnet/Migrations/Version20141210174213.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Surfnet\Stepup\MigrationsFactory\ConfigurationAwareMigrationInterface;
use Surfnet\Stepup\MigrationsFactory\ConfigurationAwareMigrationTrait;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20141210174213 extends AbstractMigration implements ContainerAwareInterface
class Version20141210174213 extends AbstractMigration implements ConfigurationAwareMigrationInterface
{
private ?ContainerInterface $container = null;
use ConfigurationAwareMigrationTrait;

public function up(Schema $schema): void
{
Expand Down Expand Up @@ -62,14 +64,4 @@ public function down(Schema $schema): void
$this->addSql(sprintf('ALTER TABLE %s.second_factor DROP id', $gatewaySchema));
$this->addSql(sprintf('ALTER TABLE %s.second_factor ADD PRIMARY KEY (identity_id)', $gatewaySchema));
}

private function getGatewaySchema(): float|array|bool|int|string|null
{
return $this->container->getParameter('database_gateway_name');
}

public function setContainer(ContainerInterface $container = null): void
{
$this->container = $container;
}
}
Loading

0 comments on commit 4186b13

Please sign in to comment.