|
48 | 48 | * @author Daniel Espendiller <[email protected]>
|
49 | 49 | */
|
50 | 50 | public class ServiceUtil {
|
51 |
| - private static ServiceNameStrategyInterface[] NAME_STRATEGIES = new ServiceNameStrategyInterface[] { |
| 51 | + private static final ServiceNameStrategyInterface[] NAME_STRATEGIES = new ServiceNameStrategyInterface[] { |
52 | 52 | new JavascriptServiceNameStrategy(),
|
53 | 53 | new DefaultServiceNameStrategy(),
|
54 | 54 | };
|
55 | 55 |
|
56 |
| - public static final Map<String , String> TAG_INTERFACES = new HashMap<String , String>() {{ |
57 |
| - put("assetic.asset", "\\Assetic\\Filter\\FilterInterface"); |
58 |
| - put("assetic.factory_worker", "\\Assetic\\Factory\\Worker\\WorkerInterface"); |
59 |
| - put("assetic.filter", "\\Assetic\\Filter\\FilterInterface"); |
60 |
| - put("assetic.formula_loader", "\\Assetic\\Factory\\Loader\\FormulaLoaderInterface"); |
61 |
| - put("assetic.formula_resource", null); |
62 |
| - put("assetic.templating.php", null); |
63 |
| - put("assetic.templating.twig", null); |
64 |
| - put("console.command", "\\Symfony\\Component\\Console\\Command\\Command"); |
65 |
| - put("data_collector", "\\Symfony\\Component\\HttpKernel\\DataCollector\\DataCollectorInterface"); |
66 |
| - put("doctrine.event_listener", null); |
67 |
| - put("doctrine.event_subscriber", null); |
68 |
| - put("form.type", "\\Symfony\\Component\\Form\\FormTypeInterface"); |
69 |
| - put("form.type_extension", "\\Symfony\\Component\\Form\\FormTypeExtensionInterface"); |
70 |
| - put("form.type_guesser", "\\Symfony\\Component\\Form\\FormTypeGuesserInterface"); |
71 |
| - put("kernel.cache_clearer", null); |
72 |
| - put("kernel.cache_warmer", "\\Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmerInterface"); |
73 |
| - put("kernel.event_subscriber", "\\Symfony\\Component\\EventDispatcher\\EventSubscriberInterface"); |
74 |
| - put("kernel.fragment_renderer", "\\Symfony\\Component\\HttpKernel\\Fragment\\FragmentRendererInterface"); |
75 |
| - put("monolog.logger", null); |
76 |
| - put("monolog.processor", null); |
77 |
| - put("routing.loader", "\\Symfony\\Component\\Config\\Loader\\LoaderInterface"); |
| 56 | + public static final Map<String , String[]> TAG_INTERFACES = new HashMap<>() {{ |
| 57 | + put("assetic.asset", new String[]{"\\Assetic\\Filter\\FilterInterface"}); |
| 58 | + put("assetic.factory_worker", new String[]{"\\Assetic\\Factory\\Worker\\WorkerInterface"}); |
| 59 | + put("assetic.filter", new String[]{"\\Assetic\\Filter\\FilterInterface"}); |
| 60 | + put("assetic.formula_loader", new String[]{"\\Assetic\\Factory\\Loader\\FormulaLoaderInterface"}); |
| 61 | + put("assetic.formula_resource", new String[] {}); |
| 62 | + put("assetic.templating.php", new String[] {}); |
| 63 | + put("assetic.templating.twig", new String[] {}); |
| 64 | + put("console.command", new String[]{"\\Symfony\\Component\\Console\\Command\\Command"}); |
| 65 | + put("data_collector", new String[]{"\\Symfony\\Component\\HttpKernel\\DataCollector\\DataCollectorInterface"}); |
| 66 | + put("doctrine.event_listener", new String[] {}); |
| 67 | + put("doctrine.event_subscriber", new String[] {}); |
| 68 | + put("form.type", new String[]{"\\Symfony\\Component\\Form\\FormTypeInterface"}); |
| 69 | + put("form.type_extension", new String[]{"\\Symfony\\Component\\Form\\FormTypeExtensionInterface"}); |
| 70 | + put("form.type_guesser", new String[]{"\\Symfony\\Component\\Form\\FormTypeGuesserInterface"}); |
| 71 | + put("kernel.cache_clearer", new String[] {}); |
| 72 | + put("kernel.cache_warmer", new String[]{"\\Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmerInterface"}); |
| 73 | + put("kernel.event_subscriber", new String[]{"\\Symfony\\Component\\EventDispatcher\\EventSubscriberInterface"}); |
| 74 | + put("kernel.fragment_renderer", new String[]{"\\Symfony\\Component\\HttpKernel\\Fragment\\FragmentRendererInterface"}); |
| 75 | + put("monolog.logger", new String[] {}); |
| 76 | + put("monolog.processor", new String[] {}); |
| 77 | + put("routing.loader", new String[]{"\\Symfony\\Component\\Config\\Loader\\LoaderInterface"}); |
78 | 78 | //put("security.remember_me_aware", null);
|
79 |
| - put("security.voter", "\\Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface"); |
80 |
| - put("serializer.encoder", "\\Symfony\\Component\\Serializer\\Encoder\\EncoderInterface"); |
81 |
| - put("serializer.normalizer", "\\Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface"); |
| 79 | + put("security.voter", new String[]{"\\Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface"}); |
| 80 | + put("serializer.encoder", new String[]{"\\Symfony\\Component\\Serializer\\Encoder\\EncoderInterface"}); |
| 81 | + put("serializer.normalizer", new String[]{"\\Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface"}); |
82 | 82 | // Symfony\Component\Serializer\Normalizer\DenormalizerInterface
|
83 |
| - put("swiftmailer.default.plugin", "\\Swift_Events_EventListener"); |
84 |
| - put("templating.helper", "\\Symfony\\Component\\Templating\\Helper\\HelperInterface"); |
85 |
| - put("translation.loader", "\\Symfony\\Component\\Translation\\Loader\\LoaderInterface"); |
86 |
| - put("translation.extractor", "\\Symfony\\Component\\Translation\\Extractor\\ExtractorInterface"); |
87 |
| - put("translation.dumper", "\\Symfony\\Component\\Translation\\Dumper\\DumperInterface"); |
88 |
| - put("twig.extension", "\\Twig_ExtensionInterface"); |
89 |
| - put("twig.loader", "\\Twig_LoaderInterface"); |
90 |
| - put("validator.constraint_validator", "Symfony\\Component\\Validator\\ConstraintValidator"); |
91 |
| - put("validator.initializer", "Symfony\\Component\\Validator\\ObjectInitializerInterface"); |
| 83 | + put("swiftmailer.default.plugin", new String[]{"\\Swift_Events_EventListener"}); |
| 84 | + put("templating.helper", new String[]{"\\Symfony\\Component\\Templating\\Helper\\HelperInterface"}); |
| 85 | + put("translation.loader", new String[]{"\\Symfony\\Component\\Translation\\Loader\\LoaderInterface"}); |
| 86 | + put("translation.extractor", new String[]{"\\Symfony\\Component\\Translation\\Extractor\\ExtractorInterface"}); |
| 87 | + put("translation.dumper", new String[]{"\\Symfony\\Component\\Translation\\Dumper\\DumperInterface"}); |
| 88 | + put("twig.extension", new String[]{"\\Twig\\Extension\\ExtensionInterface", "\\Twig_ExtensionInterface"}); |
| 89 | + put("twig.loader", new String[]{"\\Twig\\Loader\\LoaderInterface", "\\Twig_LoaderInterface"}); |
| 90 | + put("validator.constraint_validator", new String[]{"Symfony\\Component\\Validator\\ConstraintValidator"}); |
| 91 | + put("validator.initializer", new String[]{"Symfony\\Component\\Validator\\ObjectInitializerInterface"}); |
92 | 92 |
|
93 | 93 | // 2.6 - @TODO: how to handle duplicate interfaces; also make them weaker
|
94 |
| - put("routing.expression_language_provider", "\\Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface"); |
95 |
| - put("security.expression_language_provider", "\\Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface"); |
| 94 | + put("routing.expression_language_provider", new String[]{"\\Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface"}); |
| 95 | + put("security.expression_language_provider", new String[]{"\\Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface"}); |
96 | 96 |
|
97 |
| - put("controller.service_arguments", null); |
| 97 | + put("controller.service_arguments", new String[] {}); |
98 | 98 | }};
|
99 | 99 |
|
100 | 100 | /**
|
@@ -427,19 +427,14 @@ public static PhpClass getServiceClass(@NotNull Project project, @NotNull String
|
427 | 427 | */
|
428 | 428 | @NotNull
|
429 | 429 | public static Set<String> getPhpClassServiceTags(@NotNull PhpClass phpClass) {
|
430 |
| - |
431 | 430 | Set<String> tags = new HashSet<>();
|
432 | 431 |
|
433 |
| - for (Map.Entry<String, String> entry : TAG_INTERFACES.entrySet()) { |
434 |
| - |
435 |
| - if(entry.getValue() == null) { |
436 |
| - continue; |
437 |
| - } |
438 |
| - |
439 |
| - if(PhpElementsUtil.isInstanceOf(phpClass, entry.getValue())) { |
440 |
| - tags.add(entry.getKey()); |
| 432 | + for (Map.Entry<String, String[]> entry : TAG_INTERFACES.entrySet()) { |
| 433 | + for (String s : entry.getValue()) { |
| 434 | + if(PhpElementsUtil.isInstanceOf(phpClass, s)) { |
| 435 | + tags.add(entry.getKey()); |
| 436 | + } |
441 | 437 | }
|
442 |
| - |
443 | 438 | }
|
444 | 439 |
|
445 | 440 | // strong tags wins
|
|
0 commit comments