1111
1212namespace Symfony \Flex ;
1313
14+ use Composer \Command \BaseConfigCommand ;
1415use Composer \Command \GlobalCommand ;
1516use Composer \Composer ;
1617use Composer \Console \Application ;
@@ -76,7 +77,7 @@ class Flex implements PluginInterface, EventSubscriberInterface
7677 private $ operations = [];
7778 private $ lock ;
7879 private $ displayThanksReminder = 0 ;
79- private $ ignoreUnstableReleases = false ;
80+ private $ ignorePreleases = false ;
8081 private $ reinstall ;
8182 private static $ activated = true ;
8283 private static $ aliasResolveCommands = [
@@ -182,7 +183,12 @@ class_exists(__NAMESPACE__.str_replace('/', '\\', substr($file, \strlen(__DIR__)
182183 }
183184 }
184185
185- $ this ->ignoreUnstableReleases = $ input ->hasParameterOption ('--prefer-lowest ' , true ) && $ input ->hasParameterOption ('--prefer-stable ' , true );
186+ if (class_exists (BaseConfigCommand::class)) {
187+ // composer 2.9+
188+ $ _SERVER ['COMPOSER_PREFER_DEV_OVER_PRERELEASE ' ] = '1 ' ;
189+ } else {
190+ $ this ->ignorePreleases = $ input ->hasParameterOption ('--prefer-lowest ' , true ) && $ input ->hasParameterOption ('--prefer-stable ' , true );
191+ }
186192
187193 $ addCommand = 'add ' .(method_exists ($ app , 'addCommand ' ) ? 'Command ' : '' );
188194 $ app ->$ addCommand (new Command \RecipesCommand ($ this , $ this ->lock , $ rfs ));
@@ -195,8 +201,8 @@ class_exists(__NAMESPACE__.str_replace('/', '\\', substr($file, \strlen(__DIR__)
195201
196202 $ symfonyRequire = preg_replace ('/\.x$/ ' , '.x-dev ' , getenv ('SYMFONY_REQUIRE ' ) ?: ($ composer ->getPackage ()->getExtra ()['symfony ' ]['require ' ] ?? '' ));
197203
198- if ($ symfonyRequire || $ this ->ignoreUnstableReleases ) {
199- $ this ->filter = new PackageFilter ($ io , $ symfonyRequire , $ this ->downloader , $ this ->ignoreUnstableReleases );
204+ if ($ symfonyRequire || $ this ->ignorePreleases ) {
205+ $ this ->filter = new PackageFilter ($ io , $ symfonyRequire , $ this ->downloader , $ this ->ignorePreleases );
200206 }
201207 }
202208
0 commit comments