Visitar URL original
Merge pull request #18946 from kamil-tekiela/Table-updateForeignKeys · phpmyadmin/phpmyadmin@45b5577 · GitHub
Skip to content

Commit 45b5577

Browse files
Merge pull request #18946 from kamil-tekiela/Table-updateForeignKeys
Add type hint to Table::updateForeignKeys()
2 parents ec0926d + 0e1e91e commit 45b5577

4 files changed

Lines changed: 11 additions & 48 deletions

File tree

‎phpstan-baseline.neon‎

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4830,21 +4830,6 @@ parameters:
48304830
count: 1
48314831
path: src/Controllers/Table/RelationController.php
48324832

4833-
-
4834-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
4835-
count: 1
4836-
path: src/Controllers/Table/RelationController.php
4837-
4838-
-
4839-
message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
4840-
count: 1
4841-
path: src/Controllers/Table/RelationController.php
4842-
4843-
-
4844-
message: "#^Parameter \\#1 \\$content of method PhpMyAdmin\\\\ResponseRenderer\\:\\:addHTML\\(\\) expects string, mixed given\\.$#"
4845-
count: 1
4846-
path: src/Controllers/Table/RelationController.php
4847-
48484833
-
48494834
message: "#^Parameter \\#1 \\$dbName of method PhpMyAdmin\\\\DatabaseInterface\\:\\:getTable\\(\\) expects string, mixed given\\.$#"
48504835
count: 1
@@ -4880,11 +4865,6 @@ parameters:
48804865
count: 1
48814866
path: src/Controllers/Table/RelationController.php
48824867

4883-
-
4884-
message: "#^Parameter \\#1 \\$queryData of static method PhpMyAdmin\\\\Core\\:\\:previewSQL\\(\\) expects array\\|string, mixed given\\.$#"
4885-
count: 1
4886-
path: src/Controllers/Table/RelationController.php
4887-
48884868
-
48894869
message: "#^Parameter \\#2 \\$callback of function usort expects callable\\(mixed, mixed\\)\\: int, Closure\\(string, string\\)\\: int\\<\\-1, 1\\> given\\.$#"
48904870
count: 1
@@ -15190,16 +15170,6 @@ parameters:
1519015170
count: 2
1519115171
path: src/Table/Table.php
1519215172

15193-
-
15194-
message: "#^Parameter \\#7 \\$onDelete of method PhpMyAdmin\\\\Table\\\\Table\\:\\:getSQLToCreateForeignKey\\(\\) expects string\\|null, mixed given\\.$#"
15195-
count: 2
15196-
path: src/Table/Table.php
15197-
15198-
-
15199-
message: "#^Parameter \\#8 \\$onUpdate of method PhpMyAdmin\\\\Table\\\\Table\\:\\:getSQLToCreateForeignKey\\(\\) expects string\\|null, mixed given\\.$#"
15200-
count: 2
15201-
path: src/Table/Table.php
15202-
1520315173
-
1520415174
message: "#^Property PhpMyAdmin\\\\Table\\\\Table\\:\\:\\$uiprefs \\(array\\) does not accept mixed\\.$#"
1520515175
count: 1

‎psalm-baseline.xml‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3724,8 +3724,6 @@
37243724
<MixedArgument>
37253725
<code>$foreignDb</code>
37263726
<code>$foreignTable</code>
3727-
<code>$html</code>
3728-
<code>$previewSqlData</code>
37293727
<code><![CDATA[array_key_exists('foreign_keys_data', $relationsForeign)
37303728
? $relationsForeign['foreign_keys_data']
37313729
: []]]></code>
@@ -3738,7 +3736,6 @@
37383736
<code><![CDATA[$oneKey['ref_table_name']]]></code>
37393737
</MixedArrayAccess>
37403738
<MixedAssignment>
3741-
<code><![CDATA[$GLOBALS['display_query']]]></code>
37423739
<code>$existrelForeign</code>
37433740
<code>$foreignDb</code>
37443741
<code>$foreignTable</code>
@@ -3769,7 +3766,6 @@
37693766
<code>$foreignTable</code>
37703767
</PossiblyInvalidCast>
37713768
<RiskyTruthyFalsyComparison>
3772-
<code>! $seenError</code>
37733769
<code>$foreignDb</code>
37743770
<code>$foreignDb</code>
37753771
<code>$foreignTable</code>
@@ -12023,10 +12019,6 @@
1202312019
<code>$masterField</code>
1202412020
<code>$oneField</code>
1202512021
<code>$oneField</code>
12026-
<code><![CDATA[$optionsArray[$_POST['on_delete'][$masterFieldMd5]]]]></code>
12027-
<code><![CDATA[$optionsArray[$_POST['on_update'][$masterFieldMd5]]]]></code>
12028-
<code><![CDATA[$optionsArray[$existrelForeign[$masterFieldMd5]['on_delete'] ?? ''] ?? null]]></code>
12029-
<code><![CDATA[$optionsArray[$existrelForeign[$masterFieldMd5]['on_update'] ?? ''] ?? null]]></code>
1203012022
<code><![CDATA[$options['expr']]]></code>
1203112023
<code><![CDATA[$row['Type']]]></code>
1203212024
<code><![CDATA[$this->uiprefs[$property]]]></code>

‎src/Controllers/Table/RelationController.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public function __invoke(ServerRequest $request): void
101101
// updates for foreign keys
102102
$multiEditColumnsName = $_POST['foreign_key_fields_name'] ?? null;
103103
$previewSqlData = '';
104+
$displayQuery = '';
104105
$seenError = false;
105106

106107
// (for now, one index name only; we keep the definitions if the
@@ -133,7 +134,7 @@ public function __invoke(ServerRequest $request): void
133134
return;
134135
}
135136

136-
if (! empty($displayQuery) && ! $seenError) {
137+
if ($displayQuery !== '' && ! $seenError) {
137138
$GLOBALS['display_query'] = $displayQuery;
138139
$this->response->addHTML(
139140
Generator::getMessage(

‎src/Table/Table.php‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,15 +1987,15 @@ public function updateInternalRelations(
19871987
/**
19881988
* Function to handle foreign key updates
19891989
*
1990-
* @param mixed[] $destinationForeignDb destination foreign database
1991-
* @param mixed[] $multiEditColumnsName multi edit column names
1992-
* @param mixed[] $destinationForeignTable destination foreign table
1993-
* @param mixed[] $destinationForeignColumn destination foreign column
1994-
* @param mixed[] $optionsArray options array
1995-
* @param string $table current table
1996-
* @param mixed[] $existrelForeign db, table, column
1997-
*
1998-
* @return mixed[]
1990+
* @param mixed[] $destinationForeignDb destination foreign database
1991+
* @param mixed[] $multiEditColumnsName multi edit column names
1992+
* @param mixed[] $destinationForeignTable destination foreign table
1993+
* @param mixed[] $destinationForeignColumn destination foreign column
1994+
* @param string[] $optionsArray options array
1995+
* @param string $table current table
1996+
* @param mixed[] $existrelForeign db, table, column
1997+
*
1998+
* @return array{string, string, string, bool}
19991999
*/
20002000
public function updateForeignKeys(
20012001
array $destinationForeignDb,

0 commit comments

Comments
 (0)