@@ -77,14 +77,12 @@ class Flex implements PluginInterface, EventSubscriberInterface
7777 private $ operations = [];
7878 private $ lock ;
7979 private $ displayThanksReminder = 0 ;
80- private $ dryRun = false ;
8180 private $ reinstall ;
8281 private static $ activated = true ;
8382 private static $ aliasResolveCommands = [
8483 'require ' => true ,
8584 'update ' => false ,
8685 'remove ' => false ,
87- 'unpack ' => true ,
8886 ];
8987 private $ filter ;
9088
@@ -108,6 +106,8 @@ class_exists(__NAMESPACE__.str_replace('/', '\\', substr($file, \strlen(__DIR__)
108106 }
109107 }
110108
109+ $ composer ->getInstallationManager ()->addInstaller (new SymfonyPackInstaller ($ io ));
110+
111111 $ this ->composer = $ composer ;
112112 $ this ->io = $ io ;
113113 $ this ->config = $ composer ->getConfig ();
@@ -122,7 +122,7 @@ class_exists(__NAMESPACE__.str_replace('/', '\\', substr($file, \strlen(__DIR__)
122122
123123 $ symfonyRequire = preg_replace ('/\.x$/ ' , '.x-dev ' , getenv ('SYMFONY_REQUIRE ' ) ?: ($ composer ->getPackage ()->getExtra ()['symfony ' ]['require ' ] ?? '' ));
124124
125- $ rfs = Factory:: createHttpDownloader ( $ this -> io , $ this -> config );
125+ $ rfs = $ composer -> getLoop ()-> getHttpDownloader ( );
126126
127127 $ this ->downloader = $ downloader = new Downloader ($ composer , $ io , $ rfs );
128128
@@ -221,14 +221,6 @@ public function configureInstaller()
221221 foreach ($ backtrace as $ trace ) {
222222 if (isset ($ trace ['object ' ]) && $ trace ['object ' ] instanceof Installer) {
223223 $ this ->installer = $ trace ['object ' ]->setSuggestedPackagesReporter (new SuggestedPackagesReporter (new NullIO ()));
224-
225- $ updateAllowList = \Closure::bind (function () {
226- return $ this ->updateAllowList ;
227- }, $ this ->installer , $ this ->installer )();
228-
229- if (['php ' => 0 ] === $ updateAllowList ) {
230- $ this ->dryRun = true ; // prevent recipes from being uninstalled when removing a pack
231- }
232224 }
233225
234226 if (isset ($ trace ['object ' ]) && $ trace ['object ' ] instanceof GlobalCommand) {
@@ -254,7 +246,6 @@ public function configureProject(Event $event)
254246 $ file = Factory::getComposerFile ();
255247 $ contents = file_get_contents ($ file );
256248 $ manipulator = new JsonManipulator ($ contents );
257- $ json = JsonFile::parseJson ($ contents );
258249
259250 // new projects are most of the time proprietary
260251 $ manipulator ->addMainKey ('license ' , 'proprietary ' );
@@ -351,7 +342,7 @@ public function update(Event $event, $operations = [])
351342
352343 file_put_contents ($ file , $ manipulator ->getContents ());
353344
354- $ this ->reinstall ($ event, true );
345+ $ this ->reinstall ($ event );
355346 }
356347
357348 public function install (Event $ event )
@@ -738,7 +729,7 @@ private function formatOrigin(Recipe $recipe): string
738729
739730 private function shouldRecordOperation (OperationInterface $ operation , bool $ isDevMode , ?Composer $ composer = null ): bool
740731 {
741- if ($ this ->dryRun || $ this -> reinstall ) {
732+ if ($ this ->reinstall ) {
742733 return false ;
743734 }
744735
@@ -794,31 +785,29 @@ private function unpack(Event $event)
794785 }
795786 }
796787
797- $ unpacker = new Unpacker ($ this ->composer , new PackageResolver ($ this ->downloader ), $ this -> dryRun );
788+ $ unpacker = new Unpacker ($ this ->composer , new PackageResolver ($ this ->downloader ));
798789 $ result = $ unpacker ->unpack ($ unpackOp );
799790
800791 if (!$ result ->getUnpacked ()) {
801792 return ;
802793 }
803794
804- $ this ->io ->writeError ('<info>Unpacking Symfony packs</> ' );
805795 foreach ($ result ->getUnpacked () as $ pkg ) {
806796 $ this ->io ->writeError (\sprintf (' - Unpacked <info>%s</> ' , $ pkg ->getName ()));
807797 }
808798
809799 $ unpacker ->updateLock ($ result , $ this ->io );
810-
811- $ this ->reinstall ($ event , false );
812800 }
813801
814- private function reinstall (Event $ event, bool $ update )
802+ private function reinstall (Event $ event )
815803 {
816804 $ this ->reinstall = false ;
817805 $ event ->stopPropagation ();
818806
819807 $ ed = $ this ->composer ->getEventDispatcher ();
820808 $ disableScripts = !method_exists ($ ed , 'setRunScripts ' ) || !((array ) $ ed )["\0* \0runScripts " ];
821809 $ composer = Factory::create ($ this ->io , null , false , $ disableScripts );
810+ $ composer ->getInstallationManager ()->addInstaller (new SymfonyPackInstaller ($ this ->io ));
822811
823812 $ installer = clone $ this ->installer ;
824813 $ installer ->__construct (
@@ -836,10 +825,6 @@ private function reinstall(Event $event, bool $update)
836825 $ installer ->setPlatformRequirementFilter (((array ) $ this ->installer )["\0* \0platformRequirementFilter " ]);
837826 }
838827
839- if (!$ update ) {
840- $ installer ->setUpdateAllowList (['php ' ]);
841- }
842-
843828 $ installer ->run ();
844829
845830 $ this ->io ->write ($ this ->postInstallOutput );
0 commit comments