Skip to content

Commit

Permalink
Merge #19124 - Refactoring move copy
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
MauricioFauth committed May 10, 2024
2 parents 70b67fa + c14efeb commit c6c9aeb
Show file tree
Hide file tree
Showing 17 changed files with 830 additions and 710 deletions.
4 changes: 3 additions & 1 deletion app/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
use PhpMyAdmin\Table\ColumnsDefinition;
use PhpMyAdmin\Table\Indexes;
use PhpMyAdmin\Table\Search;
use PhpMyAdmin\Table\TableMover;
use PhpMyAdmin\Template;
use PhpMyAdmin\Theme\ThemeManager;
use PhpMyAdmin\Tracking\Tracking;
Expand Down Expand Up @@ -135,7 +136,7 @@
],
'operations' => [
'class' => Operations::class,
'arguments' => ['$dbi' => '@dbi', '$relation' => '@relation'],
'arguments' => ['$dbi' => '@dbi', '$relation' => '@relation', '$tableMover' => '@table_mover'],
],
'partitioning_maintenance' => [
'class' => Maintenance::class,
Expand Down Expand Up @@ -226,5 +227,6 @@
PhpMyAdmin\ResponseRenderer::class => 'response',
'bookmarkRepository' => ['class' => BookmarkRepository::class, 'arguments' => ['@dbi', '@relation']],
'console' => ['class' => Console::class, 'arguments' => [ '@relation', '@template', '@bookmarkRepository']],
'table_mover' => ['class' => TableMover::class, 'arguments' => ['@dbi', '@relation']],
],
];
6 changes: 5 additions & 1 deletion app/services_controllers.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,15 @@
'$operations' => '@operations',
'$structureController' => '@' . Database\StructureController::class,
'$userPrivilegesFactory' => '@' . UserPrivilegesFactory::class,
'$tableMover' => '@table_mover',
],
],
Database\Structure\CopyTableWithPrefixController::class => [
'class' => Database\Structure\CopyTableWithPrefixController::class,
'arguments' => ['$structureController' => '@' . Database\StructureController::class],
'arguments' => [
'$structureController' => '@' . Database\StructureController::class,
'$tableMover' => '@table_mover',
],
],
Database\Structure\DropFormController::class => [
'class' => Database\Structure\DropFormController::class,
Expand Down
104 changes: 52 additions & 52 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1891,7 +1891,7 @@ parameters:
path: src/Controllers/Database/Structure/CentralColumns/RemoveController.php

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

Expand Down Expand Up @@ -9482,7 +9482,7 @@ parameters:

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

-
Expand Down Expand Up @@ -9531,8 +9531,13 @@ parameters:
path: src/Operations.php

-
message: "#^Parameter \\#5 \\$what of static method PhpMyAdmin\\\\Table\\\\Table\\:\\:moveCopy\\(\\) expects string, mixed given\\.$#"
count: 2
message: "#^Parameter \\#1 \\$value of static method PhpMyAdmin\\\\Table\\\\MoveScope\\:\\:from\\(\\) expects int\\|string, mixed given\\.$#"
count: 1
path: src/Operations.php

-
message: "#^Parameter \\#1 \\$value of static method PhpMyAdmin\\\\Table\\\\MoveScope\\:\\:tryFrom\\(\\) expects int\\|string, mixed given\\.$#"
count: 1
path: src/Operations.php

-
Expand Down Expand Up @@ -10625,16 +10630,6 @@ parameters:
count: 19
path: src/Plugins/Export/ExportSql.php

-
message: "#^Parameter \\#1 \\$line of method PhpMyAdmin\\\\Export\\\\Export\\:\\:outputHandler\\(\\) expects string, mixed given\\.$#"
count: 3
path: src/Plugins/Export/ExportSql.php

-
message: "#^Parameter \\#1 \\$sqlStatement of method PhpMyAdmin\\\\Plugins\\\\Export\\\\ExportSql\\:\\:generateComment\\(\\) expects string\\|null, mixed given\\.$#"
count: 3
path: src/Plugins/Export/ExportSql.php

-
message: "#^Parameter \\#1 \\$string of function strtoupper expects string, mixed given\\.$#"
count: 1
Expand Down Expand Up @@ -13780,19 +13775,14 @@ parameters:
count: 1
path: src/Table/Search.php

-
message: "#^Argument of an invalid type array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\AlterOperation\\>\\|null supplied for foreach, only iterables are supported\\.$#"
count: 2
path: src/Table/Table.php

-
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
count: 1
path: src/Table/Table.php

-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 3
count: 2
path: src/Table/Table.php

-
Expand Down Expand Up @@ -13890,19 +13880,9 @@ parameters:
count: 6
path: src/Table/Table.php

-
message: "#^Cannot call method has\\(\\) on PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#"
count: 2
path: src/Table/Table.php

-
message: "#^Cannot cast mixed to string\\.$#"
count: 2
path: src/Table/Table.php

-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 17
count: 13
path: src/Table/Table.php

-
Expand Down Expand Up @@ -13960,11 +13940,6 @@ parameters:
count: 2
path: src/Table/Table.php

-
message: "#^Only booleans are allowed in a negated boolean, bool\\|string given\\.$#"
count: 1
path: src/Table/Table.php

-
message: "#^Only booleans are allowed in a negated boolean, int\\|false given\\.$#"
count: 1
Expand All @@ -13975,11 +13950,6 @@ parameters:
count: 1
path: src/Table/Table.php

-
message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
count: 2
path: src/Table/Table.php

-
message: "#^Only booleans are allowed in an elseif condition, int\\|false given\\.$#"
count: 1
Expand Down Expand Up @@ -14010,21 +13980,11 @@ parameters:
count: 6
path: src/Table/Table.php

-
message: "#^Parameter \\#1 \\$list of class PhpMyAdmin\\\\SqlParser\\\\Parser constructor expects PhpMyAdmin\\\\SqlParser\\\\TokensList\\|PhpMyAdmin\\\\SqlParser\\\\UtfString\\|string\\|null, mixed given\\.$#"
count: 3
path: src/Table/Table.php

-
message: "#^Parameter \\#1 \\$str of method PhpMyAdmin\\\\DatabaseInterface\\:\\:quoteString\\(\\) expects string, mixed given\\.$#"
count: 9
path: src/Table/Table.php

-
message: "#^Parameter \\#1 \\$str of method PhpMyAdmin\\\\DatabaseInterface\\:\\:quoteString\\(\\) expects string, string\\|null given\\.$#"
count: 6
path: src/Table/Table.php

-
message: "#^Parameter \\#1 \\$string of function substr expects string, mixed given\\.$#"
count: 2
Expand Down Expand Up @@ -14090,6 +14050,46 @@ parameters:
count: 1
path: src/Table/Table.php

-
message: "#^Argument of an invalid type array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\AlterOperation\\>\\|null supplied for foreach, only iterables are supported\\.$#"
count: 2
path: src/Table/TableMover.php

-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
path: src/Table/TableMover.php

-
message: "#^Cannot call method has\\(\\) on PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#"
count: 2
path: src/Table/TableMover.php

-
message: "#^Cannot cast mixed to string\\.$#"
count: 2
path: src/Table/TableMover.php

-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 1
path: src/Table/TableMover.php

-
message: "#^Only booleans are allowed in a negated boolean, bool\\|string given\\.$#"
count: 1
path: src/Table/TableMover.php

-
message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
count: 2
path: src/Table/TableMover.php

-
message: "#^Parameter \\#1 \\$str of method PhpMyAdmin\\\\DatabaseInterface\\:\\:quoteString\\(\\) expects string, string\\|null given\\.$#"
count: 6
path: src/Table/TableMover.php

-
message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#"
count: 1
Expand Down Expand Up @@ -16102,7 +16102,7 @@ parameters:

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

-
Expand Down
Loading

0 comments on commit c6c9aeb

Please sign in to comment.