Skip to content

Commit 71ac9f7

Browse files
Merge pull request #20103 from kamil-tekiela/Properties-2
Refactoring of Properties 2
2 parents da6b98f + ecd109d commit 71ac9f7

28 files changed

Lines changed: 554 additions & 560 deletions

phpstan-baseline.neon

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8283,30 +8283,12 @@ parameters:
82838283
count: 1
82848284
path: src/Plugins.php
82858285

8286-
-
8287-
message: '#^Cannot cast mixed to string\.$#'
8288-
identifier: cast.string
8289-
count: 2
8290-
path: src/Plugins.php
8291-
82928286
-
82938287
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
82948288
identifier: empty.notAllowed
82958289
count: 1
82968290
path: src/Plugins.php
82978291

8298-
-
8299-
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
8300-
identifier: notEqual.notAllowed
8301-
count: 1
8302-
path: src/Plugins.php
8303-
8304-
-
8305-
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
8306-
identifier: equal.notAllowed
8307-
count: 2
8308-
path: src/Plugins.php
8309-
83108292
-
83118293
message: '''
83128294
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -10563,6 +10545,18 @@ parameters:
1056310545
count: 1
1056410546
path: src/Profiling.php
1056510547

10548+
-
10549+
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
10550+
identifier: equal.notAllowed
10551+
count: 1
10552+
path: src/Properties/Options/Items/RadioPropertyItem.php
10553+
10554+
-
10555+
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
10556+
identifier: equal.notAllowed
10557+
count: 1
10558+
path: src/Properties/Options/Items/SelectPropertyItem.php
10559+
1056610560
-
1056710561
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
1056810562
identifier: equal.notAllowed
@@ -16368,12 +16362,6 @@ parameters:
1636816362
count: 1
1636916363
path: tests/unit/PluginsTest.php
1637016364

16371-
-
16372-
message: '#^You should use assertCount\(\$expectedCount, \$variable\) instead of assertSame\(\$expectedCount, \$variable\-\>count\(\)\)\.$#'
16373-
identifier: phpunit.assertCount
16374-
count: 1
16375-
path: tests/unit/Properties/Options/OptionsPropertyGroupTest.php
16376-
1637716365
-
1637816366
message: '''
1637916367
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:

psalm-baseline.xml

