rector/config/services.php

102 lines
3.6 KiB
PHP
Raw Normal View History

2020-07-16 13:07:08 +02:00
<?php
declare(strict_types=1);
use Composer\Semver\VersionParser;
use Doctrine\Inflector\Inflector;
use Doctrine\Inflector\Rules\English\InflectorFactory;
2020-07-16 13:07:08 +02:00
use PhpParser\BuilderFactory;
use PhpParser\Lexer;
use PhpParser\NodeFinder;
use PhpParser\NodeVisitor\CloningVisitor;
use PhpParser\Parser;
use PhpParser\ParserFactory;
use Rector\Core\Bootstrap\NoRectorsLoadedReporter;
use Rector\Core\Configuration\RectorClassesProvider;
use Rector\Core\Console\ConsoleApplication;
2020-07-16 13:07:08 +02:00
use Rector\Core\PhpParser\Parser\NikicPhpParserFactory;
use Rector\Core\PhpParser\Parser\PhpParserLexerFactory;
2020-07-16 13:07:08 +02:00
use Symfony\Component\Console\Application as SymfonyApplication;
use Symfony\Component\Console\Descriptor\TextDescriptor;
2020-07-19 10:34:30 +02:00
use Symfony\Component\Console\Style\SymfonyStyle;
2020-07-18 11:24:54 +02:00
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
2020-07-16 13:07:08 +02:00
use Symfony\Component\Filesystem\Filesystem;
use Symplify\PackageBuilder\Console\Command\CommandNaming;
2020-07-20 10:20:23 +02:00
use Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory;
2020-07-16 13:07:08 +02:00
use Symplify\PackageBuilder\Parameter\ParameterProvider;
use Symplify\PackageBuilder\Reflection\PrivatesAccessor;
use Symplify\PackageBuilder\Reflection\PrivatesCaller;
use Symplify\PackageBuilder\Strings\StringFormatConverter;
use Symplify\SmartFileSystem\FileSystemFilter;
use Symplify\SmartFileSystem\Finder\FinderSanitizer;
use Symplify\SmartFileSystem\SmartFileSystem;
2020-07-16 13:07:08 +02:00
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->defaults()
->public()
->autowire()
->autoconfigure();
2020-07-16 13:07:08 +02:00
$services->load('Rector\Core\\', __DIR__ . '/../src')
->exclude([
__DIR__ . '/../src/Rector',
__DIR__ . '/../src/Exception',
__DIR__ . '/../src/DependencyInjection/CompilerPass',
__DIR__ . '/../src/DependencyInjection/Loader',
__DIR__ . '/../src/HttpKernel',
__DIR__ . '/../src/ValueObject',
__DIR__ . '/../src/Bootstrap',
__DIR__ . '/../src/PhpParser/Node/CustomNode',
2020-07-16 13:07:08 +02:00
]);
$services->alias(SymfonyApplication::class, ConsoleApplication::class);
2020-07-16 13:07:08 +02:00
$services->set(NoRectorsLoadedReporter::class);
2020-07-16 13:07:08 +02:00
$services->set(TextDescriptor::class);
$services->set(ParserFactory::class);
$services->set(BuilderFactory::class);
$services->set(CloningVisitor::class);
$services->set(NodeFinder::class);
$services->set(Parser::class)
->factory([service(NikicPhpParserFactory::class), 'create']);
2020-07-16 13:07:08 +02:00
$services->set(Lexer::class)
->factory([service(PhpParserLexerFactory::class), 'create']);
2020-07-16 13:07:08 +02:00
// symplify/package-builder
2020-07-16 13:07:08 +02:00
$services->set(Filesystem::class);
$services->set(PrivatesAccessor::class);
$services->set(PrivatesCaller::class);
2020-07-16 13:07:08 +02:00
$services->set(FinderSanitizer::class);
$services->set(FileSystemFilter::class);
$services->set(ParameterProvider::class);
$services->set(ParameterProvider::class)
->arg('$container', service('service_container'));
$services->set(RectorClassesProvider::class)
->arg('$container', service('service_container'));
$services->set(CommandNaming::class);
$services->set(SmartFileSystem::class);
2020-07-16 13:07:08 +02:00
$services->set(StringFormatConverter::class);
2020-07-19 10:34:30 +02:00
$services->set(SymfonyStyleFactory::class);
$services->set(SymfonyStyle::class)
->factory([service(SymfonyStyleFactory::class), 'create']);
$services->set(InflectorFactory::class);
$services->set(Inflector::class)
->factory([service(InflectorFactory::class), 'build']);
$services->set(VersionParser::class);
2020-07-16 13:07:08 +02:00
};