Skip to content

Commit a11b384

Browse files
Merge pull request #20450 from kamil-tekiela/Small-refactoring
Small refactoring
2 parents 9315397 + 0417705 commit a11b384

6 files changed

Lines changed: 16 additions & 47 deletions

File tree

‎phpstan-baseline.neon‎

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,16 +1572,10 @@ parameters:
15721572
count: 1
15731573
path: src/Controllers/Database/StructureController.php
15741574

1575-
-
1576-
message: '#^Binary operation "\." between mixed and array\<string\>\|string\|false results in an error\.$#'
1577-
identifier: binaryOp.invalid
1578-
count: 1
1579-
path: src/Controllers/Database/StructureController.php
1580-
15811575
-
15821576
message: '#^Binary operation "\." between non\-empty\-string and array\<string\>\|string\|false results in an error\.$#'
15831577
identifier: binaryOp.invalid
1584-
count: 1
1578+
count: 2
15851579
path: src/Controllers/Database/StructureController.php
15861580

15871581
-
@@ -1596,6 +1590,12 @@ parameters:
15961590
count: 2
15971591
path: src/Controllers/Database/StructureController.php
15981592

1593+
-
1594+
message: '#^Cannot cast mixed to string\.$#'
1595+
identifier: cast.string
1596+
count: 1
1597+
path: src/Controllers/Database/StructureController.php
1598+
15991599
-
16001600
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
16011601
identifier: notEqual.notAllowed
@@ -2227,7 +2227,7 @@ parameters:
22272227
path: src/Controllers/Server/ReplicationController.php
22282228

22292229
-
2230-
message: '#^Static property PhpMyAdmin\\UrlParams\:\:\$params \(array\<string, bool\|int\|string\>\) does not accept array\<mixed, mixed\>\.$#'
2230+
message: '#^Static property PhpMyAdmin\\UrlParams\:\:\$params \(array\<string, bool\|int\|string\>\) does not accept array\<mixed, string\>\.$#'
22312231
identifier: assign.propertyType
22322232
count: 1
22332233
path: src/Controllers/Server/ReplicationController.php
@@ -7410,12 +7410,6 @@ parameters:
74107410
count: 1
74117411
path: src/Navigation/Navigation.php
74127412

7413-
-
7414-
message: '#^Access to an undefined property PhpMyAdmin\\Navigation\\Nodes\\Node\:\:\$secondIcon\.$#'
7415-
identifier: property.notFound
7416-
count: 1
7417-
path: src/Navigation/NavigationTree.php
7418-
74197413
-
74207414
message: '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\.$#'
74217415
identifier: foreach.nonIterable
@@ -13164,18 +13158,6 @@ parameters:
1316413158
count: 2
1316513159
path: src/WebAuthn/WebauthnLibServer.php
1316613160

13167-
-
13168-
message: '#^Call to static method Webmozart\\Assert\\Assert\:\:isInstanceOf\(\) with Webauthn\\PublicKeyCredentialCreationOptions and ''Webauthn\\\\PublicKeyCredentialCreationOptions'' will always evaluate to true\.$#'
13169-
identifier: staticMethod.alreadyNarrowedType
13170-
count: 1
13171-
path: src/WebAuthn/WebauthnLibServer.php
13172-
13173-
-
13174-
message: '#^Call to static method Webmozart\\Assert\\Assert\:\:isInstanceOf\(\) with Webauthn\\PublicKeyCredentialRequestOptions and ''Webauthn\\\\PublicKeyCredentialRequestOptions'' will always evaluate to true\.$#'
13175-
identifier: staticMethod.alreadyNarrowedType
13176-
count: 1
13177-
path: src/WebAuthn/WebauthnLibServer.php
13178-
1317913161
-
1318013162
message: '#^Cannot access offset ''authenticatorData'' on mixed\.$#'
1318113163
identifier: offsetAccess.nonOffsetAccessible

‎psalm-baseline.xml‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,10 +1077,6 @@
10771077
<code><![CDATA[$currentTable['TABLE_NAME']]]></code>
10781078
<code><![CDATA[$currentTable['TABLE_ROWS']]]></code>
10791079
</PossiblyNullOperand>
1080-
<RedundantCast>
1081-
<code><![CDATA[(string) $_REQUEST['tbl_group']]]></code>
1082-
<code><![CDATA[(string) $_REQUEST['tbl_group']]]></code>
1083-
</RedundantCast>
10841080
<RiskyTruthyFalsyComparison>
10851081
<code><![CDATA[! $currentTable['COUNTED']]]></code>
10861082
</RiskyTruthyFalsyComparison>
@@ -8415,10 +8411,6 @@
84158411
<code><![CDATA[$assertionResponseDecoded]]></code>
84168412
<code><![CDATA[$attestationResponseDecoded]]></code>
84178413
</MixedAssignment>
8418-
<RedundantCondition>
8419-
<code><![CDATA[isInstanceOf]]></code>
8420-
<code><![CDATA[isInstanceOf]]></code>
8421-
</RedundantCondition>
84228414
</file>
84238415
<file src="src/ZipExtension.php">
84248416
<ArgumentTypeCoercion>

