|
53 | 53 | use Symfony\Component\Console\Debug\CliRequest;
|
54 | 54 | use Symfony\Component\Console\Messenger\RunCommandMessageHandler;
|
55 | 55 | use Symfony\Component\DependencyInjection\Alias;
|
| 56 | +use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument; |
56 | 57 | use Symfony\Component\DependencyInjection\ChildDefinition;
|
57 | 58 | use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
|
58 | 59 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
167 | 168 | use Symfony\Component\Translation\LocaleSwitcher;
|
168 | 169 | use Symfony\Component\Translation\PseudoLocalizationTranslator;
|
169 | 170 | use Symfony\Component\Translation\Translator;
|
| 171 | +use Symfony\Component\TypeInfo\Type; |
| 172 | +use Symfony\Component\TypeInfo\TypeResolver\StringTypeResolver; |
170 | 173 | use Symfony\Component\Uid\Factory\UuidFactory;
|
171 | 174 | use Symfony\Component\Uid\UuidV4;
|
172 | 175 | use Symfony\Component\Validator\Constraints\ExpressionLanguageProvider;
|
@@ -388,6 +391,10 @@ public function load(array $configs, ContainerBuilder $container): void
|
388 | 391 | $container->removeDefinition('console.command.serializer_debug');
|
389 | 392 | }
|
390 | 393 |
|
| 394 | + if ($this->readConfigEnabled('type_info', $container, $config['type_info'])) { |
| 395 | + $this->registerTypeInfoConfiguration($container, $loader); |
| 396 | + } |
| 397 | + |
391 | 398 | if ($propertyInfoEnabled) {
|
392 | 399 | $this->registerPropertyInfoConfiguration($container, $loader);
|
393 | 400 | }
|
@@ -1953,6 +1960,25 @@ private function registerPropertyInfoConfiguration(ContainerBuilder $container,
|
1953 | 1960 | }
|
1954 | 1961 | }
|
1955 | 1962 |
|
| 1963 | + private function registerTypeInfoConfiguration(ContainerBuilder $container, PhpFileLoader $loader): void |
| 1964 | + { |
| 1965 | + if (!class_exists(Type::class)) { |
| 1966 | + throw new LogicException('TypeInfo support cannot be enabled as the TypeInfo component is not installed. Try running "composer require symfony/type-info".'); |
| 1967 | + } |
| 1968 | + |
| 1969 | + $loader->load('type_info.php'); |
| 1970 | + |
| 1971 | + if (ContainerBuilder::willBeAvailable('phpstan/phpdoc-parser', PhpDocParser::class, ['symfony/framework-bundle', 'symfony/type-info'])) { |
| 1972 | + $container->register('type_info.resolver.string', StringTypeResolver::class); |
| 1973 | + |
| 1974 | + /** @var ServiceLocatorArgument $resolversLocator */ |
| 1975 | + $resolversLocator = $container->getDefinition('type_info.resolver')->getArgument(0); |
| 1976 | + $resolversLocator->setValues($resolversLocator->getValues() + [ |
| 1977 | + 'string' => new Reference('type_info.resolver.string'), |
| 1978 | + ]); |
| 1979 | + } |
| 1980 | + } |
| 1981 | + |
1956 | 1982 | private function registerLockConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader): void
|
1957 | 1983 | {
|
1958 | 1984 | $loader->load('lock.php');
|
|
0 commit comments