Lines changed: 50 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5589,43 +5589,15 @@
55895589
<code><![CDATA[Config::getInstance()]]></code>
55905590
<code><![CDATA[Config::getInstance()]]></code>
55915591
</DeprecatedMethod>
5592-
<MixedAssignment>
5593-
<code><![CDATA[$val]]></code>
5594-
<code><![CDATA[$val]]></code>
5595-
</MixedAssignment>
55965592
<PossiblyInvalidCast>
5597-
<code><![CDATA[$config->settings[$section][$opt]]]></code>
5593+
<code><![CDATA[$config->settings[$pluginType->value][$opt]]]></code>
55985594
</PossiblyInvalidCast>
55995595
<PossiblyNullOperand>
5600-
<code><![CDATA[$pitem->getName()]]></code>
5601-
<code><![CDATA[$pitem->getName()]]></code>
5602-
<code><![CDATA[$pitem->getName()]]></code>
5603-
<code><![CDATA[$pitem->getName()]]></code>
5604-
<code><![CDATA[$pitem->getName()]]></code>
5605-
<code><![CDATA[$pitem->getName()]]></code>
5606-
<code><![CDATA[$pitem->getName()]]></code>
5607-
<code><![CDATA[$pitem->getName()]]></code>
5608-
<code><![CDATA[$pitem->getName()]]></code>
5609-
<code><![CDATA[$pitem->getName()]]></code>
5610-
<code><![CDATA[$pitem->getName()]]></code>
5611-
<code><![CDATA[$pitem->getName()]]></code>
56125596
<code><![CDATA[$propertyGroup->getName()]]></code>
5613-
<code><![CDATA[$propertyItem->getForce()]]></code>
5614-
<code><![CDATA[$propertyItem->getForce()]]></code>
5615-
<code><![CDATA[$propertyItem->getName()]]></code>
5616-
<code><![CDATA[$propertyItem->getName()]]></code>
5617-
<code><![CDATA[$propertyItem->getName()]]></code>
5618-
<code><![CDATA[$propertyItem->getName()]]></code>
5619-
<code><![CDATA[$propertyItem->getName()]]></code>
5620-
<code><![CDATA[$propertyItem->getName()]]></code>
5621-
<code><![CDATA[$propertyItem->getName()]]></code>
5622-
<code><![CDATA[$propertyItem->getName()]]></code>
5623-
<code><![CDATA[$propertyItem->getName()]]></code>
5624-
<code><![CDATA[$propertyItem->getName()]]></code>
56255597
<code><![CDATA[$subgroupHeader->getName()]]></code>
56265598
</PossiblyNullOperand>
56275599
<RiskyTruthyFalsyComparison>
5628-
<code><![CDATA[empty(Config::getInstance()->settings[$section][$opt])]]></code>
5600+
<code><![CDATA[empty(Config::getInstance()->settings[$pluginType->value][$opt])]]></code>
56295601
</RiskyTruthyFalsyComparison>
56305602
</file>
56315603
<file src="src/Plugins/Auth/AuthenticationConfig.php">
@@ -7213,6 +7185,54 @@
72137185
<code><![CDATA[$dbi->fetchValue('SELECT @@have_profiling')]]></code>
72147186
</RiskyTruthyFalsyComparison>
72157187
</file>
7188+
<file src="src/Properties/Options/Items/BoolPropertyItem.php">
7189+
<PossiblyNullOperand>
7190+
<code><![CDATA[$this->getForce()]]></code>
7191+
<code><![CDATA[$this->getForce()]]></code>
7192+
<code><![CDATA[$this->getName()]]></code>
7193+
<code><![CDATA[$this->getName()]]></code>
7194+
<code><![CDATA[$this->getName()]]></code>
7195+
<code><![CDATA[$this->getName()]]></code>
7196+
</PossiblyNullOperand>
7197+
</file>
7198+
<file src="src/Properties/Options/Items/HiddenPropertyItem.php">
7199+
<PossiblyNullOperand>
7200+
<code><![CDATA[$this->getName()]]></code>
7201+
<code><![CDATA[$this->getName()]]></code>
7202+
</PossiblyNullOperand>
7203+
</file>
7204+
<file src="src/Properties/Options/Items/NumberPropertyItem.php">
7205+
<PossiblyNullOperand>
7206+
<code><![CDATA[$this->getName()]]></code>
7207+
<code><![CDATA[$this->getName()]]></code>
7208+
<code><![CDATA[$this->getName()]]></code>
7209+
<code><![CDATA[$this->getName()]]></code>
7210+
</PossiblyNullOperand>
7211+
</file>
7212+
<file src="src/Properties/Options/Items/RadioPropertyItem.php">
7213+
<PossiblyNullOperand>
7214+
<code><![CDATA[$this->getName()]]></code>
7215+
<code><![CDATA[$this->getName()]]></code>
7216+
<code><![CDATA[$this->getName()]]></code>
7217+
<code><![CDATA[$this->getName()]]></code>
7218+
</PossiblyNullOperand>
7219+
</file>
7220+
<file src="src/Properties/Options/Items/SelectPropertyItem.php">
7221+
<PossiblyNullOperand>
7222+
<code><![CDATA[$this->getName()]]></code>
7223+
<code><![CDATA[$this->getName()]]></code>
7224+
<code><![CDATA[$this->getName()]]></code>
7225+
<code><![CDATA[$this->getName()]]></code>
7226+
</PossiblyNullOperand>
7227+
</file>
7228+
<file src="src/Properties/Options/Items/TextPropertyItem.php">
7229+
<PossiblyNullOperand>
7230+
<code><![CDATA[$this->getName()]]></code>
7231+
<code><![CDATA[$this->getName()]]></code>
7232+
<code><![CDATA[$this->getName()]]></code>
7233+
<code><![CDATA[$this->getName()]]></code>
7234+
</PossiblyNullOperand>
7235+
</file>
72167236
<file src="src/Query/Compatibility.php">
72177237
<PossiblyInvalidArgument>
72187238
<code><![CDATA[$eachTables[$tableName]['Comment'] ?? '']]></code>

src/Controllers/Database/ImportController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use PhpMyAdmin\Import\ImportSettings;
2121
use PhpMyAdmin\Message;
2222
use PhpMyAdmin\Plugins;
23+
use PhpMyAdmin\Plugins\PluginType;
2324
use PhpMyAdmin\ResponseRenderer;
2425
use PhpMyAdmin\Routing\Route;
2526
use PhpMyAdmin\Util;
@@ -93,9 +94,9 @@ public function __invoke(ServerRequest $request): Response
9394
$hiddenInputs = [$idKey => $uploadId, 'import_type' => 'database', 'db' => Current::$database];
9495

9596
$choice = Plugins::getChoice($importList, $this->getFormat($request->getParam('format')));
96-
$options = Plugins::getOptions('Import', $importList);
97+
$options = Plugins::getOptions(PluginType::Import, $importList);
9798
$skipQueriesDefault = $this->getSkipQueries($request->getParam('skip_queries'));
98-
$isAllowInterruptChecked = Plugins::checkboxCheck('Import', 'allow_interrupt');
99+
$isAllowInterruptChecked = Plugins::checkboxCheck(PluginType::Import, 'allow_interrupt');
99100
$maxUploadSize = Util::getUploadSizeInBytes();
100101

