Skip to content

Commit 0dd9e4f

Browse files
Merge pull request #18944 from MauricioFauth/connection-type-enum
Create ConnectionType enum
2 parents 8ea7637 + 3353b47 commit 0dd9e4f

61 files changed

Lines changed: 641 additions & 719 deletions

Some content is hidden

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

phpstan-baseline.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7331,7 +7331,7 @@ parameters:
73317331
path: src/DatabaseInterface.php
73327332

73337333
-
7334-
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(mixed\\)\\: mixed\\)\\|null, Closure\\(string, 0\\|1\\|2\\=\\)\\: non\\-empty\\-string given\\.$#"
7334+
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(mixed\\)\\: mixed\\)\\|null, Closure\\(string, PhpMyAdmin\\\\Dbal\\\\ConnectionType\\=\\)\\: non\\-empty\\-string given\\.$#"
73357335
count: 1
73367336
path: src/DatabaseInterface.php
73377337

psalm-baseline.xml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5058,9 +5058,6 @@
50585058
<DeprecatedProperty>
50595059
<code>Routing::$route</code>
50605060
</DeprecatedProperty>
5061-
<InvalidDocblock>
5062-
<code>private array $connections = [];</code>
5063-
</InvalidDocblock>
50645061
<InvalidOperand>
50655062
<code><![CDATA[$row['Data_free']]]></code>
50665063
<code><![CDATA[$row['Data_length']]]></code>
@@ -5072,18 +5069,6 @@
50725069
<MixedArgument>
50735070
<code>$a</code>
50745071
<code>$b</code>
5075-
<code><![CDATA[$this->connections[$connectionType]]]></code>
5076-
<code><![CDATA[$this->connections[$connectionType]]]></code>
5077-
<code><![CDATA[$this->connections[$connectionType]]]></code>
5078-
<code><![CDATA[$this->connections[$connectionType]]]></code>
5079-
<code><![CDATA[$this->connections[$connectionType]]]></code>
5080-
<code><![CDATA[$this->connections[$connectionType]]]></code>
5081-
<code><![CDATA[$this->connections[$connectionType]]]></code>
5082-
<code><![CDATA[$this->connections[$connectionType]]]></code>
5083-
<code><![CDATA[$this->connections[$connectionType]]]></code>
5084-
<code><![CDATA[$this->connections[$connectionType]]]></code>
5085-
<code><![CDATA[$this->connections[$connectionType]]]></code>
5086-
<code><![CDATA[$this->connections[$connectionType]]]></code>
50875072
<code><![CDATA[$this->versionComment]]></code>
50885073
<code><![CDATA[$this->versionString]]></code>
50895074
</MixedArgument>

src/Bookmarks/Bookmark.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
use PhpMyAdmin\ConfigStorage\Features\BookmarkFeature;
1111
use PhpMyAdmin\DatabaseInterface;
12-
use PhpMyAdmin\Dbal\Connection;
12+
use PhpMyAdmin\Dbal\ConnectionType;
1313
use PhpMyAdmin\Util;
1414

1515
use function count;
@@ -95,7 +95,7 @@ public function save(): bool
9595
. $this->dbi->quoteString($this->query) . ', '
9696
. $this->dbi->quoteString($this->label) . ')';
9797

98-
return (bool) $this->dbi->query($query, Connection::TYPE_CONTROL);
98+
return (bool) $this->dbi->query($query, ConnectionType::ControlUser);
9999
}
100100

101101
/**
@@ -107,7 +107,7 @@ public function delete(): bool
107107
. '.' . Util::backquote($this->bookmarkFeature->bookmark)
108108
. ' WHERE id = ' . $this->id;
109109

110-
return (bool) $this->dbi->tryQuery($query, Connection::TYPE_CONTROL);
110+
return (bool) $this->dbi->tryQuery($query, ConnectionType::ControlUser);
111111
}
112112

113113
/**

src/Bookmarks/BookmarkRepository.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use PhpMyAdmin\ConfigStorage\Features\BookmarkFeature;
1212
use PhpMyAdmin\ConfigStorage\Relation;
1313
use PhpMyAdmin\DatabaseInterface;
14-
use PhpMyAdmin\Dbal\Connection;
14+
use PhpMyAdmin\Dbal\ConnectionType;
1515
use PhpMyAdmin\Identifiers\DatabaseName;
1616
use PhpMyAdmin\Util;
1717

@@ -93,7 +93,7 @@ public function getList(
9393

9494
$query .= ' ORDER BY label ASC';
9595

96-
$result = $this->dbi->fetchResult($query, null, null, Connection::TYPE_CONTROL);
96+
$result = $this->dbi->fetchResult($query, null, null, ConnectionType::ControlUser);
9797

9898
$bookmarks = [];
9999
foreach ($result as $row) {
@@ -131,7 +131,7 @@ public function get(
131131

132132
$query .= ' LIMIT 1';
133133

134-
$result = $this->dbi->fetchSingleRow($query, DatabaseInterface::FETCH_ASSOC, Connection::TYPE_CONTROL);
134+
$result = $this->dbi->fetchSingleRow($query, DatabaseInterface::FETCH_ASSOC, ConnectionType::ControlUser);
135135
if ($result !== null) {
136136
return $this->createFromRow($result);
137137
}
@@ -159,7 +159,7 @@ public function getByLabel(
159159
. ' AND user = ' . $this->dbi->quoteString($user)
160160
. ' LIMIT 1';
161161

162-
$result = $this->dbi->fetchSingleRow($query, DatabaseInterface::FETCH_ASSOC, Connection::TYPE_CONTROL);
162+
$result = $this->dbi->fetchSingleRow($query, DatabaseInterface::FETCH_ASSOC, ConnectionType::ControlUser);
163163
if ($result !== null) {
164164
return $this->createFromRow($result);
165165
}

src/Config.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use PhpMyAdmin\Config\Settings;
88
use PhpMyAdmin\Config\Settings\Server;
99
use PhpMyAdmin\ConfigStorage\Relation;
10-
use PhpMyAdmin\Dbal\Connection;
10+
use PhpMyAdmin\Dbal\ConnectionType;
1111
use PhpMyAdmin\Exceptions\ConfigException;
1212
use PhpMyAdmin\Routing\Routing;
1313
use PhpMyAdmin\Theme\ThemeManager;
@@ -70,7 +70,6 @@
7070
/**
7171
* Configuration handling
7272
*
73-
* @psalm-import-type ConnectionType from Connection
7473
* @psalm-import-type ServerSettingsType from Server
7574
* @psalm-import-type SettingsType from Settings
7675
*/
@@ -1105,12 +1104,10 @@ public function selectServer(mixed $serverParamFromRequest): int
11051104

11061105
/**
11071106
* Return connection parameters for the database server
1108-
*
1109-
* @psalm-param ConnectionType $connectionType
11101107
*/
1111-
public static function getConnectionParams(Server $currentServer, int $connectionType): Server
1108+
public static function getConnectionParams(Server $currentServer, ConnectionType $connectionType): Server
11121109
{
1113-
if ($connectionType !== Connection::TYPE_CONTROL) {
1110+
if ($connectionType !== ConnectionType::ControlUser) {
11141111
if ($currentServer->host !== '' && $currentServer->port !== '') {
11151112
return $currentServer;
11161113
}

0 commit comments

Comments
 (0)