Skip to content

Commit 5722cdb

Browse files
Merge pull request #19095 from MauricioFauth/controllers
Create InvocableController interface
2 parents 041107c + 181f971 commit 5722cdb

202 files changed

Lines changed: 1630 additions & 715 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

psalm-baseline.xml

Lines changed: 380 additions & 85 deletions
Large diffs are not rendered by default.

src/Controllers/AbstractController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
use function __;
1616

17-
abstract class AbstractController
17+
abstract class AbstractController implements InvocableController
1818
{
1919
public function __construct(protected ResponseRenderer $response, protected Template $template)
2020
{

src/Controllers/BrowseForeignersController.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use PhpMyAdmin\BrowseForeigners;
88
use PhpMyAdmin\ConfigStorage\Relation;
9+
use PhpMyAdmin\Http\Response;
910
use PhpMyAdmin\Http\ServerRequest;
1011
use PhpMyAdmin\ResponseRenderer;
1112
use PhpMyAdmin\Template;
@@ -24,7 +25,7 @@ public function __construct(
2425
parent::__construct($response, $template);
2526
}
2627

27-
public function __invoke(ServerRequest $request): void
28+
public function __invoke(ServerRequest $request): Response|null
2829
{
2930
/** @var string|null $database */
3031
$database = $request->getParsedBodyParam('db');
@@ -42,7 +43,7 @@ public function __invoke(ServerRequest $request): void
4243
$foreignFilter = $request->getParsedBodyParam('foreign_filter', '');
4344

4445
if (! isset($database, $table, $field)) {
45-
return;
46+
return null;
4647
}
4748

4849
$this->response->setMinimalFooter();
@@ -69,5 +70,7 @@ public function __invoke(ServerRequest $request): void
6970
$fieldKey,
7071
$data,
7172
));
73+
74+
return null;
7275
}
7376
}

src/Controllers/ChangeLogController.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use PhpMyAdmin\Config;
88
use PhpMyAdmin\Core;
9+
use PhpMyAdmin\Http\Response;
910
use PhpMyAdmin\Http\ServerRequest;
1011
use PhpMyAdmin\ResponseRenderer;
1112
use PhpMyAdmin\Template;
@@ -31,7 +32,7 @@ public function __construct(ResponseRenderer $response, Template $template, priv
3132
parent::__construct($response, $template);
3233
}
3334

34-
public function __invoke(ServerRequest $request): void
35+
public function __invoke(ServerRequest $request): Response|null
3536
{
3637
$this->response->disable();
3738
$this->response->getHeader()->sendHttpHeaders();
@@ -52,7 +53,7 @@ public function __invoke(ServerRequest $request): void
5253
. '" rel="noopener noreferrer" target="_blank">phpmyadmin.net</a>',
5354
);
5455

55-
return;
56+
return null;
5657
}
5758

5859
// Test if the file is in a compressed format
@@ -115,5 +116,7 @@ public function __invoke(ServerRequest $request): void
115116
$this->render('changelog', [
116117
'changelog' => preg_replace(array_keys($replaces), $replaces, $changelog),
117118
]);
119+
120+
return null;
118121
}
119122
}

src/Controllers/CheckRelationsController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PhpMyAdmin\Config;
88
use PhpMyAdmin\ConfigStorage\Relation;
99
use PhpMyAdmin\Current;
10+
use PhpMyAdmin\Http\Response;
1011
use PhpMyAdmin\Http\ServerRequest;
1112
use PhpMyAdmin\Identifiers\DatabaseName;
1213
use PhpMyAdmin\ResponseRenderer;
@@ -24,7 +25,7 @@ public function __construct(ResponseRenderer $response, Template $template, priv
2425
parent::__construct($response, $template);
2526
}
2627

27-
public function __invoke(ServerRequest $request): void
28+
public function __invoke(ServerRequest $request): Response|null
2829
{
2930
$cfgStorageDbName = $this->relation->getConfigurationStorageDbName();
3031

@@ -57,5 +58,7 @@ public function __invoke(ServerRequest $request): void
5758
'config_storage_database_name' => $cfgStorageDbName,
5859
'are_config_storage_tables_defined' => $this->relation->arePmadbTablesDefined(),
5960
]);
61+
62+
return null;
6063
}
6164
}

src/Controllers/CollationConnectionController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace PhpMyAdmin\Controllers;
66

77
use PhpMyAdmin\Config;
8+
use PhpMyAdmin\Http\Response;
89
use PhpMyAdmin\Http\ServerRequest;
910
use PhpMyAdmin\ResponseRenderer;
1011
use PhpMyAdmin\Template;
@@ -17,7 +18,7 @@ public function __construct(ResponseRenderer $response, Template $template, priv
1718
parent::__construct($response, $template);
1819
}
1920

20-
public function __invoke(ServerRequest $request): void
21+
public function __invoke(ServerRequest $request): Response|null
2122
{
2223
$this->config->setUserValue(
2324
null,
@@ -27,5 +28,7 @@ public function __invoke(ServerRequest $request): void
2728
);
2829

2930
$this->response->redirect('index.php?route=/' . Url::getCommonRaw([], '&'));
31+
32+
return null;
3033
}
3134
}

