@@ -45,13 +45,15 @@ class Plugin implements PluginInterface, EventSubscriberInterface
45
45
*/
46
46
private const PROVIDE_RULES = [
47
47
'php-http/async-client-implementation ' => [
48
+ 'symfony/http-client:>=6.3 ' => ['guzzlehttp/promises ' , 'psr/http-factory-implementation ' ],
48
49
'symfony/http-client ' => ['guzzlehttp/promises ' , 'php-http/message-factory ' , 'psr/http-factory-implementation ' ],
49
50
'php-http/guzzle7-adapter ' => [],
50
51
'php-http/guzzle6-adapter ' => [],
51
52
'php-http/curl-client ' => [],
52
53
'php-http/react-adapter ' => [],
53
54
],
54
55
'php-http/client-implementation ' => [
56
+ 'symfony/http-client:>=6.3 ' => ['psr/http-factory-implementation ' ],
55
57
'symfony/http-client ' => ['php-http/message-factory ' , 'psr/http-factory-implementation ' ],
56
58
'php-http/guzzle7-adapter ' => [],
57
59
'php-http/guzzle6-adapter ' => [],
@@ -147,8 +149,18 @@ public function postUpdate(Event $event)
147
149
$ composer ->getPackage ()->getRequires (),
148
150
$ composer ->getPackage ()->getDevRequires (),
149
151
];
152
+ $ pinnedAbstractions = [];
153
+ $ pinned = $ composer ->getPackage ()->getExtra ()['discovery ' ] ?? [];
154
+ foreach (self ::INTERFACE_MAP as $ abstraction => $ interfaces ) {
155
+ foreach (isset ($ pinned [$ abstraction ]) ? [] : $ interfaces as $ interface ) {
156
+ if (!isset ($ pinned [$ interface ])) {
157
+ continue 2 ;
158
+ }
159
+ }
160
+ $ pinnedAbstractions [$ abstraction ] = true ;
161
+ }
150
162
151
- $ missingRequires = $ this ->getMissingRequires ($ repo , $ requires , 'project ' === $ composer ->getPackage ()->getType ());
163
+ $ missingRequires = $ this ->getMissingRequires ($ repo , $ requires , 'project ' === $ composer ->getPackage ()->getType (), $ pinnedAbstractions );
152
164
$ missingRequires = [
153
165
'require ' => array_fill_keys (array_merge ([], ...array_values ($ missingRequires [0 ])), '* ' ),
154
166
'require-dev ' => array_fill_keys (array_merge ([], ...array_values ($ missingRequires [1 ])), '* ' ),
@@ -227,7 +239,7 @@ public function postUpdate(Event $event)
227
239
}
228
240
}
229
241
230
- public function getMissingRequires (InstalledRepositoryInterface $ repo , array $ requires , bool $ isProject ): array
242
+ public function getMissingRequires (InstalledRepositoryInterface $ repo , array $ requires , bool $ isProject, array $ pinnedAbstractions ): array
231
243
{
232
244
$ allPackages = [];
233
245
$ devPackages = method_exists ($ repo , 'getDevPackageNames ' ) ? array_fill_keys ($ repo ->getDevPackageNames (), true ) : [];
@@ -267,7 +279,14 @@ public function getMissingRequires(InstalledRepositoryInterface $repo, array $re
267
279
$ rules = array_intersect_key (self ::PROVIDE_RULES , $ rules );
268
280
269
281
while ($ rules ) {
270
- $ abstractions [] = $ abstraction = key ($ rules );
282
+ $ abstraction = key ($ rules );
283
+
284
+ if (isset ($ pinnedAbstractions [$ abstraction ])) {
285
+ unset($ rules [$ abstraction ]);
286
+ continue ;
287
+ }
288
+
289
+ $ abstractions [] = $ abstraction ;
271
290
272
291
foreach (array_shift ($ rules ) as $ candidate => $ deps ) {
273
292
[$ candidate , $ version ] = explode (': ' , $ candidate , 2 ) + [1 => null ];
@@ -332,22 +351,12 @@ public function getMissingRequires(InstalledRepositoryInterface $repo, array $re
332
351
}
333
352
334
353
$ dep = key ($ candidates );
354
+ [$ dep ] = explode (': ' , $ dep , 2 );
335
355
$ missingRequires [$ dev ][$ abstraction ] = [$ dep ];
336
356
337
357
if ($ isProject && !$ dev && isset ($ devPackages [$ dep ])) {
338
358
$ missingRequires [2 ][$ abstraction ][] = $ dep ;
339
359
}
340
-
341
- foreach (current ($ candidates ) as $ dep ) {
342
- if (isset (self ::PROVIDE_RULES [$ dep ])) {
343
- $ abstractions [] = $ dep ;
344
- } elseif (!isset ($ allPackages [$ dep ])) {
345
- $ missingRequires [$ dev ][$ abstraction ][] = $ dep ;
346
- } elseif ($ isProject && !$ dev && isset ($ devPackages [$ dep ])) {
347
- $ missingRequires [0 ][$ abstraction ][] = $ dep ;
348
- $ missingRequires [2 ][$ abstraction ][] = $ dep ;
349
- }
350
- }
351
360
}
352
361
}
353
362
0 commit comments