File tree Expand file tree Collapse file tree 2 files changed +17
-11
lines changed
Expand file tree Collapse file tree 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
8989 return '' ;
9090 }
9191
92- public static function getMergedExtra (?string $ key = null )
92+ public static function getMergedExtra (?string $ key = null ): array
9393 {
9494 if (! self ::$ extra ) {
9595 self ::getLockContent ();
@@ -101,16 +101,16 @@ public static function getMergedExtra(?string $key = null)
101101
102102 $ extra = [];
103103
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 ;
114114 }
115115 }
116116 }
Original file line number Diff line number Diff line change @@ -36,4 +36,10 @@ public function testHasPackage()
3636 $ this ->assertTrue (Composer::hasPackage ('hyperf/framework ' ));
3737 $ this ->assertFalse (Composer::hasPackage ('composer/unknown ' ));
3838 }
39+
40+ public function testGetMergedExtra ()
41+ {
42+ $ providers = Composer::getMergedExtra ('hyperf ' )['config ' ] ?? [];
43+ $ this ->assertNotEmpty ($ providers );
44+ }
3945}
You can’t perform that action at this time.
0 commit comments