Skip to content

Commit c6c9aeb

Browse files
committed
Merge #19124 - Refactoring move copy
The goal of this was to partition the big method into smaller easier to understand chunks and get rid of globals. This code is still far from perfect but I have no idea how to proceed further right now. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2 parents 70b67fa + c14efeb commit c6c9aeb

17 files changed

Lines changed: 830 additions & 710 deletions

app/services.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
use PhpMyAdmin\Table\ColumnsDefinition;
4949
use PhpMyAdmin\Table\Indexes;
5050
use PhpMyAdmin\Table\Search;
51+
use PhpMyAdmin\Table\TableMover;
5152
use PhpMyAdmin\Template;
5253
use PhpMyAdmin\Theme\ThemeManager;
5354
use PhpMyAdmin\Tracking\Tracking;
@@ -135,7 +136,7 @@
135136
],
136137
'operations' => [
137138
'class' => Operations::class,
138-
'arguments' => ['$dbi' => '@dbi', '$relation' => '@relation'],
139+
'arguments' => ['$dbi' => '@dbi', '$relation' => '@relation', '$tableMover' => '@table_mover'],
139140
],
140141
'partitioning_maintenance' => [
141142
'class' => Maintenance::class,
@@ -226,5 +227,6 @@
226227
PhpMyAdmin\ResponseRenderer::class => 'response',
227228
'bookmarkRepository' => ['class' => BookmarkRepository::class, 'arguments' => ['@dbi', '@relation']],
228229
'console' => ['class' => Console::class, 'arguments' => [ '@relation', '@template', '@bookmarkRepository']],
230+
'table_mover' => ['class' => TableMover::class, 'arguments' => ['@dbi', '@relation']],
229231
],
230232
];