‎src/Controllers/Database/StructureController.php‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
use function implode;
4545
use function in_array;
4646
use function is_numeric;
47-
use function is_scalar;
4847
use function is_string;
4948
use function max;
5049
use function mb_substr;
@@ -108,7 +107,7 @@ private function getDatabaseInfo(ServerRequest $request): void
108107

109108
// Special speedup for newer MySQL Versions (in 4.0 format changed)
110109
if ($this->config->config->SkipLockedTables) {
111-
$tables = $this->getTablesWhenOpen(Current::$database);
110+
$tables = $this->getTablesWhenOpen(Current::$database, (string) $request->getParam('tbl_group'));
112111
$totalNumTables = count($tables);
113112
} else {
114113
[$tables, $totalNumTables] = $this->getDbInfo(
@@ -1041,7 +1040,7 @@ public function getDbInfo(
10411040
*
10421041
* @return (string|int|null)[][] list of tables
10431042
*/
1044-
private function getTablesWhenOpen(string $db): array
1043+
private function getTablesWhenOpen(string $db, string $tableGroupParam): array
10451044
{
10461045
$openTables = $this->dbi->query(
10471046
'SHOW OPEN TABLES FROM ' . Util::backquote($db) . ' WHERE In_use > 0;',
@@ -1063,14 +1062,10 @@ private function getTablesWhenOpen(string $db): array
10631062
$tables = [];
10641063
$tblGroupSql = '';
10651064
$whereAdded = false;
1066-
if (
1067-
isset($_REQUEST['tbl_group'])
1068-
&& is_scalar($_REQUEST['tbl_group'])
1069-
&& (string) $_REQUEST['tbl_group'] !== ''
1070-
) {
1071-
$group = $this->dbi->escapeMysqlWildcards((string) $_REQUEST['tbl_group']);
1065+
if ($tableGroupParam !== '') {
1066+
$group = $this->dbi->escapeMysqlWildcards($tableGroupParam);
10721067
$groupWithSeparator = $this->dbi->escapeMysqlWildcards(
1073-
$_REQUEST['tbl_group'] . $this->config->config->NavigationTreeTableSeparator,
1068+
$tableGroupParam . $this->config->config->NavigationTreeTableSeparator,
10741069
);
10751070
$tblGroupSql .= ' WHERE ('
10761071
. Util::backquote('Tables_in_' . $db)

‎src/Controllers/Server/ReplicationController.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use PhpMyAdmin\Routing\Route;
1919
use PhpMyAdmin\Url;
2020
use PhpMyAdmin\UrlParams;
21+
use Webmozart\Assert\Assert;
2122

2223
use function is_array;
2324

@@ -55,6 +56,7 @@ public function __invoke(ServerRequest $request): Response
5556

5657
$urlParams = $request->getParsedBodyParam('url_params');
5758
if (is_array($urlParams)) {
59+
Assert::allString($urlParams);
5860
UrlParams::$params = $urlParams;
5961
}
6062

‎src/Navigation/NavigationTree.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ private function renderNode(
11041104
'li_classes' => $liClasses,
11051105
'control_buttons' => $controlButtons,
11061106
'node_is_container' => $nodeIsContainer,
1107-
'has_second_icon' => isset($node->secondIcon),
1107+
'has_second_icon' => $node instanceof NodeTable && $node->secondIcon !== null,
11081108
'recursive' => ['html' => $recursiveHtml ?? '', 'has_wrapper' => $wrap, 'is_hidden' => ! $node->visible],
11091109
'icon_links' => $iconLinks,
11101110
'text_link' => $textLink,

‎src/WebAuthn/WebauthnLibServer.php‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ public function parseAndValidateAssertionResponse(
196196
'rpId' => $host,
197197
'timeout' => 60000,
198198
]);
199-
Assert::isInstanceOf($requestOptions, PublicKeyCredentialRequestOptions::class);
200199

201200
$attestationStatementSupportManager = new AttestationStatementSupportManager();
202201
$attestationStatementSupportManager->add(new NoneAttestationStatementSupport());
@@ -284,7 +283,6 @@ public function parseAndValidateAttestationResponse(
284283
'timeout' => 60000,
285284
];
286285
$credentialCreationOptions = PublicKeyCredentialCreationOptions::createFromArray($creationOptionsArray);
287-
Assert::isInstanceOf($credentialCreationOptions, PublicKeyCredentialCreationOptions::class);
288286

289287
$attestationStatementSupportManager = new AttestationStatementSupportManager();
290288
$attestationStatementSupportManager->add(new NoneAttestationStatementSupport());

0 commit comments

Comments
 (0)