diff options
Diffstat (limited to 'lib/private/DB/Migrator.php')
-rw-r--r-- | lib/private/DB/Migrator.php | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/lib/private/DB/Migrator.php b/lib/private/DB/Migrator.php index 9ca37d7180a..5dc07be1d2b 100644 --- a/lib/private/DB/Migrator.php +++ b/lib/private/DB/Migrator.php @@ -27,48 +27,41 @@ */ namespace OC\DB; +use Doctrine\DBAL\Connection; use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\DBAL\Schema\AbstractAsset; use Doctrine\DBAL\Schema\Comparator; use Doctrine\DBAL\Schema\Schema; +use Doctrine\DBAL\Schema\SchemaDiff; use Doctrine\DBAL\Types\StringType; use Doctrine\DBAL\Types\Type; use OCP\IConfig; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\GenericEvent; use function preg_match; +use OCP\EventDispatcher\IEventDispatcher; class Migrator { - /** @var \Doctrine\DBAL\Connection */ + /** @var Connection */ protected $connection; /** @var IConfig */ protected $config; - /** @var EventDispatcherInterface */ - private $dispatcher; + private ?IEventDispatcher $dispatcher; /** @var bool */ private $noEmit = false; - /** - * @param \Doctrine\DBAL\Connection $connection - * @param IConfig $config - * @param EventDispatcherInterface $dispatcher - */ - public function __construct(\Doctrine\DBAL\Connection $connection, + public function __construct(Connection $connection, IConfig $config, - EventDispatcherInterface $dispatcher = null) { + ?IEventDispatcher $dispatcher = null) { $this->connection = $connection; $this->config = $config; $this->dispatcher = $dispatcher; } /** - * @param \Doctrine\DBAL\Schema\Schema $targetSchema - * * @throws Exception */ public function migrate(Schema $targetSchema) { @@ -77,7 +70,6 @@ class Migrator { } /** - * @param \Doctrine\DBAL\Schema\Schema $targetSchema * @return string */ public function generateChangeScript(Schema $targetSchema) { @@ -108,11 +100,9 @@ class Migrator { } /** - * @param Schema $targetSchema - * @param \Doctrine\DBAL\Connection $connection - * @return \Doctrine\DBAL\Schema\SchemaDiff + * @return SchemaDiff */ - protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) { + protected function getDiff(Schema $targetSchema, Connection $connection) { // adjust varchar columns with a length higher then getVarcharMaxLength to clob foreach ($targetSchema->getTables() as $table) { foreach ($table->getColumns() as $column) { @@ -153,12 +143,9 @@ class Migrator { } /** - * @param \Doctrine\DBAL\Schema\Schema $targetSchema - * @param \Doctrine\DBAL\Connection $connection - * * @throws Exception */ - protected function applySchema(Schema $targetSchema, \Doctrine\DBAL\Connection $connection = null) { + protected function applySchema(Schema $targetSchema, Connection $connection = null) { if (is_null($connection)) { $connection = $this->connection; } @@ -194,13 +181,13 @@ class Migrator { return '/^' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/'; } - protected function emit($sql, $step, $max) { + protected function emit(string $sql, int $step, int $max): void { if ($this->noEmit) { return; } if (is_null($this->dispatcher)) { return; } - $this->dispatcher->dispatch('\OC\DB\Migrator::executeSql', new GenericEvent($sql, [$step + 1, $max])); + $this->dispatcher->dispatchTyped(new MigratorExecuteSqlEvent($sql, $step, $max)); } } |