<commit_before><?php

namespace Kunstmaan\TranslatorBundle\Service\Command;

use Doctrine\DBAL\Migrations\Configuration\Configuration;
use Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

if (class_exists(\Doctrine\Migrations\Tools\Console\Command\GenerateCommand::class)) {
    /**
     * @deprecated This class is deprecated since KunstmaanTranslatorBundle 5.2 and will be removed in 6.0.
     */
    class DiffCommand extends \Doctrine\Migrations\Tools\Console\Command\GenerateCommand
    {
        protected function configure(): void
        {
            parent::configure();
        }

        public function execute(InputInterface $input, OutputInterface $output): ?int
        {
            $configuration = $this->getMigrationConfiguration($input, $output);
            $sql = $this->getApplication()->getKernel()->getContainer()->get('kunstmaan_translator.service.migrations.migrations')->getDiffSqlArray();

            $up = $this->buildCodeFromSql($configuration, $sql);
            $down = '';

            if (!$up && !$down) {
                $output->writeln('No changes detected in your mapping information.', 'ERROR');

                return 0;
            }

            $version = date('YmdHis');
            $path = $this->generateMigration($configuration, $input, $version, $up, $down);

            $output->writeln(sprintf('Generated new migration class to "<info>%s</info>" from schema differences.', $path));

            return 0;
        }

        private function buildCodeFromSql(\Doctrine\Migrations\Configuration\Configuration $configuration, array $sql)
        {
            $currentPlatform = $configuration->getConnection()->getDatabasePlatform()->getName();
            $code = array(
                "\$this->abortIf(\$this->connection->getDatabasePlatform()->getName() != \"$currentPlatform\", \"Migration can only be executed safely on '$currentPlatform'.\");", '',
            );
            foreach ($sql as $query) {
                if (strpos($query, $configuration->getMigrationsTableName()) !== false) {
                    continue;
                }
                $code[] = "\$this->addSql(\"$query\");";
            }

            return implode("\n", $code);
        }
    }
} else {
    /**
     * @deprecated This class is deprecated since KunstmaanTranslatorBundle 5.2 and will be removed in 6.0.
     */
    class DiffCommand extends GenerateCommand
    {
        protected function configure()
        {
            parent::configure();
        }

        public function execute(InputInterface $input, OutputInterface $output)
        {
            $configuration = $this->getMigrationConfiguration($input, $output);
            $sql = $this->getApplication()->getKernel()->getContainer()->get('kunstmaan_translator.service.migrations.migrations')->getDiffSqlArray();

            $up = $this->buildCodeFromSql($configuration, $sql);
            $down = '';

            if (!$up && !$down) {
                $output->writeln('No changes detected in your mapping information.', 'ERROR');

                return 0;
            }

            $version = date('YmdHis');
            $path = $this->generateMigration($configuration, $input, $version, $up, $down);

            $output->writeln(sprintf('Generated new migration class to "<info>%s</info>" from schema differences.', $path));

            return 0;
        }

        private function buildCodeFromSql(Configuration $configuration, array $sql)
        {
            $currentPlatform = $configuration->getConnection()->getDatabasePlatform()->getName();
            $code = [
                "\$this->abortIf(\$this->connection->getDatabasePlatform()->getName() != \"$currentPlatform\", \"Migration can only be executed safely on '$currentPlatform'.\");", '',
            ];
            foreach ($sql as $query) {
                if (strpos($query, $configuration->getMigrationsTableName()) !== false) {
                    continue;
                }
                $code[] = "\$this->addSql(\"$query\");";
            }

            return implode("\n", $code);
        }
    }
}
<commit_msg>[AllBundles] Fix issues after 5.6 upmerge<commit_after><?php

namespace Kunstmaan\TranslatorBundle\Service\Command;

use Doctrine\DBAL\Migrations\Configuration\Configuration;
use Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

if (class_exists(\Doctrine\Migrations\Tools\Console\Command\GenerateCommand::class)) {
    /**
     * @deprecated This class is deprecated since KunstmaanTranslatorBundle 5.2 and will be removed in 6.0.
     */
    class DiffCommand extends \Doctrine\Migrations\Tools\Console\Command\GenerateCommand
    {
        protected function configure(): void
        {
            parent::configure();
        }

        public function execute(InputInterface $input, OutputInterface $output): ?int
        {
            $configuration = $this->getMigrationConfiguration($input, $output);
            $sql = $this->getApplication()->getKernel()->getContainer()->get('kunstmaan_translator.service.migrations.migrations')->getDiffSqlArray();

            $up = $this->buildCodeFromSql($configuration, $sql);
            $down = '';

            if (!$up && !$down) {
                $output->writeln('No changes detected in your mapping information.', 'ERROR');

                return 0;
            }

            $version = date('YmdHis');
            $path = $this->generateMigration($configuration, $input, $version, $up, $down);

            $output->writeln(sprintf('Generated new migration class to "<info>%s</info>" from schema differences.', $path));

            return 0;
        }

        private function buildCodeFromSql(\Doctrine\Migrations\Configuration\Configuration $configuration, array $sql)
        {
            $currentPlatform = $configuration->getConnection()->getDatabasePlatform()->getName();
            $code = [
                "\$this->abortIf(\$this->connection->getDatabasePlatform()->getName() != \"$currentPlatform\", \"Migration can only be executed safely on '$currentPlatform'.\");", '',
            ];
            foreach ($sql as $query) {
                if (strpos($query, $configuration->getMigrationsTableName()) !== false) {
                    continue;
                }
                $code[] = "\$this->addSql(\"$query\");";
            }

            return implode("\n", $code);
        }
    }
} else {
    /**
     * @deprecated This class is deprecated since KunstmaanTranslatorBundle 5.2 and will be removed in 6.0.
     */
    class DiffCommand extends GenerateCommand
    {
        protected function configure()
        {
            parent::configure();
        }

        public function execute(InputInterface $input, OutputInterface $output)
        {
            $configuration = $this->getMigrationConfiguration($input, $output);
            $sql = $this->getApplication()->getKernel()->getContainer()->get('kunstmaan_translator.service.migrations.migrations')->getDiffSqlArray();

            $up = $this->buildCodeFromSql($configuration, $sql);
            $down = '';

            if (!$up && !$down) {
                $output->writeln('No changes detected in your mapping information.', 'ERROR');

                return 0;
            }

            $version = date('YmdHis');
            $path = $this->generateMigration($configuration, $input, $version, $up, $down);

            $output->writeln(sprintf('Generated new migration class to "<info>%s</info>" from schema differences.', $path));

            return 0;
        }

        private function buildCodeFromSql(Configuration $configuration, array $sql)
        {
            $currentPlatform = $configuration->getConnection()->getDatabasePlatform()->getName();
            $code = [
                "\$this->abortIf(\$this->connection->getDatabasePlatform()->getName() != \"$currentPlatform\", \"Migration can only be executed safely on '$currentPlatform'.\");", '',
            ];
            foreach ($sql as $query) {
                if (strpos($query, $configuration->getMigrationsTableName()) !== false) {
                    continue;
                }
                $code[] = "\$this->addSql(\"$query\");";
            }

            return implode("\n", $code);
        }
    }
}

{'fraction_non_alphanumeric': 0.14245382896129868, 'fraction_numerical': 0.003058463710151747, 'mean_word_length': 2.3432953204876132, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1983275', 'n_tokens_mistral': 2174, 'n_tokens_neox': 2139, 'n_words': 450}