src/Controllers/ColumnController.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace PhpMyAdmin\Controllers;
66

77
use PhpMyAdmin\DatabaseInterface;
8+
use PhpMyAdmin\Http\Response;
89
use PhpMyAdmin\Http\ServerRequest;
910
use PhpMyAdmin\Message;
1011
use PhpMyAdmin\ResponseRenderer;
@@ -17,7 +18,7 @@ public function __construct(ResponseRenderer $response, Template $template, priv
1718
parent::__construct($response, $template);
1819
}
1920

20-
public function __invoke(ServerRequest $request): void
21+
public function __invoke(ServerRequest $request): Response|null
2122
{
2223
/** @var string|null $db */
2324
$db = $request->getParsedBodyParam('db');
@@ -28,9 +29,11 @@ public function __invoke(ServerRequest $request): void
2829
$this->response->setRequestStatus(false);
2930
$this->response->addJSON(['message' => Message::error()]);
3031

31-
return;
32+
return null;
3233
}
3334

3435
$this->response->addJSON(['columns' => $this->dbi->getColumnNames($db, $table)]);
36+
37+
return null;
3538
}
3639
}

src/Controllers/Console/Bookmark/AddController.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PhpMyAdmin\Bookmarks\BookmarkRepository;
88
use PhpMyAdmin\Config;
99
use PhpMyAdmin\Controllers\AbstractController;
10+
use PhpMyAdmin\Http\Response;
1011
use PhpMyAdmin\Http\ServerRequest;
1112
use PhpMyAdmin\ResponseRenderer;
1213
use PhpMyAdmin\Template;
@@ -24,7 +25,7 @@ public function __construct(
2425
parent::__construct($response, $template);
2526
}
2627

27-
public function __invoke(ServerRequest $request): void
28+
public function __invoke(ServerRequest $request): Response|null
2829
{
2930
$db = $request->getParsedBodyParam('db');
3031
$label = $request->getParsedBodyParam('label');
@@ -34,7 +35,7 @@ public function __invoke(ServerRequest $request): void
3435
if (! is_string($label) || ! is_string($db) || ! is_string($bookmarkQuery) || ! is_string($shared)) {
3536
$this->response->addJSON('message', __('Incomplete params'));
3637

37-
return;
38+
return null;
3839
}
3940

4041
$bookmark = $this->bookmarkRepository->createBookmark(
@@ -47,7 +48,7 @@ public function __invoke(ServerRequest $request): void
4748
if ($bookmark === false || ! $bookmark->save()) {
4849
$this->response->addJSON('message', __('Failed'));
4950

50-
return;
51+
return null;
5152
}
5253

5354
$bookmarkFields = [
@@ -60,5 +61,7 @@ public function __invoke(ServerRequest $request): void
6061
$this->response->addJSON('message', __('Succeeded'));
6162
$this->response->addJSON('data', $bookmarkFields);
6263
$this->response->addJSON('isShared', $shared === 'true');
64+
65+
return null;
6366
}
6467
}

src/Controllers/Console/Bookmark/RefreshController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use PhpMyAdmin\Console;
88
use PhpMyAdmin\Controllers\AbstractController;
9+
use PhpMyAdmin\Http\Response;
910
use PhpMyAdmin\Http\ServerRequest;
1011
use PhpMyAdmin\ResponseRenderer;
1112
use PhpMyAdmin\Template;
@@ -20,8 +21,10 @@ public function __construct(
2021
parent::__construct($response, $template);
2122
}
2223

23-
public function __invoke(ServerRequest $request): void
24+
public function __invoke(ServerRequest $request): Response|null
2425
{
2526
$this->response->addJSON('console_message_bookmark', $this->console->getBookmarkContent());
27+
28+
return null;
2629
}
2730
}

src/Controllers/Database/CentralColumns/PopulateColumnsController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PhpMyAdmin\Controllers\AbstractController;
88
use PhpMyAdmin\Current;
99
use PhpMyAdmin\Database\CentralColumns;
10+
use PhpMyAdmin\Http\Response;
1011
use PhpMyAdmin\Http\ServerRequest;
1112
use PhpMyAdmin\ResponseRenderer;
1213
use PhpMyAdmin\Template;
@@ -21,12 +22,14 @@ public function __construct(
2122
parent::__construct($response, $template);
2223
}
2324

24-
public function __invoke(ServerRequest $request): void
25+
public function __invoke(ServerRequest $request): Response|null
2526
{
2627
$columns = $this->centralColumns->getColumnsNotInCentralList(
2728
Current::$database,
2829
$request->getParsedBodyParam('selectedTable'),
2930
);
3031
$this->render('database/central_columns/populate_columns', ['columns' => $columns]);
32+
33+
return null;
3134
}
3235
}

0 commit comments

Comments
 (0)