@@ -88,8 +88,20 @@ protected function execute(InputInterface $input, OutputInterface $output)
88
88
}
89
89
$ data ['tests ' ] = array_keys ($ data ['tests ' ]);
90
90
$ data ['loader_paths ' ] = $ this ->getLoaderPaths ();
91
+ if ($ wrongBundles = $ this ->findWrongBundleOverrides ()) {
92
+ $ messages = $ this ->buildWarningMessages ($ wrongBundles );
93
+ $ data ['warnings ' ] = array_reduce (
94
+ $ messages ,
95
+ function ($ carry , $ message ) {
96
+ $ carry [] = $ message ;
97
+
98
+ return $ carry ;
99
+ },
100
+ array ()
101
+ );
102
+ }
103
+
91
104
$ io ->writeln (json_encode ($ data ));
92
- $ this ->displayAlternatives ($ this ->findWrongBundleOverrides (), $ io );
93
105
94
106
return 0 ;
95
107
}
@@ -130,7 +142,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
130
142
array_pop ($ rows );
131
143
$ io ->section ('Loader Paths ' );
132
144
$ io ->table (array ('Namespace ' , 'Paths ' ), $ rows );
133
- $ this ->displayAlternatives ($ this ->findWrongBundleOverrides (), $ io );
145
+ $ messages = $ this ->buildWarningMessages ($ this ->findWrongBundleOverrides ());
146
+ array_walk (
147
+ $ messages ,
148
+ function ($ message ) use ($ io ) {
149
+ $ io ->warning (trim ($ message ));
150
+ }
151
+ );
134
152
135
153
return 0 ;
136
154
}
@@ -293,13 +311,12 @@ function ($carry, $absolutePath) use ($relativePath) {
293
311
}
294
312
295
313
if (\count ($ bundleNames )) {
296
- $ loadedBundles = $ this ->bundlesMetadata ;
297
- $ notFoundBundles = array_diff_key ($ bundleNames , $ loadedBundles );
314
+ $ notFoundBundles = array_diff_key ($ bundleNames , $ this ->bundlesMetadata );
298
315
if (\count ($ notFoundBundles )) {
299
316
$ alternatives = array ();
300
317
foreach ($ notFoundBundles as $ notFoundBundle => $ path ) {
301
318
$ alternatives [$ path ] = array ();
302
- foreach ($ loadedBundles as $ name => $ bundle ) {
319
+ foreach ($ this -> bundlesMetadata as $ name => $ bundle ) {
303
320
$ lev = levenshtein ($ notFoundBundle , $ name );
304
321
if ($ lev <= \strlen ($ notFoundBundle ) / 3 || false !== strpos ($ name , $ notFoundBundle )) {
305
322
$ alternatives [$ path ][] = $ name ;
@@ -312,8 +329,9 @@ function ($carry, $absolutePath) use ($relativePath) {
312
329
return $ alternatives ;
313
330
}
314
331
315
- private function displayAlternatives (array $ wrongBundles, SymfonyStyle $ io ): void
332
+ private function buildWarningMessages (array $ wrongBundles ): array
316
333
{
334
+ $ messages = array ();
317
335
foreach ($ wrongBundles as $ path => $ alternatives ) {
318
336
$ message = sprintf ('Path "%s" not matching any bundle found ' , $ path );
319
337
if ($ alternatives ) {
@@ -326,7 +344,9 @@ private function displayAlternatives(array $wrongBundles, SymfonyStyle $io): voi
326
344
}
327
345
}
328
346
}
329
- $ io -> warning ( trim ( $ message)) ;
347
+ $ messages [] = $ message ;
330
348
}
349
+
350
+ return $ messages ;
331
351
}
332
352
}
0 commit comments