Visitar URL original
Merge #20480 - Remove unused getters · phpmyadmin/phpmyadmin@9cb26dd · GitHub
Skip to content

Commit 9cb26dd

Browse files
committed
Merge #20480 - Remove unused getters
Pull-request: #20480 Signed-off-by: William Desportes <williamdes@wdes.fr>
2 parents 6cf52f9 + 5946188 commit 9cb26dd

9 files changed

Lines changed: 24 additions & 97 deletions

File tree

‎psalm-baseline.xml‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3127,11 +3127,6 @@
31273127
<code><![CDATA[$value['foreign_table']]]></code>
31283128
</PossiblyNullOperand>
31293129
</file>
3130-
<file src="src/Database/Designer/DesignerTable.php">
3131-
<PossiblyUnusedMethod>
3132-
<code><![CDATA[getTableEngine]]></code>
3133-
</PossiblyUnusedMethod>
3134-
</file>
31353130
<file src="src/Database/Events.php">
31363131
<PossiblyInvalidArgument>
31373132
<code><![CDATA[$_POST['item_comment']]]></code>
@@ -6360,9 +6355,6 @@
63606355
<PossiblyNullOperand>
63616356
<code><![CDATA[$nameRow[0]]]></code>
63626357
</PossiblyNullOperand>
6363-
<PossiblyUnusedMethod>
6364-
<code><![CDATA[isOffline]]></code>
6365-
</PossiblyUnusedMethod>
63666358
<RiskyCast>
63676359
<code><![CDATA[$_REQUEST['page_number']]]></code>
63686360
</RiskyCast>
@@ -6487,9 +6479,6 @@
64876479
<PossiblyNullArgument>
64886480
<code><![CDATA[$rel['foreign_field']]]></code>
64896481
</PossiblyNullArgument>
6490-
<PossiblyUnusedMethod>
6491-
<code><![CDATA[isWithDataDictionary]]></code>
6492-
</PossiblyUnusedMethod>
64936482
<RiskyTruthyFalsyComparison>
64946483
<code><![CDATA[$foreigner]]></code>
64956484
<code><![CDATA[$foreigner]]></code>