app/services_controllers.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,15 @@
263263
'$operations' => '@operations',
264264
'$structureController' => '@' . Database\StructureController::class,
265265
'$userPrivilegesFactory' => '@' . UserPrivilegesFactory::class,
266+
'$tableMover' => '@table_mover',
266267
],
267268
],
268269
Database\Structure\CopyTableWithPrefixController::class => [
269270
'class' => Database\Structure\CopyTableWithPrefixController::class,
270-
'arguments' => ['$structureController' => '@' . Database\StructureController::class],
271+
'arguments' => [
272+
'$structureController' => '@' . Database\StructureController::class,
273+
'$tableMover' => '@table_mover',
274+
],
271275
],
272276
Database\Structure\DropFormController::class => [
273277
'class' => Database\Structure\DropFormController::class,

phpstan-baseline.neon

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,7 +1891,7 @@ parameters:
18911891
path: src/Controllers/Database/Structure/CentralColumns/RemoveController.php
18921892

18931893
-
1894-
message: "#^Parameter \\#5 \\$what of static method PhpMyAdmin\\\\Table\\\\Table\\:\\:moveCopy\\(\\) expects string, mixed given\\.$#"
1894+
message: "#^Parameter \\#1 \\$value of static method PhpMyAdmin\\\\Table\\\\MoveScope\\:\\:from\\(\\) expects int\\|string, mixed given\\.$#"
18951895
count: 1
18961896
path: src/Controllers/Database/Structure/CopyTableController.php
18971897

@@ -9482,7 +9482,7 @@ parameters:
94829482

94839483
-
94849484
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
9485-
count: 9
9485+
count: 8
94869486
path: src/Operations.php
94879487

94889488
-
@@ -9531,8 +9531,13 @@ parameters:
95319531
path: src/Operations.php
95329532

95339533
-
9534-
message: "#^Parameter \\#5 \\$what of static method PhpMyAdmin\\\\Table\\\\Table\\:\\:moveCopy\\(\\) expects string, mixed given\\.$#"
9535-
count: 2
9534+
message: "#^Parameter \\#1 \\$value of static method PhpMyAdmin\\\\Table\\\\MoveScope\\:\\:from\\(\\) expects int\\|string, mixed given\\.$#"
9535+
count: 1
9536+
path: src/Operations.php
9537+
9538+
-
9539+
message: "#^Parameter \\#1 \\$value of static method PhpMyAdmin\\\\Table\\\\MoveScope\\:\\:tryFrom\\(\\) expects int\\|string, mixed given\\.$#"
9540+
count: 1
95369541
path: src/Operations.php
95379542

95389543
-
@@ -10625,16 +10630,6 @@ parameters:
1062510630
count: 19
1062610631
path: src/Plugins/Export/ExportSql.php
1062710632

10628-
-
10629-
message: "#^Parameter \\#1 \\$line of method PhpMyAdmin\\\\Export\\\\Export\\:\\:outputHandler\\(\\) expects string, mixed given\\.$#"
10630-
count: 3
10631-
path: src/Plugins/Export/ExportSql.php
10632-
10633-
-
10634-
message: "#^Parameter \\#1 \\$sqlStatement of method PhpMyAdmin\\\\Plugins\\\\Export\\\\ExportSql\\:\\:generateComment\\(\\) expects string\\|null, mixed given\\.$#"
10635-
count: 3
10636-
path: src/Plugins/Export/ExportSql.php
10637-
1063810633
-
1063910634
message: "#^Parameter \\#1 \\$string of function strtoupper expects string, mixed given\\.$#"
1064010635
count: 1
@@ -13780,19 +13775,14 @@ parameters:
1378013775
count: 1
1378113776
path: src/Table/Search.php
1378213777

13783-
-
13784-
message: "#^Argument of an invalid type array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\AlterOperation\\>\\|null supplied for foreach, only iterables are supported\\.$#"
13785-
count: 2
13786-
path: src/Table/Table.php
13787-
1378813778
-
1378913779
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
1379013780
count: 1
1379113781
path: src/Table/Table.php
1379213782

1379313783
-
1379413784
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
13795-
count: 3
13785+
count: 2
1379613786
path: src/Table/Table.php
1379713787

1379813788
-
@@ -13890,19 +13880,9 @@ parameters:
1389013880
count: 6
1389113881
path: src/Table/Table.php
1389213882

13893-
-
13894-
message: "#^Cannot call method has\\(\\) on PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#"
13895-
count: 2
13896-
path: src/Table/Table.php
13897-
13898-
-
13899-
message: "#^Cannot cast mixed to string\\.$#"
13900-
count: 2
13901-
path: src/Table/Table.php
13902-
1390313883
-
1390413884
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
13905-
count: 17
13885+
count: 13
1390613886
path: src/Table/Table.php
1390713887

1390813888
-
@@ -13960,11 +13940,6 @@ parameters:
1396013940
count: 2
1396113941
path: src/Table/Table.php
1396213942

13963-
-
13964-
message: "#^Only booleans are allowed in a negated boolean, bool\\|string given\\.$#"
13965-
count: 1
13966-
path: src/Table/Table.php
13967-
1396813943
-
1396913944
message: "#^Only booleans are allowed in a negated boolean, int\\|false given\\.$#"
1397013945
count: 1
@@ -13975,11 +13950,6 @@ parameters:
1397513950
count: 1
1397613951
path: src/Table/Table.php
1397713952

13978-
-
13979-
message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
13980-
count: 2
13981-
path: src/Table/Table.php
13982-
1398313953
-
1398413954
message: "#^Only booleans are allowed in an elseif condition, int\\|false given\\.$#"
1398513955
count: 1
@@ -14010,21 +13980,11 @@ parameters:
1401013980
count: 6
1401113981
path: src/Table/Table.php
1401213982

14013-
-
14014-
message: "#^Parameter \\#1 \\$list of class PhpMyAdmin\\\\SqlParser\\\\Parser constructor expects PhpMyAdmin\\\\SqlParser\\\\TokensList\\|PhpMyAdmin\\\\SqlParser\\\\UtfString\\|string\\|null, mixed given\\.$#"
14015-
count: 3
14016-
path: src/Table/Table.php
14017-
1401813983
-
1401913984
message: "#^Parameter \\#1 \\$str of method PhpMyAdmin\\\\DatabaseInterface\\:\\:quoteString\\(\\) expects string, mixed given\\.$#"
1402013985
count: 9
1402113986
path: src/Table/Table.php
1402213987

14023-
-
14024-
message: "#^Parameter \\#1 \\$str of method PhpMyAdmin\\\\DatabaseInterface\\:\\:quoteString\\(\\) expects string, string\\|null given\\.$#"
14025-
count: 6
14026-
path: src/Table/Table.php
14027-
1402813988
-
1402913989
message: "#^Parameter \\#1 \\$string of function substr expects string, mixed given\\.$#"
1403013990
count: 2
@@ -14090,6 +14050,46 @@ parameters:
1409014050
count: 1
1409114051
path: src/Table/Table.php
1409214052

14053+
-
14054+
message: "#^Argument of an invalid type array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\AlterOperation\\>\\|null supplied for foreach, only iterables are supported\\.$#"
14055+
count: 2
14056+
path: src/Table/TableMover.php
14057+
14058+
-
14059+
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
14060+
count: 1
14061+
path: src/Table/TableMover.php
14062+
14063+
-
14064+
message: "#^Cannot call method has\\(\\) on PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#"
14065+
count: 2
14066+
path: src/Table/TableMover.php
14067+
14068+
-
14069+
message: "#^Cannot cast mixed to string\\.$#"
14070+
count: 2
14071+
path: src/Table/TableMover.php
14072+
14073+
-
14074+
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
14075+
count: 1
14076+
path: src/Table/TableMover.php
14077+
14078+
-
14079+
message: "#^Only booleans are allowed in a negated boolean, bool\\|string given\\.$#"
14080+
count: 1
14081+
path: src/Table/TableMover.php
14082+
14083+
-
14084+
message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
14085+
count: 2
14086+
path: src/Table/TableMover.php
14087+
14088+
-
14089+
message: "#^Parameter \\#1 \\$str of method PhpMyAdmin\\\\DatabaseInterface\\:\\:quoteString\\(\\) expects string, string\\|null given\\.$#"
14090+
count: 6
14091+
path: src/Table/TableMover.php
14092+
1409314093
-
1409414094
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
1409514095
count: 1
@@ -16102,7 +16102,7 @@ parameters:
1610216102

1610316103
-
1610416104
message: "#^Parameter \\#2 \\$haystack of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, mixed given\\.$#"
16105-
count: 10
16105+
count: 4
1610616106
path: tests/unit/Plugins/Export/ExportSqlTest.php
1610716107

1610816108
-

0 commit comments

Comments
 (0)