21
21
*/
22
22
class UnusedTagsPass implements CompilerPassInterface
23
23
{
24
+ public function process (ContainerBuilder $ container ): void
25
+ {
26
+ $ tags = array_unique (array_merge ($ container ->findTags (), self ::KNOWN_TAGS ));
27
+
28
+ foreach ($ container ->findUnusedTags () as $ tag ) {
29
+ // skip known tags
30
+ if (\in_array ($ tag , self ::KNOWN_TAGS , true )) {
31
+ continue ;
32
+ }
33
+
34
+ // check for typos
35
+ $ candidates = [];
36
+ foreach ($ tags as $ definedTag ) {
37
+ if ($ definedTag === $ tag ) {
38
+ continue ;
39
+ }
40
+
41
+ if (str_contains ($ definedTag , $ tag ) || levenshtein ($ tag , $ definedTag ) <= \strlen ($ tag ) / 3 ) {
42
+ $ candidates [] = $ definedTag ;
43
+ }
44
+ }
45
+
46
+ $ services = array_keys ($ container ->findTaggedServiceIds ($ tag ));
47
+ $ message = sprintf ('Tag "%s" was defined on service(s) "%s", but was never used. ' , $ tag , implode ('", " ' , $ services ));
48
+ if ($ candidates ) {
49
+ $ message .= sprintf (' Did you mean "%s"? ' , implode ('", " ' , $ candidates ));
50
+ }
51
+
52
+ $ container ->log ($ this , $ message );
53
+ }
54
+ }
55
+
24
56
private const KNOWN_TAGS = [
57
+ 'annotations.cached_reader ' ,
25
58
'asset_mapper.compiler ' ,
26
59
'assets.package ' ,
27
60
'auto_alias ' ,
@@ -31,6 +64,7 @@ class UnusedTagsPass implements CompilerPassInterface
31
64
'chatter.transport_factory ' ,
32
65
'config_cache.resource_checker ' ,
33
66
'console.command ' ,
67
+ 'container.do_not_inline ' ,
34
68
'container.env_var_loader ' ,
35
69
'container.env_var_processor ' ,
36
70
'container.excluded ' ,
@@ -82,6 +116,7 @@ class UnusedTagsPass implements CompilerPassInterface
82
116
'routing.route_loader ' ,
83
117
'scheduler.schedule_provider ' ,
84
118
'scheduler.task ' ,
119
+ 'security.access_token_handler.oidc.signature_algorithm ' ,
85
120
'security.authenticator.login_linker ' ,
86
121
'security.expression_language_provider ' ,
87
122
'security.remember_me_handler ' ,
@@ -103,36 +138,4 @@ class UnusedTagsPass implements CompilerPassInterface
103
138
'validator.initializer ' ,
104
139
'workflow ' ,
105
140
];
106
-
107
- public function process (ContainerBuilder $ container ): void
108
- {
109
- $ tags = array_unique (array_merge ($ container ->findTags (), self ::KNOWN_TAGS ));
110
-
111
- foreach ($ container ->findUnusedTags () as $ tag ) {
112
- // skip known tags
113
- if (\in_array ($ tag , self ::KNOWN_TAGS , true )) {
114
- continue ;
115
- }
116
-
117
- // check for typos
118
- $ candidates = [];
119
- foreach ($ tags as $ definedTag ) {
120
- if ($ definedTag === $ tag ) {
121
- continue ;
122
- }
123
-
124
- if (str_contains ($ definedTag , $ tag ) || levenshtein ($ tag , $ definedTag ) <= \strlen ($ tag ) / 3 ) {
125
- $ candidates [] = $ definedTag ;
126
- }
127
- }
128
-
129
- $ services = array_keys ($ container ->findTaggedServiceIds ($ tag ));
130
- $ message = sprintf ('Tag "%s" was defined on service(s) "%s", but was never used. ' , $ tag , implode ('", " ' , $ services ));
131
- if ($ candidates ) {
132
- $ message .= sprintf (' Did you mean "%s"? ' , implode ('", " ' , $ candidates ));
133
- }
134
-
135
- $ container ->log ($ this , $ message );
136
- }
137
- }
138
141
}
0 commit comments