‎resources/templates/database/designer/database_tables.twig‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{% for designerTable in tables %}
22
{% set i = loop.index0 %}
33
{% set t_n_url = designerTable.getDbTableString()|escape('url') %}
4-
{% set db = designerTable.getDatabaseName() %}
4+
{% set db = designerTable.databaseName %}
55
{% set db_url = db|escape('url') %}
66
{% set t_n = designerTable.getDbTableString() %}
7-
{% set table_name = designerTable.getTableName()|escape('html') %}
7+
{% set table_name = designerTable.tableName|escape('html') %}
88
<input name="t_x[{{ t_n_url }}]" type="hidden" id="t_x_{{ t_n_url }}_" />
99
<input name="t_y[{{ t_n_url }}]" type="hidden" id="t_y_{{ t_n_url }}_" />
1010
<input name="t_v[{{ t_n_url }}]" type="hidden" id="t_v_{{ t_n_url }}_" />
1111
<input name="t_h[{{ t_n_url }}]" type="hidden" id="t_h_{{ t_n_url }}_" />
1212
<table id="{{ t_n_url }}"
13-
db_url="{{ designerTable.getDatabaseName()|escape('url') }}"
14-
table_name_url="{{ designerTable.getTableName()|escape('url') }}"
13+
db_url="{{ designerTable.databaseName|escape('url') }}"
14+
table_name_url="{{ designerTable.tableName|escape('url') }}"
1515
cellpadding="0"
1616
cellspacing="0"
1717
class="table table-sm table-striped table-hover w-auto designer_tab"
@@ -38,19 +38,19 @@
3838
id="id_hide_tbody_{{ t_n_url }}"
3939
table_name="{{ t_n_url }}">{{ tab_pos[t_n] is not defined or tab_pos[t_n]['V'] is not empty ? 'v' : '&gt;' }}</td>
4040
<td class="small_tab_pref small_tab_pref_1"
41-
db="{{ designerTable.getDatabaseName() }}"
42-
db_url="{{ designerTable.getDatabaseName()|escape('url') }}"
43-
table_name="{{ designerTable.getTableName() }}"
44-
table_name_url="{{ designerTable.getTableName()|escape('url') }}">
41+
db="{{ designerTable.databaseName }}"
42+
db_url="{{ designerTable.databaseName|escape('url') }}"
43+
table_name="{{ designerTable.tableName }}"
44+
table_name_url="{{ designerTable.tableName|escape('url') }}">
4545
<img src="{{ image('designer/exec_small.png') }}"
4646
title="{{ t('See table structure') }}">
4747
</td>
4848
<td id="id_zag_{{ t_n_url }}"
4949
class="tab_zag text-nowrap tab_zag_noquery"
5050
table_name="{{ t_n_url }}"
5151
query_set="{{ has_query ? 1 : 0 }}">
52-
<span class="owner">{{ designerTable.getDatabaseName() }}</span>
53-
{{ designerTable.getTableName() }}
52+
<span class="owner">{{ designerTable.databaseName }}</span>
53+
{{ designerTable.tableName }}
5454
</td>
5555
{% if has_query %}
5656
<td class="tab_zag tab_zag_query"
@@ -62,12 +62,12 @@
6262
</thead>
6363
<tbody id="id_tbody_{{ t_n_url }}"
6464
{{- tab_pos[t_n] is defined and tab_pos[t_n]['V'] is empty ? ' style="display: none"' }}>
65-
{% set display_field = designerTable.getDisplayField() %}
65+
{% set display_field = designerTable.displayField %}
6666
{% for j in 0..tab_column[t_n]|length - 1 %}
6767
{% set col_name = tab_column[t_n][j].name %}
6868
{% set tmp_column = t_n ~ '.' ~ tab_column[t_n][j].name %}
6969
{% set click_field_param = [
70-
designerTable.getTableName()|escape('url'),
70+
designerTable.tableName|escape('url'),
7171
tab_column[t_n][j].name|url_encode
7272
] %}
7373
{% if tables_all_keys[tmp_column] is defined %}
@@ -80,7 +80,7 @@
8080
{% endif %}
8181
{% endif %}
8282
{% set click_field_param = click_field_param|merge([db]) %}
83-
<tr id="id_tr_{{ designerTable.getTableName()|escape('url') }}.{{ tab_column[t_n][j].name }}" class="tab_field
83+
<tr id="id_tr_{{ designerTable.tableName|escape('url') }}.{{ tab_column[t_n][j].name }}" class="tab_field
8484
{{- display_field == tab_column[t_n][j].name ? '_3' }}" click_field_param="
8585
{{- click_field_param|join(',') }}">
8686
{% if has_query %}

