diff --git a/.gitignore b/.gitignore index 283db0a..044ece9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ dist/ vendor/ .gh_token *.min.* +var/ diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 5fd203d..ddf4eba 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -5,16 +5,17 @@ $finder = Finder::create() ->in(__DIR__) - ->name('*.php'); + ->name('*.php') + ->ignoreVCSIgnored(true); $config = new Config(); $rules = [ - '@PER-CS2.0' => true, - 'trailing_comma_in_multiline' => ['elements' => ['arguments', 'array_destructuring', 'arrays']], // For PHP 7.4 compatibility + '@PER-CS' => true, // Latest PER rules. ]; return $config ->setRules($rules) ->setFinder($finder) - ->setUsingCache(false); + ->setCacheFile(__DIR__ . '/var/php-cs-fixer/.php-cs-fixer.cache') +; diff --git a/ajax/agent.php b/ajax/agent.php index 09ea8ce..9375ec4 100644 --- a/ajax/agent.php +++ b/ajax/agent.php @@ -45,13 +45,12 @@ $agent = new Agent(); if (!$agent->getFromDB($_POST['id'])) { throw new NotFoundHttpException(); - }; + } + $answer = []; - switch ($_POST['action']) { - case PluginDatabaseinventoryInventoryAction::MA_PARTIAL: - $answer = PluginDatabaseinventoryInventoryAction::runPartialInventory($agent); - break; + if ($_POST['action'] === PluginDatabaseinventoryInventoryAction::MA_PARTIAL) { + $answer = PluginDatabaseinventoryInventoryAction::runPartialInventory($agent); } echo json_encode($answer); diff --git a/composer.lock b/composer.lock index 5620753..4cd7fe2 100644 --- a/composer.lock +++ b/composer.lock @@ -618,16 +618,16 @@ }, { "name": "symfony/service-contracts", - "version": "v3.6.0", + "version": "v3.6.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "f021b05a130d35510bd6b25fe9053c2a8a15d5d4" + "reference": "45112560a3ba2d715666a509a0bc9521d10b6c43" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f021b05a130d35510bd6b25fe9053c2a8a15d5d4", - "reference": "f021b05a130d35510bd6b25fe9053c2a8a15d5d4", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/45112560a3ba2d715666a509a0bc9521d10b6c43", + "reference": "45112560a3ba2d715666a509a0bc9521d10b6c43", "shasum": "" }, "require": { @@ -681,7 +681,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.6.0" + "source": "https://github.com/symfony/service-contracts/tree/v3.6.1" }, "funding": [ { @@ -692,12 +692,16 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-04-25T09:37:31+00:00" + "time": "2025-07-15T11:30:57+00:00" }, { "name": "symfony/string", diff --git a/front/computergroup.form.php b/front/computergroup.form.php index 03e90c3..be67f8a 100644 --- a/front/computergroup.form.php +++ b/front/computergroup.form.php @@ -59,6 +59,7 @@ Html::redirect($computergroup->getLinkURL()); } } + Html::back(); } elseif (isset($_POST['add_staticcomputer'])) { if (!$_POST['computers_id']) { @@ -81,6 +82,7 @@ Html::redirect($computergroup->getLinkURL()); } } + Html::back(); } elseif (isset($_POST['purge'])) { // purge a computergroup @@ -95,6 +97,7 @@ sprintf(__s('%s purges an item'), $_SESSION['glpiname']), ); } + $computergroup->redirectToList(); } elseif (isset($_POST['update'])) { // update a computergroup @@ -143,5 +146,6 @@ } else { $computergroup->display($_GET); } + Html::footer(); } diff --git a/front/credential.form.php b/front/credential.form.php index dc516bc..c495186 100644 --- a/front/credential.form.php +++ b/front/credential.form.php @@ -58,6 +58,7 @@ Html::redirect($credential->getLinkURL()); } } + Html::back(); } elseif (isset($_POST['purge'])) { // purge a credential @@ -72,6 +73,7 @@ sprintf(__s('%s purges an item'), $_SESSION['glpiname']), ); } + $credential->redirectToList(); } elseif (isset($_POST['update'])) { // update a credential @@ -95,5 +97,6 @@ } else { $credential->display($_GET); } + Html::footer(); } diff --git a/front/databaseparam.form.php b/front/databaseparam.form.php index 9ee6a12..ccbd75e 100644 --- a/front/databaseparam.form.php +++ b/front/databaseparam.form.php @@ -60,6 +60,7 @@ Html::redirect($databaseparam->getLinkURL()); } } + Html::back(); } elseif (isset($_POST['add_credential'])) { // add credential @@ -78,6 +79,7 @@ Html::redirect($databaseparam->getLinkURL()); } } + Html::back(); } elseif (isset($_POST['add_computergroup'])) { // add computer group @@ -96,6 +98,7 @@ Html::redirect($databaseparam->getLinkURL()); } } + Html::back(); } elseif (isset($_POST['purge'])) { // purge a databaseparam @@ -110,6 +113,7 @@ sprintf(__s('%s purges an item'), $_SESSION['glpiname']), ); } + $databaseparam->redirectToList(); } elseif (isset($_POST['update'])) { // update a databaseparam @@ -133,5 +137,6 @@ } else { $databaseparam->display($_GET); } + Html::footer(); } diff --git a/hook.php b/hook.php index 008d6c7..0e420b8 100644 --- a/hook.php +++ b/hook.php @@ -53,6 +53,7 @@ function plugin_databaseinventory_install() } } } + $migration->executeMigration(); return true; @@ -79,6 +80,7 @@ function plugin_databaseinventory_uninstall() } } } + $migration->executeMigration(); return true; diff --git a/inc/computergroup.class.php b/inc/computergroup.class.php index 09f3877..d153387 100644 --- a/inc/computergroup.class.php +++ b/inc/computergroup.class.php @@ -61,6 +61,7 @@ class PluginDatabaseinventoryComputerGroup extends CommonDBTM { public $dohistory = true; + public static $rightname = 'database_inventory'; public static function getTypeName($nb = 0) @@ -220,9 +221,8 @@ public function countStaticItem() ]; $iterator = $DB->request($params); - $count = count($iterator); - return $count; + return count($iterator); } public static function install(Migration $migration) @@ -236,9 +236,9 @@ public static function install(Migration $migration) $table = self::getTable(); if (!$DB->tableExists($table)) { - $migration->displayMessage("Installing $table"); + $migration->displayMessage('Installing ' . $table); $query = << $values]; } + switch ($field) { case 'search': $count = 0; @@ -91,7 +92,7 @@ public static function getSpecificValueToDisplay($field, $values, array $options global $CFG_GLPI; $value = ' '; $out = ' '; - if (!str_contains($values['id'], Search::NULLVALUE)) { + if (!str_contains((string) $values['id'], Search::NULLVALUE)) { $search_params = Search::manageParams('Computer', unserialize($values['search'])); $data = Search::prepareDatasForSearch('Computer', $search_params); Search::constructSQL($data); @@ -120,6 +121,7 @@ public static function getSpecificValueToDisplay($field, $values, array $options foreach ($values as $v) { $value .= $v . $line_delimiter; } + $value = preg_replace('/' . Search::LBBR . '/', '
', $value); $value = preg_replace('/' . Search::LBHR . '/', '
', $value); $value = '
' . $value . '
'; @@ -147,12 +149,8 @@ public static function getSpecificValueToDisplay($field, $values, array $options public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { - if ($item instanceof PluginDatabaseinventoryComputerGroup) { - switch ($tabnum) { - case 1: - self::showForItem($item); - break; - } + if ($item instanceof PluginDatabaseinventoryComputerGroup && $tabnum === 1) { + self::showForItem($item); } return true; @@ -164,9 +162,8 @@ private function countDynamicItems() $data = Search::prepareDatasForSearch('Computer', $search_params); Search::constructSQL($data); Search::constructData($data); - $count = $data['data']['totalcount']; - return $count; + return $data['data']['totalcount']; } public function isDynamicSearchMatchComputer(Computer $computer) @@ -183,13 +180,13 @@ public function isDynamicSearchMatchComputer(Computer $computer) if (!isset($_SESSION['glpiname'])) { $_SESSION['glpiname'] = 'databaseinventory_plugin'; } + $search_params = Search::manageParams('Computer', $search); $data = Search::prepareDatasForSearch('Computer', $search_params); Search::constructSQL($data); Search::constructData($data); - $count = $data['data']['totalcount']; - return $count; + return $data['data']['totalcount']; } private static function showForItem(PluginDatabaseinventoryComputerGroup $computergroup) @@ -204,16 +201,16 @@ private static function showForItem(PluginDatabaseinventoryComputerGroup $comput $firsttime = true; // load dynamic search criteria from DB if exist $computergroup_dynamic = new self(); - if ( - $computergroup_dynamic->getFromDBByCrit([ - 'plugin_databaseinventory_computergroups_id' => $ID, - ]) - ) { - $p = $search_params = Search::manageParams('Computer', unserialize($computergroup_dynamic->fields['search'])); + if ($computergroup_dynamic->getFromDBByCrit([ + 'plugin_databaseinventory_computergroups_id' => $ID, + ])) { + $p = Search::manageParams('Computer', unserialize($computergroup_dynamic->fields['search'])); + $search_params = $p; $firsttime = false; } else { // retrieve filter value from search if exist and reset it - $p = $search_params = Search::manageParams('Computer', $_GET); + $p = Search::manageParams('Computer', $_GET); + $search_params = $p; if (isset($_SESSION['glpisearch']['Computer'])) { unset($_SESSION['glpisearch']['Computer']); } @@ -268,9 +265,9 @@ public static function install(Migration $migration) $table = self::getTable(); if (!$DB->tableExists($table)) { - $migration->displayMessage("Installing $table"); + $migration->displayMessage('Installing ' . $table); $query = <<display( '@databaseinventory/computergroupstatic.html.twig', [ @@ -173,9 +175,9 @@ public static function install(Migration $migration) $table = self::getTable(); if (!$DB->tableExists($table)) { - $migration->displayMessage("Installing $table"); + $migration->displayMessage('Installing ' . $table); $query = << $item->getID()]); @@ -101,7 +102,7 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { - switch (get_class($item)) { + switch ($item::class) { case (PluginDatabaseinventoryDatabaseParam::class): self::showForDatabaseParams($item); break; @@ -109,6 +110,7 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $ self::showForAgent($item); break; } + return true; } @@ -134,10 +136,12 @@ private static function showForDatabaseParams(PluginDatabaseinventoryDatabasePar $linkcred = $credential->getLinkURL(); $credname = $credential->fields['name']; } + if ($agent->getFromDB($dbpctlog['agents_id'])) { $linkagent = $agent->getLinkURL(); $agentname = $agent->fields['name']; } + if (isset($linkcred) || isset($linkagent)) { $listofctlog[] = $dbpctlog + [ 'linkcred' => $linkcred ?? '', @@ -147,6 +151,7 @@ private static function showForDatabaseParams(PluginDatabaseinventoryDatabasePar ]; } } + TemplateRenderer::getInstance()->display( '@databaseinventory/contactlog.html.twig', [ @@ -181,10 +186,12 @@ private static function showForAgent(Agent $agent) $linkcred = $credential->getLinkURL(); $credname = $credential->fields['name']; } + if ($dbparam->getFromDB($dbpctlog['plugin_databaseinventory_databaseparams_id'])) { $linkdbparam = $dbparam->getLinkURL(); $dbparamname = $dbparam->fields['name']; } + if (isset($linkcred)) { $listofctlog[] = $dbpctlog + [ 'linkcred' => $linkcred, @@ -194,6 +201,7 @@ private static function showForAgent(Agent $agent) ]; } } + TemplateRenderer::getInstance()->display( '@databaseinventory/contactlog.html.twig', [ @@ -217,9 +225,9 @@ public static function install(Migration $migration) $table = self::getTable(); if (!$DB->tableExists($table)) { - $migration->displayMessage("Installing $table"); + $migration->displayMessage('Installing ' . $table); $query = <<encrypt($input['password']); } } + if (isset($input['_blank_password'])) { $input['password'] = ''; } @@ -168,9 +170,7 @@ public function prepareInput(array $input, $mode = 'add'): array public function prepareInputForAdd($input) { - $input = $this->prepareInput($input, 'add'); - - return $input; + return $this->prepareInput($input, 'add'); } public function prepareInputForUpdate($input) @@ -195,9 +195,9 @@ public static function install(Migration $migration) $table = self::getTable(); if (!$DB->tableExists($table)) { - $migration->displayMessage("Installing $table"); + $migration->displayMessage('Installing ' . $table); $query = << 'mysql', + self::ORACLE => 'oracle', + self::DB2 => 'db2', + self::MSSQL => 'mssql', + self::POSTGRE_SQL => 'postgresql', + self::MONGO_DB => 'mongodb', + default => null, + }; } public static function getModuleKeyByName($credential_type) { - switch ($credential_type) { - case 'mysql': - return self::MYSQL; - case 'oracle': - return self::ORACLE; - case 'db2': - return self::DB2; - case 'mssql': - return self::MSSQL; - case 'postgresql': - return self::POSTGRE_SQL; - case 'mongodb': - return self::MONGO_DB; - } + return match ($credential_type) { + 'mysql' => self::MYSQL, + 'oracle' => self::ORACLE, + 'db2' => self::DB2, + 'mssql' => self::MSSQL, + 'postgresql' => self::POSTGRE_SQL, + 'mongodb' => self::MONGO_DB, + default => null, + }; } public static function install(Migration $migration) @@ -138,9 +133,9 @@ public static function install(Migration $migration) // PluginDatabaseinventoryCredentialType was named PluginDatabaseinventoryCredential_Type prior to v1.0.0 $migration->renameTable('glpi_plugin_databaseinventory_credentials_types', $table); } elseif (!$DB->tableExists($table)) { - $migration->displayMessage("Installing $table"); + $migration->displayMessage('Installing ' . $table); $query = <<tableExists($table)) { - $migration->displayMessage("Installing $table"); + $migration->displayMessage('Installing ' . $table); $query = <<display( '@databaseinventory/databaseparam_computergroup.html.twig', [ @@ -172,9 +174,9 @@ public static function install(Migration $migration) $table = self::getTable(); if (!$DB->tableExists($table)) { - $migration->displayMessage("Installing $table"); + $migration->displayMessage('Installing ' . $table); $query = <<display( '@databaseinventory/databaseparam_credential.html.twig', [ @@ -174,9 +176,9 @@ public static function install(Migration $migration) $table = self::getTable(); if (!$DB->tableExists($table)) { - $migration->displayMessage("Installing $table"); + $migration->displayMessage('Installing ' . $table); $query = <<getAction() !== self::MA_PARTIAL) { return parent::showMassiveActionsSubForm($ma); } + echo Html::submit(__s('Run', 'databaseinventory'), ['name' => 'submit']); return true; @@ -71,6 +74,7 @@ public static function processMassiveActionsForOneItemtype(MassiveAction $ma, Co $ma->addMessage(__s('Agent not found for computer', 'databaseinventory') . "" . $computer->getFriendlyName() . ''); } } + break; case Agent::getType(): foreach ($ids as $id) { @@ -87,6 +91,7 @@ public static function processMassiveActionsForOneItemtype(MassiveAction $ma, Co $ma->addMessage(sprintf(__s('Agent %1$s not found', 'databaseinventory'), $id)); } } + break; } } @@ -112,25 +117,22 @@ public static function runPartialInventory(Agent $agent, $fromMA = false) // not authorized return self::handleAgentResponse($response, $endpoint); } - } catch (Exception $e) { + } catch (Exception $exception) { if ($fromMA) { return false; } else { // not authorized - return ['answer' => $e->getMessage()]; + return ['answer' => $exception->getMessage()]; } } } public static function handleAgentResponse($response, $request): array { - $params = []; - $params['answer'] = sprintf( + return ['answer' => sprintf( __s('Requested at %s', 'databaseinventory'), Html::convDateTime(date('Y-m-d H:i:s')), - ); - - return $params; + )]; } private static function findAgent(Computer $item) @@ -172,6 +174,7 @@ public static function postItemForm($item) if (!Session::haveRight("database_inventory", PluginDatabaseinventoryProfile::RUN_DATABSE_INVENTORY)) { return; } + /** @var array $CFG_GLPI */ global $CFG_GLPI; diff --git a/inc/menu.class.php b/inc/menu.class.php index 0a3734a..ef46a20 100644 --- a/inc/menu.class.php +++ b/inc/menu.class.php @@ -46,7 +46,7 @@ public static function getMenuContent() $links = []; foreach ($links_class as $link) { $link_text = "" . $link::getTypeName(Session::getPluralNumber()) . ''; - $links["$link_text"] = $link::getSearchURL(false); + $links["" . $link_text)] = $link::getSearchURL(false); } $menu = [ diff --git a/inc/profile.class.php b/inc/profile.class.php index 8642749..715e174 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -39,9 +39,9 @@ public static function getTypeName($nb = 0) return __s('Database Inventory', 'databaseinventory'); } - private static function getAllRights($all = false) + private static function getAllRights() { - $rights = [ + return [ [ 'itemtype' => PluginDatabaseinventoryDatabaseParam::getType(), 'label' => PluginDatabaseinventoryProfile::getTypeName(), @@ -57,8 +57,6 @@ private static function getAllRights($all = false) ], ], ]; - - return $rights; } public function getRights($interface = 'central') diff --git a/inc/task.class.php b/inc/task.class.php index c021746..86918eb 100644 --- a/inc/task.class.php +++ b/inc/task.class.php @@ -90,38 +90,36 @@ public static function inventoryGetParams(array $params) * ) * ) */ - if (count($credential_found)) { - foreach ($credential_found as $crendential_id) { - $crendential = new PluginDatabaseinventoryCredential(); - $crendential->getFromDB($crendential_id); - $data = [ - 'id' => $crendential->fields['id'], - 'type' => $crendential->getCredentialMode(), - 'use' => $content->use, - 'login' => $crendential->fields['login'], - 'password' => (new GLPIKey())->decrypt($crendential->fields['password']), - ]; + foreach ($credential_found as $crendential_id) { + $crendential = new PluginDatabaseinventoryCredential(); + $crendential->getFromDB($crendential_id); + $data = [ + 'id' => $crendential->fields['id'], + 'type' => $crendential->getCredentialMode(), + 'use' => $content->use, + 'login' => $crendential->fields['login'], + 'password' => (new GLPIKey())->decrypt($crendential->fields['password']), + ]; - if (!empty($crendential->fields['socket'])) { - $data['socket'] = $crendential->fields['socket']; - } + if (!empty($crendential->fields['socket'])) { + $data['socket'] = $crendential->fields['socket']; + } - if ($crendential->fields['port'] != 0) { - $data['port'] = $crendential->fields['port']; - } + if ($crendential->fields['port'] != 0) { + $data['port'] = $crendential->fields['port']; + } - $params['options']['response']['credentials'][] = $data; + $params['options']['response']['credentials'][] = $data; - // store requested credentials - $contact_log = new PluginDatabaseinventoryContactLog(); - $log = [ - 'agents_id' => $agent->fields['id'], - 'plugin_databaseinventory_credentials_id' => $crendential_id, - 'plugin_databaseinventory_databaseparams_id' => $content->params_id, - 'date_creation ' => $_SESSION['glpi_currenttime'], - ]; - $contact_log->add($log); - } + // store requested credentials + $contact_log = new PluginDatabaseinventoryContactLog(); + $log = [ + 'agents_id' => $agent->fields['id'], + 'plugin_databaseinventory_credentials_id' => $crendential_id, + 'plugin_databaseinventory_databaseparams_id' => $content->params_id, + 'date_creation ' => $_SESSION['glpi_currenttime'], + ]; + $contact_log->add($log); } return $params; @@ -138,7 +136,7 @@ public static function handleInventoryTask(array $params) $database_param_found = []; // only Computer type - if (get_class($computer) == Computer::getType() && !$computer->isNewItem()) { + if ($computer::class == Computer::getType() && !$computer->isNewItem()) { $database_param_table = PluginDatabaseinventoryDatabaseParam::getTable() ; $database_param_computergroup_table = PluginDatabaseinventoryDatabaseParam_ComputerGroup::getTable(); $computer_group_static_table = PluginDatabaseinventoryComputerGroupStatic::getTable(); @@ -274,20 +272,19 @@ public static function handleInventoryTask(array $params) * ) * ) */ - if (count($database_param_found)) { - foreach ($database_param_found as $database_params_id) { - $database_params = new PluginDatabaseinventoryDatabaseParam(); - $database_params->getFromDB($database_params_id); + foreach ($database_param_found as $database_params_id) { + $database_params = new PluginDatabaseinventoryDatabaseParam(); + $database_params->getFromDB($database_params_id); - $json = []; - $json['category'] = 'database'; - $json['use'] = $database_params->getCredentialTypeLinked(); - $json['params_id'] = $database_params_id; - if ($database_params->fields['partial_inventory']) { - $json['delay'] = $database_params->fields['execution_delay']; - } - $params['options']['response']['inventory']['params'][] = $json; + $json = []; + $json['category'] = 'database'; + $json['use'] = $database_params->getCredentialTypeLinked(); + $json['params_id'] = $database_params_id; + if ($database_params->fields['partial_inventory']) { + $json['delay'] = $database_params->fields['execution_delay']; } + + $params['options']['response']['inventory']['params'][] = $json; } return $params; diff --git a/rector.php b/rector.php index 2a10231..87d418a 100644 --- a/rector.php +++ b/rector.php @@ -31,9 +31,7 @@ require_once __DIR__ . '/../../src/Plugin.php'; use Rector\Caching\ValueObject\Storage\FileCacheStorage; -use Rector\CodeQuality\Rector as CodeQuality; use Rector\Config\RectorConfig; -use Rector\DeadCode\Rector as DeadCode; use Rector\ValueObject\PhpVersion; return RectorConfig::configure() @@ -44,55 +42,16 @@ ]) ->withPhpVersion(PhpVersion::PHP_82) ->withCache( + cacheDirectory: __DIR__ . '/var/rector', cacheClass: FileCacheStorage::class, - cacheDirectory: sys_get_temp_dir() . '/databaseinventory-rector', ) ->withRootFiles() ->withParallel(timeoutSeconds: 300) ->withImportNames(removeUnusedImports: true) - ->withRules([ - CodeQuality\Assign\CombinedAssignRector::class, - CodeQuality\BooleanAnd\RemoveUselessIsObjectCheckRector::class, - CodeQuality\BooleanAnd\SimplifyEmptyArrayCheckRector::class, - CodeQuality\BooleanNot\ReplaceMultipleBooleanNotRector::class, - CodeQuality\Catch_\ThrowWithPreviousExceptionRector::class, - CodeQuality\Empty_\SimplifyEmptyCheckOnEmptyArrayRector::class, - CodeQuality\Expression\InlineIfToExplicitIfRector::class, - CodeQuality\Expression\TernaryFalseExpressionToIfRector::class, - CodeQuality\For_\ForRepeatedCountToOwnVariableRector::class, - CodeQuality\Foreach_\ForeachItemsAssignToEmptyArrayToAssignRector::class, - CodeQuality\Foreach_\ForeachToInArrayRector::class, - CodeQuality\Foreach_\SimplifyForeachToCoalescingRector::class, - CodeQuality\Foreach_\UnusedForeachValueToArrayKeysRector::class, - CodeQuality\FuncCall\ChangeArrayPushToArrayAssignRector::class, - CodeQuality\FuncCall\CompactToVariablesRector::class, - CodeQuality\FuncCall\InlineIsAInstanceOfRector::class, - CodeQuality\FuncCall\IsAWithStringWithThirdArgumentRector::class, - CodeQuality\FuncCall\RemoveSoleValueSprintfRector::class, - CodeQuality\FuncCall\SetTypeToCastRector::class, - CodeQuality\FuncCall\SimplifyFuncGetArgsCountRector::class, - CodeQuality\FuncCall\SimplifyInArrayValuesRector::class, - CodeQuality\FuncCall\SimplifyStrposLowerRector::class, - CodeQuality\FuncCall\UnwrapSprintfOneArgumentRector::class, - CodeQuality\Identical\BooleanNotIdenticalToNotIdenticalRector::class, - CodeQuality\Identical\SimplifyArraySearchRector::class, - CodeQuality\Identical\SimplifyConditionsRector::class, - CodeQuality\Identical\StrlenZeroToIdenticalEmptyStringRector::class, - CodeQuality\If_\CombineIfRector::class, - CodeQuality\If_\CompleteMissingIfElseBracketRector::class, - CodeQuality\If_\ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class, - CodeQuality\If_\ExplicitBoolCompareRector::class, - CodeQuality\If_\ShortenElseIfRector::class, - CodeQuality\If_\SimplifyIfElseToTernaryRector::class, - CodeQuality\If_\SimplifyIfNotNullReturnRector::class, - CodeQuality\If_\SimplifyIfNullableReturnRector::class, - CodeQuality\If_\SimplifyIfReturnBoolRector::class, - CodeQuality\Include_\AbsolutizeRequireAndIncludePathRector::class, - CodeQuality\LogicalAnd\AndAssignsToSeparateLinesRector::class, - CodeQuality\LogicalAnd\LogicalToBooleanRector::class, - CodeQuality\NotEqual\CommonNotEqualRector::class, - CodeQuality\Ternary\UnnecessaryTernaryExpressionRector::class, - DeadCode\Assign\RemoveUnusedVariableAssignRector::class, - ]) - ->withPhpSets(php74: true) // apply PHP sets up to PHP 7.4 + ->withPreparedSets( + deadCode: true, + codeQuality: true, + codingStyle: true, + ) + ->withPhpSets(php82: true) // apply PHP sets up to PHP 8.2 ;