2020-07-16 13:07:08 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-12-29 01:32:48 +01:00
|
|
|
use Composer\Semver\VersionParser;
|
2020-07-28 00:19:38 +08:00
|
|
|
use Doctrine\Inflector\Inflector;
|
|
|
|
use Doctrine\Inflector\Rules\English\InflectorFactory;
|
2021-05-06 13:26:28 +02:00
|
|
|
use Ergebnis\Json\Printer\Printer;
|
|
|
|
use Ergebnis\Json\Printer\PrinterInterface;
|
|
|
|
use Idiosyncratic\EditorConfig\EditorConfig;
|
2021-03-18 02:11:54 +01:00
|
|
|
use Nette\Caching\Cache;
|
2020-07-16 13:07:08 +02:00
|
|
|
use PhpParser\BuilderFactory;
|
|
|
|
use PhpParser\Lexer;
|
|
|
|
use PhpParser\NodeFinder;
|
|
|
|
use PhpParser\NodeVisitor\CloningVisitor;
|
2021-03-12 02:21:29 +01:00
|
|
|
use PhpParser\NodeVisitor\NodeConnectingVisitor;
|
2020-07-16 13:07:08 +02:00
|
|
|
use PhpParser\Parser;
|
|
|
|
use PhpParser\ParserFactory;
|
2021-03-12 02:21:29 +01:00
|
|
|
use PHPStan\Analyser\NodeScopeResolver;
|
|
|
|
use PHPStan\Analyser\ScopeFactory;
|
|
|
|
use PHPStan\Dependency\DependencyResolver;
|
|
|
|
use PHPStan\File\FileHelper;
|
|
|
|
use PHPStan\PhpDoc\TypeNodeResolver;
|
|
|
|
use PHPStan\PhpDocParser\Parser\PhpDocParser;
|
2021-04-04 11:01:11 +02:00
|
|
|
use PHPStan\PhpDocParser\Parser\TypeParser;
|
2021-03-12 02:21:29 +01:00
|
|
|
use PHPStan\Reflection\ReflectionProvider;
|
2021-05-06 13:26:28 +02:00
|
|
|
use PrettyXml\Formatter;
|
2021-03-12 02:21:29 +01:00
|
|
|
use Rector\BetterPhpDocParser\PhpDocParser\BetterPhpDocParser;
|
2021-04-04 11:01:11 +02:00
|
|
|
use Rector\BetterPhpDocParser\PhpDocParser\BetterTypeParser;
|
2021-03-18 02:11:54 +01:00
|
|
|
use Rector\Caching\Cache\NetteCacheFactory;
|
2020-11-23 20:16:48 +01:00
|
|
|
use Rector\Core\Console\ConsoleApplication;
|
2020-07-16 13:07:08 +02:00
|
|
|
use Rector\Core\PhpParser\Parser\NikicPhpParserFactory;
|
2020-10-05 00:19:25 +02:00
|
|
|
use Rector\Core\PhpParser\Parser\PhpParserLexerFactory;
|
2021-05-06 13:26:28 +02:00
|
|
|
use Rector\FileFormatter\Contract\EditorConfig\EditorConfigParserInterface;
|
|
|
|
use Rector\FileFormatter\EditorConfig\EditorConfigIdiosyncraticParser;
|
2021-03-12 02:21:29 +01:00
|
|
|
use Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory;
|
|
|
|
use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocator\IntermediateSourceLocator;
|
|
|
|
use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider;
|
2020-07-16 13:07:08 +02:00
|
|
|
use Symfony\Component\Console\Application as SymfonyApplication;
|
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;
|
2021-01-08 15:04:35 +01:00
|
|
|
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
|
2021-03-06 22:16:18 +01:00
|
|
|
use Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser;
|
2020-11-23 20:16:48 +01:00
|
|
|
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;
|
2021-01-19 20:11:10 +01:00
|
|
|
use Symplify\PackageBuilder\Php\TypeChecker;
|
2020-07-16 13:07:08 +02:00
|
|
|
use Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
|
|
|
use Symplify\PackageBuilder\Reflection\PrivatesCaller;
|
|
|
|
use Symplify\PackageBuilder\Strings\StringFormatConverter;
|
|
|
|
use Symplify\SmartFileSystem\FileSystemFilter;
|
2021-03-12 20:13:27 +01:00
|
|
|
use Symplify\SmartFileSystem\FileSystemGuard;
|
2020-07-16 13:07:08 +02:00
|
|
|
use Symplify\SmartFileSystem\Finder\FinderSanitizer;
|
2021-01-15 21:27:36 +01:00
|
|
|
use Symplify\SmartFileSystem\Json\JsonFileSystem;
|
2020-07-20 00:48:51 +02:00
|
|
|
use Symplify\SmartFileSystem\SmartFileSystem;
|
2020-07-16 13:07:08 +02:00
|
|
|
|
|
|
|
return static function (ContainerConfigurator $containerConfigurator): void {
|
|
|
|
$services = $containerConfigurator->services();
|
|
|
|
|
|
|
|
$services->defaults()
|
|
|
|
->public()
|
2020-09-23 11:16:40 +02:00
|
|
|
->autowire()
|
|
|
|
->autoconfigure();
|
2020-07-16 13:07:08 +02:00
|
|
|
|
|
|
|
$services->load('Rector\Core\\', __DIR__ . '/../src')
|
|
|
|
->exclude([
|
2020-09-23 11:16:40 +02:00
|
|
|
__DIR__ . '/../src/Rector',
|
|
|
|
__DIR__ . '/../src/Exception',
|
|
|
|
__DIR__ . '/../src/DependencyInjection/CompilerPass',
|
|
|
|
__DIR__ . '/../src/DependencyInjection/Loader',
|
|
|
|
__DIR__ . '/../src/HttpKernel',
|
|
|
|
__DIR__ . '/../src/ValueObject',
|
|
|
|
__DIR__ . '/../src/Bootstrap',
|
2020-10-05 10:39:02 +02:00
|
|
|
__DIR__ . '/../src/PhpParser/Node/CustomNode',
|
2021-04-24 16:22:36 +02:00
|
|
|
__DIR__ . '/../src/functions',
|
2021-05-04 14:21:34 +02:00
|
|
|
__DIR__ . '/../src/constants.php',
|
2020-07-16 13:07:08 +02:00
|
|
|
]);
|
|
|
|
|
2020-11-23 20:16:48 +01:00
|
|
|
$services->alias(SymfonyApplication::class, ConsoleApplication::class);
|
2020-07-16 13:07:08 +02:00
|
|
|
|
2021-03-12 20:13:27 +01:00
|
|
|
$services->set(FileSystemGuard::class);
|
|
|
|
|
2021-03-06 22:16:18 +01:00
|
|
|
$services->set(SimpleCallableNodeTraverser::class);
|
2020-10-10 19:42:43 +02:00
|
|
|
|
2020-07-16 13:07:08 +02:00
|
|
|
$services->set(ParserFactory::class);
|
|
|
|
$services->set(BuilderFactory::class);
|
|
|
|
$services->set(CloningVisitor::class);
|
|
|
|
$services->set(NodeFinder::class);
|
|
|
|
|
|
|
|
$services->set(Parser::class)
|
2021-01-08 15:04:35 +01:00
|
|
|
->factory([service(NikicPhpParserFactory::class), 'create']);
|
2020-07-16 13:07:08 +02:00
|
|
|
$services->set(Lexer::class)
|
2021-01-08 15:04:35 +01:00
|
|
|
->factory([service(PhpParserLexerFactory::class), 'create']);
|
2020-07-16 13:07:08 +02:00
|
|
|
|
2020-11-23 20:16:48 +01:00
|
|
|
// symplify/package-builder
|
2020-07-16 13:07:08 +02:00
|
|
|
$services->set(PrivatesAccessor::class);
|
2020-09-23 11:16:40 +02:00
|
|
|
$services->set(PrivatesCaller::class);
|
2020-07-16 13:07:08 +02:00
|
|
|
$services->set(FinderSanitizer::class);
|
|
|
|
$services->set(FileSystemFilter::class);
|
2021-03-06 22:16:18 +01:00
|
|
|
|
2020-11-23 15:10:13 +01:00
|
|
|
$services->set(ParameterProvider::class)
|
2021-01-08 15:04:35 +01:00
|
|
|
->arg('$container', service('service_container'));
|
2020-11-23 15:10:13 +01:00
|
|
|
|
2020-11-23 20:16:48 +01:00
|
|
|
$services->set(CommandNaming::class);
|
2020-09-23 11:16:40 +02:00
|
|
|
$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)
|
2021-01-08 15:04:35 +01:00
|
|
|
->factory([service(SymfonyStyleFactory::class), 'create']);
|
2020-07-28 00:19:38 +08:00
|
|
|
|
2021-01-15 21:27:36 +01:00
|
|
|
$services->set(JsonFileSystem::class);
|
2021-03-12 02:21:29 +01:00
|
|
|
$services->set(NodeConnectingVisitor::class);
|
2021-01-15 21:27:36 +01:00
|
|
|
|
2020-07-28 00:19:38 +08:00
|
|
|
$services->set(InflectorFactory::class);
|
|
|
|
$services->set(Inflector::class)
|
2021-01-08 15:04:35 +01:00
|
|
|
->factory([service(InflectorFactory::class), 'build']);
|
2020-12-29 01:32:48 +01:00
|
|
|
|
|
|
|
$services->set(VersionParser::class);
|
2021-01-19 20:11:10 +01:00
|
|
|
$services->set(TypeChecker::class);
|
2021-03-12 02:21:29 +01:00
|
|
|
|
|
|
|
// phpdoc parser
|
|
|
|
$services->set(\PHPStan\PhpDocParser\Lexer\Lexer::class);
|
|
|
|
$services->alias(PhpDocParser::class, BetterPhpDocParser::class);
|
|
|
|
|
|
|
|
// cache
|
|
|
|
$services->set(DependencyResolver::class)
|
|
|
|
->factory([service(PHPStanServicesFactory::class), 'createDependencyResolver']);
|
|
|
|
$services->set(FileHelper::class)
|
|
|
|
->factory([service(PHPStanServicesFactory::class), 'createFileHelper']);
|
2021-03-18 02:11:54 +01:00
|
|
|
|
|
|
|
$services->set(Cache::class)
|
|
|
|
->factory([service(NetteCacheFactory::class), 'create']);
|
2021-03-12 02:21:29 +01:00
|
|
|
|
|
|
|
// type resolving
|
|
|
|
$services->set(IntermediateSourceLocator::class);
|
2021-04-04 11:01:11 +02:00
|
|
|
$services->alias(TypeParser::class, BetterTypeParser::class);
|
|
|
|
|
2021-03-12 02:21:29 +01:00
|
|
|
// PHPStan services
|
|
|
|
$services->set(ReflectionProvider::class)
|
|
|
|
->factory([service(PHPStanServicesFactory::class), 'createReflectionProvider']);
|
|
|
|
$services->set(NodeScopeResolver::class)
|
|
|
|
->factory([service(PHPStanServicesFactory::class), 'createNodeScopeResolver']);
|
|
|
|
$services->set(ScopeFactory::class)
|
|
|
|
->factory([service(PHPStanServicesFactory::class), 'createScopeFactory']);
|
|
|
|
$services->set(TypeNodeResolver::class)
|
|
|
|
->factory([service(PHPStanServicesFactory::class), 'createTypeNodeResolver']);
|
|
|
|
$services->set(DynamicSourceLocatorProvider::class)
|
|
|
|
->factory([service(PHPStanServicesFactory::class), 'createDynamicSourceLocatorProvider']);
|
2021-05-06 13:26:28 +02:00
|
|
|
|
|
|
|
$services->set(Printer::class);
|
|
|
|
$services->alias(PrinterInterface::class, Printer::class);
|
|
|
|
|
|
|
|
$services->set(Formatter::class);
|
|
|
|
|
|
|
|
$services->set(EditorConfig::class);
|
|
|
|
|
|
|
|
$services->alias(EditorConfigParserInterface::class, EditorConfigIdiosyncraticParser::class);
|
2020-07-16 13:07:08 +02:00
|
|
|
};
|