@@ -27,41 +27,44 @@ public function loadConfiguration(): void
2727 return ;
2828 }
2929
30+ $ newExcludePaths = [];
31+ if (array_key_exists ('analyseAndScan ' , $ excludePaths )) {
32+ $ newExcludePaths ['analyseAndScan ' ] = $ excludePaths ['analyseAndScan ' ];
33+ }
34+ if (array_key_exists ('analyse ' , $ excludePaths )) {
35+ $ newExcludePaths ['analyse ' ] = $ excludePaths ['analyse ' ];
36+ }
37+
3038 $ errors = [];
39+ $ suggestOptional = [];
3140 if ($ builder ->parameters ['__validate ' ]) {
32- $ paths = [];
33- if (array_key_exists ('analyse ' , $ excludePaths )) {
34- $ paths = $ excludePaths ['analyse ' ];
35- }
36- if (array_key_exists ('analyseAndScan ' , $ excludePaths )) {
37- $ paths = array_merge ($ paths , $ excludePaths ['analyseAndScan ' ]);
38- }
39- foreach ($ paths as $ path ) {
40- if ($ path instanceof OptionalPath) {
41- continue ;
42- }
43- if (FileExcluder::isAbsolutePath ($ path )) {
44- if (is_dir ($ path )) {
41+ foreach ($ newExcludePaths as $ key => $ paths ) {
42+ foreach ($ paths as $ path ) {
43+ if ($ path instanceof OptionalPath) {
4544 continue ;
4645 }
47- if (is_file ($ path )) {
46+ if (FileExcluder::isAbsolutePath ($ path )) {
47+ if (is_dir ($ path )) {
48+ continue ;
49+ }
50+ if (is_file ($ path )) {
51+ continue ;
52+ }
53+
54+ $ suggestOptional [$ key ][] = $ path ;
55+ }
56+ if (FileExcluder::isFnmatchPattern ($ path )) {
4857 continue ;
4958 }
50- }
51- if (FileExcluder::isFnmatchPattern ($ path )) {
52- continue ;
53- }
5459
55- $ errors [] = sprintf ('Path %s is neither a directory, nor a file path, nor a fnmatch pattern. ' , $ path );
60+ $ errors [] = sprintf ('Path %s is neither a directory, nor a file path, nor a fnmatch pattern. ' , $ path );
61+ }
5662 }
5763 }
5864
59- $ newExcludePaths = [];
60- if (array_key_exists ('analyseAndScan ' , $ excludePaths )) {
61- $ newExcludePaths ['analyseAndScan ' ] = $ excludePaths ['analyseAndScan ' ];
62- }
63- if (array_key_exists ('analyse ' , $ excludePaths )) {
64- $ newExcludePaths ['analyse ' ] = $ excludePaths ['analyse ' ];
65+
66+ if (count ($ errors ) !== 0 ) {
67+ throw new InvalidExcludePathsException ($ errors , $ suggestOptional );
6568 }
6669
6770 foreach ($ newExcludePaths as $ key => $ p ) {
@@ -72,12 +75,6 @@ public function loadConfiguration(): void
7275 }
7376
7477 $ builder ->parameters ['excludePaths ' ] = $ newExcludePaths ;
75-
76- if (count ($ errors ) === 0 ) {
77- return ;
78- }
79-
80- throw new InvalidExcludePathsException ($ errors );
8178 }
8279
8380}
0 commit comments