File tree 2 files changed +17
-11
lines changed
2 files changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ public static function discoverLockFile(): string
89
89
return '' ;
90
90
}
91
91
92
- public static function getMergedExtra (?string $ key = null )
92
+ public static function getMergedExtra (?string $ key = null ): array
93
93
{
94
94
if (! self ::$ extra ) {
95
95
self ::getLockContent ();
@@ -101,16 +101,16 @@ public static function getMergedExtra(?string $key = null)
101
101
102
102
$ extra = [];
103
103
104
- foreach (self ::$ extra as $ project => $ config ) {
105
- foreach ( $ config ?? [] as $ configKey => $ item ) {
106
- if ( $ key === $ configKey && $ item ) {
107
- foreach ( $ item as $ k => $ v ) {
108
- if ( is_array ( $ v )) {
109
- $ extra [ $ k ] = array_merge ( $ extra [ $ k ] ?? [], $ v );
110
- } else {
111
- $ extra [$ k ][] = $ v ;
112
- }
113
- }
104
+ foreach (self ::$ extra as $ config ) {
105
+ if (! isset ( $ config[ $ key ]) ) {
106
+ continue ;
107
+ }
108
+
109
+ foreach ( $ config [ $ key ] as $ k => $ v ) {
110
+ if ( is_array ( $ v )) {
111
+ $ extra [ $ k ] = array_merge ( $ extra [$ k ] ?? [], $ v ) ;
112
+ } else {
113
+ $ extra [ $ k ][] = $ v ;
114
114
}
115
115
}
116
116
}
Original file line number Diff line number Diff line change @@ -36,4 +36,10 @@ public function testHasPackage()
36
36
$ this ->assertTrue (Composer::hasPackage ('hyperf/framework ' ));
37
37
$ this ->assertFalse (Composer::hasPackage ('composer/unknown ' ));
38
38
}
39
+
40
+ public function testGetMergedExtra ()
41
+ {
42
+ $ providers = Composer::getMergedExtra ('hyperf ' )['config ' ] ?? [];
43
+ $ this ->assertNotEmpty ($ providers );
44
+ }
39
45
}
You can’t perform that action at this time.
0 commit comments