@@ -28,7 +28,37 @@ public function initialize(): IgnoredErrorHelperResult
2828 $ otherIgnoreErrors = [];
2929 $ ignoreErrorsByFile = [];
3030 $ errors = [];
31- foreach ($ this ->ignoreErrors as $ i => $ ignoreError ) {
31+
32+ $ expandedIgnoreErrors = [];
33+ foreach ($ this ->ignoreErrors as $ ignoreError ) {
34+ if (is_array ($ ignoreError )) {
35+ if (!isset ($ ignoreError ['message ' ]) && !isset ($ ignoreError ['messages ' ])) {
36+ $ errors [] = sprintf (
37+ 'Ignored error %s is missing a message. ' ,
38+ Json::encode ($ ignoreError ),
39+ );
40+ continue ;
41+ }
42+ if (isset ($ ignoreError ['messages ' ])) {
43+ foreach ($ ignoreError ['messages ' ] as $ message ) {
44+ $ expandedIgnoreError = $ ignoreError ;
45+ unset($ expandedIgnoreError ['messages ' ]);
46+ $ expandedIgnoreError ['message ' ] = $ message ;
47+ $ expandedIgnoreErrors [] = $ expandedIgnoreError ;
48+ }
49+ } else {
50+ $ expandedIgnoreErrors [] = $ ignoreError ;
51+ }
52+ } else {
53+ $ expandedIgnoreErrors [] = $ ignoreError ;
54+ }
55+ }
56+
57+ foreach ($ expandedIgnoreErrors as $ i => $ ignoreError ) {
58+ $ ignoreErrorEntry = [
59+ 'index ' => $ i ,
60+ 'ignoreError ' => $ ignoreError ,
61+ ];
3262 try {
3363 if (is_array ($ ignoreError )) {
3464 if (!isset ($ ignoreError ['message ' ])) {
@@ -39,44 +69,32 @@ public function initialize(): IgnoredErrorHelperResult
3969 continue ;
4070 }
4171 if (!isset ($ ignoreError ['path ' ])) {
42- if (!isset ($ ignoreError ['paths ' ])) {
72+ if (!isset ($ ignoreError ['paths ' ]) && ! isset ( $ ignoreError [ ' reportUnmatched ' ]) ) {
4373 $ errors [] = sprintf (
44- 'Ignored error %s is missing a path. ' ,
74+ 'Ignored error %s is missing a path, paths or reportUnmatched . ' ,
4575 Json::encode ($ ignoreError ),
4676 );
4777 }
4878
49- $ otherIgnoreErrors [] = [
50- 'index ' => $ i ,
51- 'ignoreError ' => $ ignoreError ,
52- ];
79+ $ otherIgnoreErrors [] = $ ignoreErrorEntry ;
5380 } elseif (@is_file ($ ignoreError ['path ' ])) {
5481 $ normalizedPath = $ this ->fileHelper ->normalizePath ($ ignoreError ['path ' ]);
5582 $ ignoreError ['path ' ] = $ normalizedPath ;
56- $ ignoreErrorsByFile [$ normalizedPath ][] = [
57- 'index ' => $ i ,
58- 'ignoreError ' => $ ignoreError ,
59- ];
83+ $ ignoreErrorsByFile [$ normalizedPath ][] = $ ignoreErrorEntry ;
6084 $ ignoreError ['realPath ' ] = $ normalizedPath ;
61- $ this -> ignoreErrors [$ i ] = $ ignoreError ;
85+ $ expandedIgnoreErrors [$ i ] = $ ignoreError ;
6286 } else {
63- $ otherIgnoreErrors [] = [
64- 'index ' => $ i ,
65- 'ignoreError ' => $ ignoreError ,
66- ];
87+ $ otherIgnoreErrors [] = $ ignoreErrorEntry ;
6788 }
6889 } else {
69- $ otherIgnoreErrors [] = [
70- 'index ' => $ i ,
71- 'ignoreError ' => $ ignoreError ,
72- ];
90+ $ otherIgnoreErrors [] = $ ignoreErrorEntry ;
7391 }
7492 } catch (JsonException $ e ) {
7593 $ errors [] = $ e ->getMessage ();
7694 }
7795 }
7896
79- return new IgnoredErrorHelperResult ($ this ->fileHelper , $ errors , $ otherIgnoreErrors , $ ignoreErrorsByFile , $ this -> ignoreErrors , $ this ->reportUnmatchedIgnoredErrors );
97+ return new IgnoredErrorHelperResult ($ this ->fileHelper , $ errors , $ otherIgnoreErrors , $ ignoreErrorsByFile , $ expandedIgnoreErrors , $ this ->reportUnmatchedIgnoredErrors );
8098 }
8199
82100}
0 commit comments