Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,7 @@
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"enable-patching": true,
"rector": {
"includes": [
"config/extension.php"
]
}
"enable-patching": true
},
"require-dev": {
"php": "^8.2",
Expand Down
36 changes: 36 additions & 0 deletions config/drupal-bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,40 @@
// need them can re-register this singleton in its own rector.php.)
$rectorConfig->singleton(DrupalRectorSettings::class, fn () => (new DrupalRectorSettings())
->disableBackwardCompatibility());

// Drupal executes PHP from several non-.php extensions.
$rectorConfig->fileExtensions(['php', 'module', 'theme', 'install', 'profile', 'inc', 'engine']);

// upgrade_status ships intentionally broken test modules.
$rectorConfig->skip(['*/upgrade_status/tests/modules/*']);

// Autoloading and phpstan-drupal only make sense when Drupal is actually
// present. Bail out otherwise — DrupalFinderComposerRuntime::getDrupalRoot()
// calls Composer\InstalledVersions::getInstallPath('drupal/core'), which
// THROWS (not returns null) when the package is not installed, so this must
// be guarded before the lookup.
if (! \Composer\InstalledVersions::isInstalled('drupal/core')) {
return;
}

$drupalFinder = new \DrupalFinder\DrupalFinderComposerRuntime();

$drupalRoot = $drupalFinder->getDrupalRoot();
if (is_string($drupalRoot) && $drupalRoot !== '') {
$rectorConfig->autoloadPaths([
$drupalRoot.'/core',
$drupalRoot.'/modules',
$drupalRoot.'/profiles',
$drupalRoot.'/themes',
]);
}

// phpstan-drupal lives in the analysed project's vendor dir, not ours.
$vendorDir = $drupalFinder->getVendorDir();
if (is_string($vendorDir) && $vendorDir !== '') {
$phpstanDrupalExtension = $vendorDir.'/mglaman/phpstan-drupal/extension.neon';
if (file_exists($phpstanDrupalExtension)) {
$rectorConfig->phpstanConfigs([$phpstanDrupalExtension]);
}
}
};
67 changes: 0 additions & 67 deletions config/extension.php

This file was deleted.

Loading