‎src/Database/Designer.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,11 @@ public function getDesignerConfig(
245245

246246
$displayedFields = [];
247247
foreach ($designerTables as $designerTable) {
248-
if ($designerTable->getDisplayField() === null) {
248+
if ($designerTable->displayField === null) {
249249
continue;
250250
}
251251

252-
$displayedFields[$designerTable->getTableName()] = $designerTable->getDisplayField();
252+
$displayedFields[$designerTable->tableName] = $designerTable->displayField;
253253
}
254254

255255
$designerConfig = new stdClass();

‎src/Database/Designer/Common.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ public function getColumnsInfo(array $designerTables): array
8787
$fieldsRs = $this->dbi->query(
8888
QueryGenerator::getColumnNamesAndTypes(
8989
Util::getCollateForIS($this->dbi),
90-
$this->dbi->quoteString($designerTable->getDatabaseName()),
91-
$this->dbi->quoteString($designerTable->getTableName()),
90+
$this->dbi->quoteString($designerTable->databaseName),
91+
$this->dbi->quoteString($designerTable->tableName),
9292
),
9393
);
9494
/**
@@ -180,12 +180,12 @@ public function getAllKeys(array $designerTables): array
180180
$keys = [];
181181

182182
foreach ($designerTables as $designerTable) {
183-
$schema = $designerTable->getDatabaseName();
183+
$schema = $designerTable->databaseName;
184184
// for now, take into account only the first index segment
185-
foreach (Index::getFromTable($this->dbi, $designerTable->getTableName(), $schema) as $index) {
185+
foreach (Index::getFromTable($this->dbi, $designerTable->tableName, $schema) as $index) {
186186
$columns = $index->getColumns();
187187
foreach (array_keys($columns) as $columnName) {
188-
$key = $schema . '.' . $designerTable->getTableName() . '.' . $columnName;
188+
$key = $schema . '.' . $designerTable->tableName . '.' . $columnName;
189189
$keys[$key] = ! $index->getNonUnique();
190190
}
191191
}

‎src/Database/Designer/DesignerTable.php‎

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,67 +6,27 @@
66

77
use PhpMyAdmin\Utils\ForeignKey;
88

9-
/**
10-
* Common functions for Designer
11-
*/
12-
class DesignerTable
9+
readonly class DesignerTable
1310
{
1411
/**
15-
* Create a new DesignerTable
16-
*
1712
* @param string $databaseName The database name
1813
* @param string $tableName The table name
1914
* @param string $tableEngine The table engine
2015
* @param string|null $displayField The display field if available
2116
*/
2217
public function __construct(
23-
private string $databaseName,
24-
private string $tableName,
18+
public string $databaseName,
19+
public string $tableName,
2520
private string $tableEngine,
26-
private string|null $displayField,
21+
public string|null $displayField,
2722
) {
2823
}
2924

30-
/**
31-
* The table engine supports or not foreign keys
32-
*/
3325
public function supportsForeignkeys(): bool
3426
{
3527
return ForeignKey::isSupported($this->tableEngine);
3628
}
3729

38-
/**
39-
* Get the database name
40-
*/
41-
public function getDatabaseName(): string
42-
{
43-
return $this->databaseName;
44-
}
45-
46-
/**
47-
* Get the table name
48-
*/
49-
public function getTableName(): string
50-
{
51-
return $this->tableName;
52-
}
53-
54-
/**
55-
* Get the table engine
56-
*/
57-
public function getTableEngine(): string
58-
{
59-
return $this->tableEngine;
60-
}
61-
62-
/**
63-
* Get the displayed field
64-
*/
65-
public function getDisplayField(): string|null
66-
{
67-
return $this->displayField;
68-
}
69-
7030
/**
7131
* Get the db and table separated with a dot
7232
*/

‎src/Plugins/Schema/ExportRelationSchema.php‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,6 @@ public function setOffline(bool $value): void
191191
$this->offline = $value;
192192
}
193193

194-
/**
195-
* Returns whether the client side database is used
196-
*/
197-
public function isOffline(): bool
198-
{
199-
return $this->offline;
200-
}
201-
202194
/**
203195
* Get the table names from the request
204196
*

‎src/Plugins/Schema/Pdf/PdfRelationSchema.php‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,6 @@ public function setWithDataDictionary(bool $value): void
255255
$this->withDoc = $value;
256256
}
257257

258-
/**
259-
* Return whether to show selected database data dictionary or not
260-
*/
261-
public function isWithDataDictionary(): bool
262-
{
263-
return $this->withDoc;
264-
}
265-
266258
/**
267259
* Sets the order of the table in data dictionary
268260
*

‎src/Server/Plugin.php‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ public function toArray(): array
8484
];
8585
}
8686

87-
public function getName(): string
88-
{
89-
return $this->name;
90-
}
91-
9287
public function getVersion(): string|null
9388
{
9489
return $this->version;

‎tests/unit/Server/PluginTest.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public function testFromState(): Plugin
3030
'authVersion' => '1.0',
3131
]);
3232

33-
self::assertSame('BLACKHOLE', $plugin->getName());
3433
self::assertSame('1.0', $plugin->getVersion());
3534
self::assertSame('ACTIVE', $plugin->getStatus());
3635
self::assertSame('STORAGE ENGINE', $plugin->getType());

0 commit comments

Comments
 (0)