Created
August 21, 2023 16:58
-
-
Save luzzardi/7bb51c614d4cc8a9d101bda742f15025 to your computer and use it in GitHub Desktop.
Rector script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
use DrupalFinder\DrupalFinder; | |
use DrupalRector\Set\Drupal8SetList; | |
use DrupalRector\Set\Drupal9SetList; | |
use Rector\Config\RectorConfig; | |
// Drupal rector file to check code deprecation and updaate it. | |
return static function (RectorConfig $rectorConfig): void { | |
// Adjust the set lists to be more granular to your Drupal requirements. | |
// @todo find out how to only load the relevant rector rules. | |
// Should we try and load \Drupal::VERSION and check? | |
$rectorConfig->sets([ | |
Drupal9SetList::DRUPAL_90, | |
Drupal9SetList::DRUPAL_91, | |
Drupal9SetList::DRUPAL_92, | |
Drupal9SetList::DRUPAL_93, | |
]); | |
$parameters = $rectorConfig->parameters(); | |
$drupalFinder = new DrupalFinder(); | |
$drupalFinder->locateRoot(__DIR__); | |
$drupalRoot = $drupalFinder->getDrupalRoot(); | |
$rectorConfig->autoloadPaths([ | |
$drupalRoot . '/core', | |
$drupalRoot . '/modules', | |
$drupalRoot . '/profiles', | |
$drupalRoot . '/themes' | |
]); | |
$rectorConfig->skip(['*/upgrade_status/tests/modules/*']); | |
$rectorConfig->fileExtensions(['php', 'module', 'theme', 'install', 'profile', 'inc', 'engine']); | |
$rectorConfig->importNames(TRUE, FALSE); | |
$rectorConfig->importShortClasses(FALSE); | |
$parameters->set('drupal_rector_notices_as_comments', TRUE); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment