diff --git a/.github/workflows/close_stale_issue.yml b/.github/workflows/close_stale_issue.yml index da40bb2..1b455b7 100644 --- a/.github/workflows/close_stale_issue.yml +++ b/.github/workflows/close_stale_issue.yml @@ -10,7 +10,7 @@ jobs: issues: write # for actions/stale to close stale issues runs-on: ubuntu-latest steps: - - uses: actions/stale@v10 + - uses: actions/stale@v11 with: stale-issue-message: >- There has been no activity on this issue for some time and therefore it is considered stale diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ef1bed5 --- /dev/null +++ b/Makefile @@ -0,0 +1 @@ +include ../../PluginsMakefile.mk diff --git a/ajax/dropdownReplaceFindDevice.php b/ajax/dropdownReplaceFindDevice.php index 85cbf49..f2528de 100644 --- a/ajax/dropdownReplaceFindDevice.php +++ b/ajax/dropdownReplaceFindDevice.php @@ -50,9 +50,9 @@ throw new AccessDeniedHttpException(__s("You don't have permission to perform this action.")); } -if (class_exists($_REQUEST['itemtype']) && is_a($_REQUEST['itemtype'], CommonDBTM::class, true)) { +$item = getItemForItemtype($_REQUEST['itemtype']); +if ($item instanceof CommonDBTM) { $itemtypeisplugin = isPluginItemType($_REQUEST['itemtype']); - $item = new $_REQUEST['itemtype'](); $table = getTableForItemType($_REQUEST['itemtype']); $options = []; $count = 0; diff --git a/rector.php b/rector.php index 14bbcf4..aa2ab86 100644 --- a/rector.php +++ b/rector.php @@ -28,30 +28,27 @@ * ------------------------------------------------------------------------- */ +use Rector\Configuration\RectorConfigBuilder; + require_once __DIR__ . '/../../src/Plugin.php'; -use Rector\Caching\ValueObject\Storage\FileCacheStorage; -use Rector\Config\RectorConfig; -use Rector\ValueObject\PhpVersion; +$baseline_file = __DIR__ . '/../../PluginsRector.php'; +if (!file_exists($baseline_file)) { + throw new RuntimeException( + sprintf( + 'Unable to find "%s". Running rector on a plugin requires a GLPI development checkout that ships PluginsRector.php.', + $baseline_file, + ), + ); +} + +$baseline = require $baseline_file; + +/** @var RectorConfigBuilder $config */ +$config = $baseline([ + __DIR__ . '/ajax', + __DIR__ . '/front', + __DIR__ . '/inc', +]); -return RectorConfig::configure() - ->withPaths([ - __DIR__ . '/ajax', - __DIR__ . '/front', - __DIR__ . '/inc', - ]) - ->withPhpVersion(PhpVersion::PHP_82) - ->withCache( - cacheDirectory: __DIR__ . '/var/rector', - cacheClass: FileCacheStorage::class, - ) - ->withRootFiles() - ->withParallel(timeoutSeconds: 300) - ->withImportNames(removeUnusedImports: true) - ->withPreparedSets( - deadCode: true, - codeQuality: true, - codingStyle: true, - ) - ->withPhpSets(php82: true) // apply PHP sets up to PHP 8.2 -; +return $config;