diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 69201b099d5..68221cbc729 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -31,14 +31,10 @@ 'native_function_invocation' => ['include' => ['@compiler_optimized']], 'array_syntax' => ['syntax' => 'short'], 'ordered_imports' => ['sort_algorithm' => 'alpha'], - 'App/doctrine_migration_clean' => true, 'attribute_empty_parentheses' => true, 'ordered_attributes' => true, ]) ->setRiskyAllowed(true) ->setFinder($finder) ->setCacheFile(__DIR__.'/var/.php_cs/.php_cs.cache') - ->registerCustomFixers([ - new App\Fixer\DoctrineMigrationCleanFixer(), - ]) ; diff --git a/config/packages/doctrine_migrations.yaml b/config/packages/doctrine_migrations.yaml index afb429c214c..84099beec19 100644 --- a/config/packages/doctrine_migrations.yaml +++ b/config/packages/doctrine_migrations.yaml @@ -6,3 +6,4 @@ doctrine_migrations: table_storage: table_name: 'migrations' organize_migrations: 'BY_YEAR' + custom_template: '%kernel.project_dir%/migrations/migration.tpl' diff --git a/migrations/migration.tpl b/migrations/migration.tpl new file mode 100644 index 00000000000..e41ff8c49a7 --- /dev/null +++ b/migrations/migration.tpl @@ -0,0 +1,19 @@ +; + +use Doctrine\DBAL\Schema\Schema; +use Doctrine\Migrations\AbstractMigration; + +final class extends AbstractMigration +{ + public function up(Schema $schema): void + { + + } + + public function down(Schema $schema): void + { + + } +} diff --git a/src/Fixer/DoctrineMigrationCleanFixer.php b/src/Fixer/DoctrineMigrationCleanFixer.php deleted file mode 100644 index 8abffd55da3..00000000000 --- a/src/Fixer/DoctrineMigrationCleanFixer.php +++ /dev/null @@ -1,108 +0,0 @@ -abortIf($this->connection->getDatabasePlatform()->getName() !== \'mysql\', \'Migration can only be executed safely on \'mysql\'.\'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->abortIf($this->connection->getDatabasePlatform()->getName() !== \'mysql\', \'Migration can only be executed safely on \'mysql\'.\'); - } -}' - ), - ] - ); - } - - public function isRisky(): bool - { - return true; - } - - public function supports(\SplFileInfo $file): bool - { - return preg_match("/^Version\d{14}/", $file->getBasename()); - } - - public function isCandidate(Tokens $tokens): bool - { - return $tokens->isAllTokenKindsFound($this->candidateTokens); - } - - public function applyFix(\SplFileInfo $file, Tokens $tokens): void - { - foreach ($tokens as $index => $token) { - if ($token->isGivenKind(\T_DECLARE)) { - $tokens->clearRange( - $index, - $tokens->getTokenOfKindSibling($index, 1, [[\T_WHITESPACE]]) - ); - } - - if ($token->isGivenKind(\T_DOC_COMMENT) - && str_contains($token->getContent(), 'Auto-generated Migration: Please modify to your needs!') - ) { - $tokens->clearRange( - $index, - $tokens->getTokenOfKindSibling($index, 1, [[\T_WHITESPACE]]) - ); - } - - if ($token->isGivenKind(\T_COMMENT) - && str_contains($token->getContent(), 'auto-generated') - ) { - $tokens->clearRange( - $index, - $tokens->getTokenOfKindSibling($index, 1, [[\T_WHITESPACE]]) - ); - } - - if ($token->isGivenKind(\T_STRING) && 'abortIf' === $token->getContent()) { - $tokens->clearRange( - $tokens->getTokenOfKindSibling($index, -1, [[\T_WHITESPACE]]), - $endOfTheLineTokenIndex = $tokens->getNextTokenOfKind($index, [';']) - ); - } - } - } -}