diff --git a/.github/workflows/code_analysis.yaml b/.github/workflows/code_analysis.yaml index 6fb4957238..a1835cf712 100644 --- a/.github/workflows/code_analysis.yaml +++ b/.github/workflows/code_analysis.yaml @@ -34,7 +34,6 @@ jobs: name: Binary File Run run: | # test run bin files - packages/autodiscovery/bin/autodiscovery --ansi packages/easy-coding-standard/bin/ecs --ansi packages/changelog-linker/bin/changelog-linker --ansi packages/monorepo-builder/bin/monorepo-builder --ansi diff --git a/packages/autodiscovery/bin/autodiscovery b/packages/autodiscovery/bin/autodiscovery deleted file mode 100755 index 08d649c626..0000000000 --- a/packages/autodiscovery/bin/autodiscovery +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env php -boot(); - -$container = $autodiscoveryKernel->getContainer(); - -$application = $container->get(AutodiscoveryApplication::class); -exit($application->run()); diff --git a/packages/autodiscovery/composer.json b/packages/autodiscovery/composer.json index 7c81be1c65..1981bdc199 100644 --- a/packages/autodiscovery/composer.json +++ b/packages/autodiscovery/composer.json @@ -8,7 +8,6 @@ "require": { "php": ">=7.2", "nette/utils": "^3.0", - "symfony/console": "^4.4|^5.1", "symfony/dependency-injection": "^4.4|^5.1", "symfony/finder": "^4.4|^5.1", "symfony/routing": "^4.4|^5.1", diff --git a/packages/autodiscovery/src/Command/ConvertYamlCommand.php b/packages/autodiscovery/src/Command/ConvertYamlCommand.php deleted file mode 100644 index 88f0059b26..0000000000 --- a/packages/autodiscovery/src/Command/ConvertYamlCommand.php +++ /dev/null @@ -1,166 +0,0 @@ -explicitToAutodiscoveryConverter = $explicitToAutodiscoveryConverter; - $this->symfonyStyle = $symfonyStyle; - $this->finderSanitizer = $finderSanitizer; - $this->smartFileSystem = $smartFileSystem; - } - - protected function configure(): void - { - $this->setName(CommandNaming::classToName(self::class)); - $this->setDescription( - 'Convert "(services|config).(yml|yaml)" from pre-Symfony 3.3 format to modern format using autodiscovery, autowire and autoconfigure' - ); - - $this->addArgument( - self::ARGUMENT_SOURCE, - InputArgument::REQUIRED, - 'Path to your application directory or single config file' - ); - - $this->addOption( - self::OPTION_NESTING_LEVEL, - 'l', - InputOption::VALUE_REQUIRED, - 'How many namespace levels should be separated in autodiscovery, e.g 2 → "App\SomeProject\", 3 → "App\SomeProject\InnerNamespace\"', - 2 - ); - - $this->addOption( - self::OPTION_FILTER, - 'f', - InputOption::VALUE_REQUIRED, - 'Only include service by filtered name, e.g. "--filter Controller"' - ); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - $source = (string) $input->getArgument(self::ARGUMENT_SOURCE); - if (is_file($source) && file_exists($source)) { - $yamlFileInfos = [new SmartFileInfo($source)]; - } else { - $yamlFileInfos = $this->findServiceYamlFilesInDirectory($source); - } - - foreach ($yamlFileInfos as $yamlFileInfo) { - $this->symfonyStyle->section('Processing ' . $yamlFileInfo->getRealPath()); - - $nestingLevel = (int) $input->getOption(self::OPTION_NESTING_LEVEL); - $filter = (string) $input->getOption(self::OPTION_FILTER); - - $servicesYaml = Yaml::parse($yamlFileInfo->getContents()); - - $convertedYaml = $this->explicitToAutodiscoveryConverter->convert( - $servicesYaml, - $yamlFileInfo->getRealPath(), - $nestingLevel, - $filter - ); - - if ($servicesYaml === $convertedYaml) { - $this->symfonyStyle->note('No changes'); - continue; - } - - $convertedContent = Yaml::dump($convertedYaml, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK); - - // "SomeNamespace\SomeService: null" → "SomeNamespace\SomeService: ~" - $convertedContent = Strings::replace($convertedContent, self::NULL_SERVICE_REGEX, '$1~'); - - // save - $this->smartFileSystem->dumpFile($yamlFileInfo->getRealPath(), $convertedContent); - - $this->symfonyStyle->note('File converted'); - } - - $this->symfonyStyle->success('Done'); - - return ShellCode::SUCCESS; - } - - /** - * @return SmartFileInfo[] - */ - private function findServiceYamlFilesInDirectory(string $directory): array - { - $finder = Finder::create() - ->files() - ->name('#(config|services)\.(\w+\.)?(yml|yaml)$#') - ->in($directory); - - return $this->finderSanitizer->sanitize($finder); - } -} diff --git a/packages/autodiscovery/src/Console/AutodiscoveryApplication.php b/packages/autodiscovery/src/Console/AutodiscoveryApplication.php deleted file mode 100644 index d70bff789b..0000000000 --- a/packages/autodiscovery/src/Console/AutodiscoveryApplication.php +++ /dev/null @@ -1,21 +0,0 @@ -addCommands($commands); - - parent::__construct(); - } -}