diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 404cc381e5..07f46e26d6 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -8283,30 +8283,12 @@ parameters:
count: 1
path: src/Plugins.php
- -
- message: '#^Cannot cast mixed to string\.$#'
- identifier: cast.string
- count: 2
- path: src/Plugins.php
-
-
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
identifier: empty.notAllowed
count: 1
path: src/Plugins.php
- -
- message: '#^Loose comparison via "\!\=" is not allowed\.$#'
- identifier: notEqual.notAllowed
- count: 1
- path: src/Plugins.php
-
- -
- message: '#^Loose comparison via "\=\=" is not allowed\.$#'
- identifier: equal.notAllowed
- count: 2
- path: src/Plugins.php
-
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -10563,6 +10545,18 @@ parameters:
count: 1
path: src/Profiling.php
+ -
+ message: '#^Loose comparison via "\=\=" is not allowed\.$#'
+ identifier: equal.notAllowed
+ count: 1
+ path: src/Properties/Options/Items/RadioPropertyItem.php
+
+ -
+ message: '#^Loose comparison via "\=\=" is not allowed\.$#'
+ identifier: equal.notAllowed
+ count: 1
+ path: src/Properties/Options/Items/SelectPropertyItem.php
+
-
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
identifier: equal.notAllowed
@@ -16368,12 +16362,6 @@ parameters:
count: 1
path: tests/unit/PluginsTest.php
- -
- message: '#^You should use assertCount\(\$expectedCount, \$variable\) instead of assertSame\(\$expectedCount, \$variable\-\>count\(\)\)\.$#'
- identifier: phpunit.assertCount
- count: 1
- path: tests/unit/Properties/Options/OptionsPropertyGroupTest.php
-
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index a1e9da5cc8..0ff2d14756 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -5589,43 +5589,15 @@
-
-
-
-
- settings[$section][$opt]]]>
+ settings[$pluginType->value][$opt]]]>
- getName()]]>
- getName()]]>
- getName()]]>
- getName()]]>
- getName()]]>
- getName()]]>
- getName()]]>
- getName()]]>
- getName()]]>
- getName()]]>
- getName()]]>
- getName()]]>getName()]]>
- getForce()]]>
- getForce()]]>
- getName()]]>
- getName()]]>
- getName()]]>
- getName()]]>
- getName()]]>
- getName()]]>
- getName()]]>
- getName()]]>
- getName()]]>
- getName()]]>getName()]]>
- settings[$section][$opt])]]>
+ settings[$pluginType->value][$opt])]]>
@@ -7213,6 +7185,54 @@
fetchValue('SELECT @@have_profiling')]]>
+
+
+ getForce()]]>
+ getForce()]]>
+ getName()]]>
+ getName()]]>
+ getName()]]>
+ getName()]]>
+
+
+
+
+ getName()]]>
+ getName()]]>
+
+
+
+
+ getName()]]>
+ getName()]]>
+ getName()]]>
+ getName()]]>
+
+
+
+
+ getName()]]>
+ getName()]]>
+ getName()]]>
+ getName()]]>
+
+
+
+
+ getName()]]>
+ getName()]]>
+ getName()]]>
+ getName()]]>
+
+
+
+
+ getName()]]>
+ getName()]]>
+ getName()]]>
+ getName()]]>
+
+
diff --git a/src/Controllers/Database/ImportController.php b/src/Controllers/Database/ImportController.php
index f5ac290186..5ab583eeb7 100644
--- a/src/Controllers/Database/ImportController.php
+++ b/src/Controllers/Database/ImportController.php
@@ -20,6 +20,7 @@ use PhpMyAdmin\Import\Import;
use PhpMyAdmin\Import\ImportSettings;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins;
+use PhpMyAdmin\Plugins\PluginType;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Routing\Route;
use PhpMyAdmin\Util;
@@ -93,9 +94,9 @@ final readonly class ImportController implements InvocableController
$hiddenInputs = [$idKey => $uploadId, 'import_type' => 'database', 'db' => Current::$database];
$choice = Plugins::getChoice($importList, $this->getFormat($request->getParam('format')));
- $options = Plugins::getOptions('Import', $importList);
+ $options = Plugins::getOptions(PluginType::Import, $importList);
$skipQueriesDefault = $this->getSkipQueries($request->getParam('skip_queries'));
- $isAllowInterruptChecked = Plugins::checkboxCheck('Import', 'allow_interrupt');
+ $isAllowInterruptChecked = Plugins::checkboxCheck(PluginType::Import, 'allow_interrupt');
$maxUploadSize = Util::getUploadSizeInBytes();
$this->response->render('database/import/index', [
diff --git a/src/Controllers/Server/ImportController.php b/src/Controllers/Server/ImportController.php
index e471358274..238d81a7af 100644
--- a/src/Controllers/Server/ImportController.php
+++ b/src/Controllers/Server/ImportController.php
@@ -18,6 +18,7 @@ use PhpMyAdmin\Import\Import;
use PhpMyAdmin\Import\ImportSettings;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins;
+use PhpMyAdmin\Plugins\PluginType;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Routing\Route;
use PhpMyAdmin\Util;
@@ -78,9 +79,9 @@ final readonly class ImportController implements InvocableController
$hiddenInputs = [$idKey => $uploadId, 'import_type' => 'server'];
$choice = Plugins::getChoice($importList, $this->getFormat($request->getParam('format')));
- $options = Plugins::getOptions('Import', $importList);
+ $options = Plugins::getOptions(PluginType::Import, $importList);
$skipQueriesDefault = $this->getSkipQueries($request->getParam('skip_queries'));
- $isAllowInterruptChecked = Plugins::checkboxCheck('Import', 'allow_interrupt');
+ $isAllowInterruptChecked = Plugins::checkboxCheck(PluginType::Import, 'allow_interrupt');
$maxUploadSize = Util::getUploadSizeInBytes();
$this->response->render('server/import/index', [
diff --git a/src/Controllers/Table/ImportController.php b/src/Controllers/Table/ImportController.php
index 7d98c8bf02..d78a350a7a 100644
--- a/src/Controllers/Table/ImportController.php
+++ b/src/Controllers/Table/ImportController.php
@@ -21,6 +21,7 @@ use PhpMyAdmin\Import\Import;
use PhpMyAdmin\Import\ImportSettings;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins;
+use PhpMyAdmin\Plugins\PluginType;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Routing\Route;
use PhpMyAdmin\Url;
@@ -122,9 +123,9 @@ final readonly class ImportController implements InvocableController
];
$choice = Plugins::getChoice($importList, $this->getFormat($request->getParam('format')));
- $options = Plugins::getOptions('Import', $importList);
+ $options = Plugins::getOptions(PluginType::Import, $importList);
$skipQueriesDefault = $this->getSkipQueries($request->getParam('skip_queries'));
- $isAllowInterruptChecked = Plugins::checkboxCheck('Import', 'allow_interrupt');
+ $isAllowInterruptChecked = Plugins::checkboxCheck(PluginType::Import, 'allow_interrupt');
$maxUploadSize = Util::getUploadSizeInBytes();
$this->response->render('table/import/index', [
diff --git a/src/Database/Designer.php b/src/Database/Designer.php
index 68d89cb1eb..7ff2d52b2c 100644
--- a/src/Database/Designer.php
+++ b/src/Database/Designer.php
@@ -12,6 +12,7 @@ use PhpMyAdmin\Database\Designer\DesignerTable;
use PhpMyAdmin\Dbal\DatabaseInterface;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins;
+use PhpMyAdmin\Plugins\PluginType;
use PhpMyAdmin\Template;
use PhpMyAdmin\Util;
use stdClass;
@@ -118,7 +119,7 @@ class Designer
}
$choice = Plugins::getChoice($exportList, $this->getFormat($formatParam, $exportTypeParam));
- $options = Plugins::getOptions('Schema', $exportList);
+ $options = Plugins::getOptions(PluginType::Schema, $exportList);
return $this->template->render('database/designer/schema_export', [
'db' => $db,
diff --git a/src/Export/Options.php b/src/Export/Options.php
index aaf7deca16..21918fcde8 100644
--- a/src/Export/Options.php
+++ b/src/Export/Options.php
@@ -13,6 +13,7 @@ use PhpMyAdmin\Encoding;
use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
+use PhpMyAdmin\Plugins\PluginType;
use PhpMyAdmin\Query\Utilities;
use PhpMyAdmin\Table\Table;
use PhpMyAdmin\Util;
@@ -178,7 +179,7 @@ final readonly class Options
'hidden_inputs' => $hiddenInputs,
'export_method' => $_POST['quick_or_custom'] ?? $config->config->Export->method,
'plugins_choice' => $dropdown,
- 'options' => Plugins::getOptions('Export', $exportList),
+ 'options' => Plugins::getOptions(PluginType::Export, $exportList),
'can_convert_kanji' => Encoding::canConvertKanji(),
'exec_time_limit' => $config->settings['ExecTimeLimit'],
'rows' => $rows,
diff --git a/src/Plugins.php b/src/Plugins.php
index c4b98f734c..9b945195f1 100644
--- a/src/Plugins.php
+++ b/src/Plugins.php
@@ -16,17 +16,11 @@ use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Plugins\ImportPlugin;
use PhpMyAdmin\Plugins\Plugin;
+use PhpMyAdmin\Plugins\PluginType;
use PhpMyAdmin\Plugins\SchemaPlugin;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertySubgroup;
-use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
-use PhpMyAdmin\Properties\Options\Items\DocPropertyItem;
use PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem;
-use PhpMyAdmin\Properties\Options\Items\MessageOnlyPropertyItem;
-use PhpMyAdmin\Properties\Options\Items\NumberPropertyItem;
-use PhpMyAdmin\Properties\Options\Items\RadioPropertyItem;
-use PhpMyAdmin\Properties\Options\Items\SelectPropertyItem;
-use PhpMyAdmin\Properties\Options\Items\TextPropertyItem;
use PhpMyAdmin\Properties\Options\OptionsPropertyGroup;
use PhpMyAdmin\Properties\Options\OptionsPropertyItem;
use PhpMyAdmin\Properties\Options\OptionsPropertyOneItem;
@@ -36,9 +30,6 @@ use Throwable;
use function __;
use function class_exists;
use function count;
-use function htmlspecialchars;
-use function in_array;
-use function is_array;
use function is_string;
use function is_subclass_of;
use function mb_strtolower;
@@ -201,21 +192,18 @@ class Plugins
* Returns html input tag option 'checked' if plugin $opt
* should be set by config or request
*
- * @param string $section name of config section in
- * \PhpMyAdmin\Config::getInstance()->settings[$section] for plugin
- * @param string $opt name of option
- * @psalm-param 'Export'|'Import'|'Schema' $section
+ * @param string $opt name of option
*
* @return string html input tag option 'checked'
*/
- public static function checkboxCheck(string $section, string $opt): string
+ public static function checkboxCheck(PluginType $pluginType, string $opt): string
{
// If the form is being repopulated using $_GET data, that is priority
if (
isset($_GET[$opt])
|| ! isset($_GET['repopulate'])
&& ((ImportSettings::$timeoutPassed && isset($_REQUEST[$opt]))
- || ! empty(Config::getInstance()->settings[$section][$opt]))
+ || ! empty(Config::getInstance()->settings[$pluginType->value][$opt]))
) {
return ' checked';
}
@@ -226,14 +214,12 @@ class Plugins
/**
* Returns default value for option $opt
*
- * @param string $section name of config section in
- * \PhpMyAdmin\Config::getInstance()->settings[$section] for plugin
- * @param string $opt name of option
- * @psalm-param 'Export'|'Import'|'Schema' $section
+ * @param PluginType $pluginType type of the plugin
+ * @param string $opt name of option
*
* @return string default value for option $opt
*/
- public static function getDefault(string $section, string $opt): string
+ public static function getDefault(PluginType $pluginType, string $opt): string
{
if (isset($_GET[$opt]) && is_string($_GET[$opt])) {
// If the form is being repopulated using $_GET data, that is priority
@@ -245,8 +231,8 @@ class Plugins
}
$config = Config::getInstance();
- if (isset($config->settings[$section][$opt])) {
- return (string) $config->settings[$section][$opt];
+ if (isset($config->settings[$pluginType->value][$opt])) {
+ return (string) $config->settings[$pluginType->value][$opt];
}
return '';
@@ -278,22 +264,20 @@ class Plugins
/**
* Returns single option in a list element
*
- * @param string $section name of config section in $cfg[$section] for plugin
* @param string $pluginName unique plugin name
* @param OptionsPropertyItem $propertyGroup options property main group instance
* @param bool $isSubgroup if this group is a subgroup
- * @psalm-param 'Export'|'Import'|'Schema' $section
*
* @return string table row with option
*/
private static function getOneOption(
Plugin $plugin,
- string $section,
+ PluginType $pluginType,
string $pluginName,
OptionsPropertyItem $propertyGroup,
bool $isSubgroup = false,
): string {
- $ret = "\n";
+ $ret = '';
$properties = null;
if (! $isSubgroup) {
@@ -302,7 +286,7 @@ class Plugins
$properties = [$propertyGroup];
} else {
// for main groups
- $ret .= '
';
+ $ret .= "\n" . '
';
$text = null;
if (method_exists($propertyGroup, 'getText')) {
@@ -313,7 +297,7 @@ class Plugins
$ret .= '
' . $plugin->getTranslatedText($text) . '
';
}
- $ret .= '
';
+ $ret .= '
' . "\n";
}
}
@@ -325,17 +309,15 @@ class Plugins
}
}
- $propertyClass = null;
if ($properties !== null) {
foreach ($properties as $propertyItem) {
- $propertyClass = $propertyItem::class;
// if the property is a subgroup, we deal with it recursively
if ($propertyItem instanceof OptionsPropertySubgroup) {
// for subgroups
// each subgroup can have a header, which may also be a form element
$subgroupHeader = $propertyItem->getSubgroupHeader();
if ($subgroupHeader !== null) {
- $ret .= self::getOneOption($plugin, $section, $pluginName, $subgroupHeader);
+ $ret .= self::getOneOption($plugin, $pluginType, $pluginName, $subgroupHeader);
}
$ret .= '
getDoc();
- if (is_array($doc)) {
- if (count($doc) === 3) {
- $ret .= MySQLDocumentation::show($doc[1], false, null, null, $doc[2]);
- } elseif (count($doc) === 1) {
- $ret .= MySQLDocumentation::showDocumentation('faq', $doc[0]);
- } else {
- $ret .= MySQLDocumentation::show($doc[1]);
- }
- }
- }
-
- // Close the list element after $doc link is displayed
- if (
- in_array($propertyClass, [
- BoolPropertyItem::class,
- MessageOnlyPropertyItem::class,
- SelectPropertyItem::class,
- TextPropertyItem::class,
- ], true)
- ) {
- $ret .= '
';
- }
-
- return $ret . "\n";
- }
-
- /**
- * Get HTML for properties items
- *
- * @param string $section name of config section in $cfg[$section] for plugin
- * @param string $pluginName unique plugin name
- * @param OptionsPropertyItem $propertyItem Property item
- * @psalm-param 'Export'|'Import'|'Schema' $section
- */
- public static function getHtmlForProperty(
- Plugin $plugin,
- string $section,
- string $pluginName,
- OptionsPropertyItem $propertyItem,
- ): string {
- $ret = '';
- $propertyClass = $propertyItem::class;
- switch ($propertyClass) {
- case BoolPropertyItem::class:
- $ret .= '