3232use Rector \Symfony \Set \TwigSetList ;
3333use Rector \ValueObject \Configuration \LevelOverflow ;
3434use Rector \ValueObject \PhpVersion ;
35+ use RectorLaravel \Set \LaravelSetList ;
3536use Symfony \Component \Finder \Finder ;
3637use Webmozart \Assert \Assert ;
3738
@@ -56,17 +57,6 @@ final class RectorConfigBuilder
5657 'withCodingStyleLevel ' => [SetList::CODING_STYLE , 'coding style ' ],
5758 ];
5859
59- /**
60- * The composer-based set of the extensions that rector-src does not require, so their set list class cannot be
61- * imported here. Resolved at run-time; an extension that ships no such set falls back to its set group.
62- *
63- * @var array<SetGroup::*, string>
64- */
65- private const array EXTENSION_COMPOSER_BASED_SET_LISTS = [
66- SetGroup::LARAVEL => 'RectorLaravel \\Set \\LaravelSetList::COMPOSER_BASED ' ,
67- SetGroup::DRUPAL => 'DrupalRector \\Set \\DrupalSetList::COMPOSER_BASED ' ,
68- ];
69-
7060 /**
7161 * @var string[]
7262 */
@@ -693,24 +683,13 @@ public function withComposerBased(
693683 bool $ laravel = false ,
694684 bool $ drupal = false ,
695685 ): self {
696- $ setMap = [
697- SetGroup::LARAVEL => $ laravel ,
698- SetGroup::DRUPAL => $ drupal ,
699- ];
700-
701- foreach ($ setMap as $ setGroup => $ isEnabled ) {
702- if (! $ isEnabled ) {
703- continue ;
704- }
705-
706- $ setListConstant = self ::EXTENSION_COMPOSER_BASED_SET_LISTS [$ setGroup ];
707- if (defined ($ setListConstant )) {
708- $ setFilePath = constant ($ setListConstant );
709- Assert ::string ($ setFilePath );
686+ if ($ laravel ) {
687+ $ this ->sets [] = LaravelSetList::COMPOSER_BASED ;
688+ }
710689
711- // single set, as every rule inside is bound to the installed package version on its own
712- $ this -> sets [] = $ setFilePath ;
713- }
690+ if ( $ drupal && class_exists ( ' DrupalRector\Set\DrupalSetList ' )) {
691+ // waits on https://github.com/palantirnet/drupal-rector/pull/419/files#diff-c6bd4ee854830efc1363a7d99c1b6a2e7e64f2499a51e503174ab777de7e64e5
692+ $ this -> sets [] = DrupalSetList:: COMPOSER_BASED ;
714693 }
715694
716695 if ($ phpunit ) {
0 commit comments