diff --git a/DependencyInjection/TranslationExtension.php b/DependencyInjection/TranslationExtension.php index b7c1aab0..11ed972e 100644 --- a/DependencyInjection/TranslationExtension.php +++ b/DependencyInjection/TranslationExtension.php @@ -42,6 +42,8 @@ class TranslationExtension extends Extension */ public function load(array $configs, ContainerBuilder $container): void { + $container->setParameter('extractor_vendor_dir', $this->getExtractorVendorDirectory()); + $configuration = new Configuration($container); $config = $this->processConfiguration($configuration, $configs); $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); @@ -232,4 +234,11 @@ public function getConfiguration(array $config, ContainerBuilder $container): Co { return new Configuration($container); } + + private function getExtractorVendorDirectory(): string + { + $vendorReflection = new \ReflectionClass(FormTypeChoices::class); + + return \dirname($vendorReflection->getFileName(), 4); + } } diff --git a/Resources/config/extractors.yaml b/Resources/config/extractors.yaml index 0f254dc3..54cf5fe4 100644 --- a/Resources/config/extractors.yaml +++ b/Resources/config/extractors.yaml @@ -1,111 +1,76 @@ services: - Translation\Extractor\FileExtractor\PHPFileExtractor: - tags: - - { name: 'php_translation.extractor', type: 'php' } + _defaults: + autowire: true + bind: + $metadataFactory: '@validator' - Translation\Extractor\FileExtractor\TwigFileExtractor: - arguments: ["@twig"] - tags: - - { name: 'php_translation.extractor', type: 'twig' } + _instanceof: + PhpParser\NodeVisitor: + tags: + - { name: 'php_translation.visitor', type: 'php' } - # PHP Visitors: - Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTrans: - tags: - - { name: 'php_translation.visitor', type: 'php' } + Translation\Extractor\FileExtractor\PHPFileExtractor: + tags: + - { name: 'php_translation.extractor', type: 'php' } - Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTransChoice: - tags: - - { name: 'php_translation.visitor', type: 'php' } + Translation\Extractor\FileExtractor\TwigFileExtractor: + tags: + - { name: 'php_translation.extractor', type: 'twig' } - Translation\Extractor\Visitor\Php\Symfony\FlashMessage: - tags: - - { name: 'php_translation.visitor', type: 'php' } + # PHP Visitors: + Translation\Extractor\Visitor\Php\Symfony\: + resource: "%extractor_vendor_dir%/Visitor/Php/Symfony/*" - Translation\Extractor\Visitor\Php\Symfony\FormTypeChoices: - tags: - - { name: 'php_translation.visitor', type: 'php' } + Translation\Extractor\Visitor\Php\SourceLocationContainerVisitor: ~ - Translation\Extractor\Visitor\Php\Symfony\FormTypeEmptyValue: - tags: - - { name: 'php_translation.visitor', type: 'php' } + # Twig Visitors: + Translation\Extractor\Visitor\Twig\TwigVisitor: + tags: + - { name: 'php_translation.visitor', type: 'twig' } - Translation\Extractor\Visitor\Php\Symfony\FormTypeHelp: - tags: - - { name: 'php_translation.visitor', type: 'php' } - - Translation\Extractor\Visitor\Php\Symfony\FormTypeInvalidMessage: - tags: - - { name: 'php_translation.visitor', type: 'php' } - - Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelExplicit: - tags: - - { name: 'php_translation.visitor', type: 'php' } - - Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelImplicit: - tags: - - { name: 'php_translation.visitor', type: 'php' } - - Translation\Extractor\Visitor\Php\Symfony\FormTypePlaceholder: - tags: - - { name: 'php_translation.visitor', type: 'php' } - - Translation\Extractor\Visitor\Php\Symfony\ValidationAnnotation: - arguments: ['@validator'] - tags: - - { name: 'php_translation.visitor', type: 'php' } - - Translation\Extractor\Visitor\Php\SourceLocationContainerVisitor: - tags: - - { name: 'php_translation.visitor', type: 'php' } - - # Twig Visitors: - Translation\Extractor\Visitor\Twig\TwigVisitor: - tags: - - { name: 'php_translation.visitor', type: 'twig' } - - # To remove in next major release - php_translation.extractor.php: - parent: Translation\Extractor\FileExtractor\PHPFileExtractor - deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' - php_translation.extractor.twig: - parent: Translation\Extractor\FileExtractor\TwigFileExtractor - deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' - php_translation.extractor.php.visitor.ContainerAwareTrans: - parent: Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTrans - deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' - php_translation.extractor.php.visitor.ContainerAwareTransChoice: - parent: Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTransChoice - deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' - php_translation.extractor.php.visitor.FlashMessage: - parent: Translation\Extractor\Visitor\Php\Symfony\FlashMessage - deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' - php_translation.extractor.php.visitor.FormTypeChoices: - parent: Translation\Extractor\Visitor\Php\Symfony\FormTypeChoices - deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' - php_translation.extractor.php.visitor.FormTypeEmptyValue: - parent: Translation\Extractor\Visitor\Php\Symfony\FormTypeEmptyValue - deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' - php_translation.extractor.php.visitor.FormTypeHelp: - parent: Translation\Extractor\Visitor\Php\Symfony\FormTypeHelp - deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' - php_translation.extractor.php.visitor.FormTypeInvalidMessage: - parent: Translation\Extractor\Visitor\Php\Symfony\FormTypeInvalidMessage - deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' - php_translation.extractor.php.visitor.FormTypeLabelExplicit: - parent: Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelExplicit - deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' - php_translation.extractor.php.visitor.FormTypeLabelImplicit: - parent: Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelImplicit - deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' - php_translation.extractor.php.visitor.FormTypePlaceholder: - parent: Translation\Extractor\Visitor\Php\Symfony\FormTypePlaceholder - deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' - php_translation.extractor.php.visitor.ValidationAnnotation: - parent: Translation\Extractor\Visitor\Php\Symfony\ValidationAnnotation - deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' - php_translation.extractor.php.visitor.SourceLocationContainerVisitor: - parent: Translation\Extractor\Visitor\Php\SourceLocationContainerVisitor - deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' - php_translation.extractor.twig.factory.twig: - parent: Translation\Extractor\Visitor\Twig\TwigVisitor - deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.' + # To remove in next major release + php_translation.extractor.php: + alias: Translation\Extractor\FileExtractor\PHPFileExtractor + deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' + php_translation.extractor.twig: + alias: Translation\Extractor\FileExtractor\TwigFileExtractor + deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' + php_translation.extractor.php.visitor.ContainerAwareTrans: + alias: Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTrans + deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' + php_translation.extractor.php.visitor.ContainerAwareTransChoice: + alias: Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTransChoice + deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' + php_translation.extractor.php.visitor.FlashMessage: + alias: Translation\Extractor\Visitor\Php\Symfony\FlashMessage + deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' + php_translation.extractor.php.visitor.FormTypeChoices: + alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeChoices + deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' + php_translation.extractor.php.visitor.FormTypeEmptyValue: + alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeEmptyValue + deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' + php_translation.extractor.php.visitor.FormTypeHelp: + alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeHelp + deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' + php_translation.extractor.php.visitor.FormTypeInvalidMessage: + alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeInvalidMessage + deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' + php_translation.extractor.php.visitor.FormTypeLabelExplicit: + alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelExplicit + deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' + php_translation.extractor.php.visitor.FormTypeLabelImplicit: + alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelImplicit + deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' + php_translation.extractor.php.visitor.FormTypePlaceholder: + alias: Translation\Extractor\Visitor\Php\Symfony\FormTypePlaceholder + deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' + php_translation.extractor.php.visitor.ValidationAnnotation: + alias: Translation\Extractor\Visitor\Php\Symfony\ValidationAnnotation + deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' + php_translation.extractor.php.visitor.SourceLocationContainerVisitor: + alias: Translation\Extractor\Visitor\Php\SourceLocationContainerVisitor + deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' + php_translation.extractor.twig.factory.twig: + alias: Translation\Extractor\Visitor\Twig\TwigVisitor + deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.' diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e26ad678..be1f1d6d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -25,11 +25,6 @@ parameters: count: 1 path: Command/StatusCommand.php - - - message: "#^Call to method getValue\\(\\) on an unknown class Symfony\\\\Component\\\\Translation\\\\DataCollector\\\\Data\\.$#" - count: 1 - path: Controller/SymfonyProfilerController.php - - message: "#^Call to an undefined static method Symfony\\\\Component\\\\Intl\\\\Intl\\:\\:getLocaleBundle\\(\\)\\.$#" count: 1