101102
$this->response->render('database/import/index', [

src/Controllers/Server/ImportController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use PhpMyAdmin\Import\ImportSettings;
1919
use PhpMyAdmin\Message;
2020
use PhpMyAdmin\Plugins;
21+
use PhpMyAdmin\Plugins\PluginType;
2122
use PhpMyAdmin\ResponseRenderer;
2223
use PhpMyAdmin\Routing\Route;
2324
use PhpMyAdmin\Util;
@@ -78,9 +79,9 @@ public function __invoke(ServerRequest $request): Response
7879
$hiddenInputs = [$idKey => $uploadId, 'import_type' => 'server'];
7980

8081
$choice = Plugins::getChoice($importList, $this->getFormat($request->getParam('format')));
81-
$options = Plugins::getOptions('Import', $importList);
82+
$options = Plugins::getOptions(PluginType::Import, $importList);
8283
$skipQueriesDefault = $this->getSkipQueries($request->getParam('skip_queries'));
83-
$isAllowInterruptChecked = Plugins::checkboxCheck('Import', 'allow_interrupt');
84+
$isAllowInterruptChecked = Plugins::checkboxCheck(PluginType::Import, 'allow_interrupt');
8485
$maxUploadSize = Util::getUploadSizeInBytes();
8586

8687
$this->response->render('server/import/index', [

src/Controllers/Table/ImportController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use PhpMyAdmin\Import\ImportSettings;
2222
use PhpMyAdmin\Message;
2323
use PhpMyAdmin\Plugins;
24+
use PhpMyAdmin\Plugins\PluginType;
2425
use PhpMyAdmin\ResponseRenderer;
2526
use PhpMyAdmin\Routing\Route;
2627
use PhpMyAdmin\Url;
@@ -122,9 +123,9 @@ public function __invoke(ServerRequest $request): Response
122123
];
123124

124125
$choice = Plugins::getChoice($importList, $this->getFormat($request->getParam('format')));
125-
$options = Plugins::getOptions('Import', $importList);
126+
$options = Plugins::getOptions(PluginType::Import, $importList);
126127
$skipQueriesDefault = $this->getSkipQueries($request->getParam('skip_queries'));
127-
$isAllowInterruptChecked = Plugins::checkboxCheck('Import', 'allow_interrupt');
128+
$isAllowInterruptChecked = Plugins::checkboxCheck(PluginType::Import, 'allow_interrupt');
128129
$maxUploadSize = Util::getUploadSizeInBytes();
129130

130131
$this->response->render('table/import/index', [

src/Database/Designer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use PhpMyAdmin\Dbal\DatabaseInterface;
1313
use PhpMyAdmin\Message;
1414
use PhpMyAdmin\Plugins;
15+
use PhpMyAdmin\Plugins\PluginType;
1516
use PhpMyAdmin\Template;
1617
use PhpMyAdmin\Util;
1718
use stdClass;
@@ -118,7 +119,7 @@ public function getHtmlForSchemaExport(string $db, int $page, mixed $formatParam
118119
}
119120

120121
$choice = Plugins::getChoice($exportList, $this->getFormat($formatParam, $exportTypeParam));
121-
$options = Plugins::getOptions('Schema', $exportList);
122+
$options = Plugins::getOptions(PluginType::Schema, $exportList);
122123

123124
return $this->template->render('database/designer/schema_export', [
124125
'db' => $db,

src/Export/Options.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use PhpMyAdmin\Plugins;
1414
use PhpMyAdmin\Plugins\ExportPlugin;
1515
use PhpMyAdmin\Plugins\ExportType;
16+
use PhpMyAdmin\Plugins\PluginType;
1617
use PhpMyAdmin\Query\Utilities;
1718
use PhpMyAdmin\Table\Table;
1819
use PhpMyAdmin\Util;
@@ -178,7 +179,7 @@ public function getOptions(
178179
'hidden_inputs' => $hiddenInputs,
179180
'export_method' => $_POST['quick_or_custom'] ?? $config->config->Export->method,
180181
'plugins_choice' => $dropdown,
181-
'options' => Plugins::getOptions('Export', $exportList),
182+
'options' => Plugins::getOptions(PluginType::Export, $exportList),
182183
'can_convert_kanji' => Encoding::canConvertKanji(),
183184
'exec_time_limit' => $config->settings['ExecTimeLimit'],
184185
'rows' => $rows,

0 commit comments

Comments
 (0)