@@ -149,8 +149,18 @@ public function postUpdate(Event $event)
149149 $ composer ->getPackage ()->getRequires (),
150150 $ composer ->getPackage ()->getDevRequires (),
151151 ];
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+ }
152162
153- $ missingRequires = $ this ->getMissingRequires ($ repo , $ requires , 'project ' === $ composer ->getPackage ()->getType ());
163+ $ missingRequires = $ this ->getMissingRequires ($ repo , $ requires , 'project ' === $ composer ->getPackage ()->getType (), $ pinnedAbstractions );
154164 $ missingRequires = [
155165 'require ' => array_fill_keys (array_merge ([], ...array_values ($ missingRequires [0 ])), '* ' ),
156166 'require-dev ' => array_fill_keys (array_merge ([], ...array_values ($ missingRequires [1 ])), '* ' ),
@@ -229,7 +239,7 @@ public function postUpdate(Event $event)
229239 }
230240 }
231241
232- public function getMissingRequires (InstalledRepositoryInterface $ repo , array $ requires , bool $ isProject ): array
242+ public function getMissingRequires (InstalledRepositoryInterface $ repo , array $ requires , bool $ isProject, array $ pinnedAbstractions ): array
233243 {
234244 $ allPackages = [];
235245 $ devPackages = method_exists ($ repo , 'getDevPackageNames ' ) ? array_fill_keys ($ repo ->getDevPackageNames (), true ) : [];
@@ -269,7 +279,14 @@ public function getMissingRequires(InstalledRepositoryInterface $repo, array $re
269279 $ rules = array_intersect_key (self ::PROVIDE_RULES , $ rules );
270280
271281 while ($ rules ) {
272- $ 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 ;
273290
274291 foreach (array_shift ($ rules ) as $ candidate => $ deps ) {
275292 [$ candidate , $ version ] = explode (': ' , $ candidate , 2 ) + [1 => null ];
0 commit comments