diff --git a/libraries/classes/ConfigStorage/Relation.php b/libraries/classes/ConfigStorage/Relation.php index bf96fecba5..f86e988b22 100644 --- a/libraries/classes/ConfigStorage/Relation.php +++ b/libraries/classes/ConfigStorage/Relation.php @@ -477,9 +477,9 @@ class Relation * @param string $db the name of the db to check for * @param string $table the name of the table to check for * - * @return string|false field name or false + * @return string field name */ - public function getDisplayField(string $db, string $table): string|false + public function getDisplayField(string $db, string $table): string { $displayFeature = $this->getRelationParameters()->displayFeature; @@ -522,7 +522,7 @@ class Relation } } - return false; + return ''; } /** @@ -1028,7 +1028,7 @@ class Relation $fQueryMain = 'SELECT ' . Util::backquote($foreignField) . ( - $foreignDisplay === false + $foreignDisplay === '' ? '' : ', ' . Util::backquote($foreignDisplay) ); @@ -1040,14 +1040,14 @@ class Relation '%' . $this->dbi->escapeMysqlWildcards($foreignFilter) . '%', ) . ( - $foreignDisplay === false + $foreignDisplay === '' ? '' : ' OR ' . Util::backquote($foreignDisplay) . ' LIKE ' . $this->dbi->quoteString( '%' . $this->dbi->escapeMysqlWildcards($foreignFilter) . '%', ) ); - $fQueryOrder = $foreignDisplay === false ? '' : ' ORDER BY ' + $fQueryOrder = $foreignDisplay === '' ? '' : ' ORDER BY ' . Util::backquote($foreignTable) . '.' . Util::backquote($foreignDisplay); diff --git a/libraries/classes/Database/Designer/Common.php b/libraries/classes/Database/Designer/Common.php index 4c84ee03b8..384a6d37ad 100644 --- a/libraries/classes/Database/Designer/Common.php +++ b/libraries/classes/Database/Designer/Common.php @@ -58,7 +58,6 @@ class Common foreach ($tables as $oneTable) { $df = $this->relation->getDisplayField($db, $oneTable['TABLE_NAME']); - $df = is_string($df) ? $df : ''; $df = $df !== '' ? $df : null; $designerTables[] = new DesignerTable( $db, diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php index 80b440b3f4..773e0f0efb 100644 --- a/libraries/classes/Display/Results.php +++ b/libraries/classes/Display/Results.php @@ -4119,14 +4119,14 @@ class Results } if (isset($map[$meta->name])) { - /** @var array{0: string, 1: string, 2: string|false, 3: string} $relation */ + /** @var array{0: string, 1: string, 2: string, 3: string} $relation */ $relation = $map[$meta->name]; // Field to display from the foreign table? $dispval = ''; // Check that we have a valid column name // Relation::getDisplayField() returns false by default - if ($relation[2] !== '' && $relation[2] !== false) { + if ($relation[2] !== '') { $dispval = $this->getFromForeign($relation, $whereComparison); } @@ -4158,7 +4158,7 @@ class Results // always apply a transformation on the real data, // not on the display field $displayedData = $transformationPlugin->applyTransformation($data, $transformOptions, $meta); - } elseif ($relationalDisplay === self::RELATIONAL_DISPLAY_COLUMN && $relation[2]) { + } elseif ($relationalDisplay === self::RELATIONAL_DISPLAY_COLUMN && $relation[2] !== '') { // user chose "relational display field" in the // display options, so show display field in the cell $displayedData = $dispval === null ? 'NULL' : Core::mimeDefaultFunction($dispval); diff --git a/libraries/classes/InsertEdit.php b/libraries/classes/InsertEdit.php index d86c1d40c9..dd903e0a3b 100644 --- a/libraries/classes/InsertEdit.php +++ b/libraries/classes/InsertEdit.php @@ -1102,7 +1102,7 @@ class InsertEdit $displayField = $this->relation->getDisplayField($foreigner['foreign_db'], $foreigner['foreign_table']); // Field to display from the foreign table? - if (is_string($displayField) && $displayField !== '') { + if ($displayField !== '') { $dispsql = 'SELECT ' . Util::backquote($displayField) . ' FROM ' . Util::backquote($foreigner['foreign_db']) . '.' . Util::backquote($foreigner['foreign_table']) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c13c6780cf..00fbb3e793 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -656,7 +656,7 @@ parameters: path: libraries/classes/ConfigStorage/Relation.php - - message: "#^Method PhpMyAdmin\\\\ConfigStorage\\\\Relation\\:\\:getDisplayField\\(\\) should return string\\|false but returns mixed\\.$#" + message: "#^Method PhpMyAdmin\\\\ConfigStorage\\\\Relation\\:\\:getDisplayField\\(\\) should return string but returns mixed\\.$#" count: 1 path: libraries/classes/ConfigStorage/Relation.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 62cba2b2b3..3469b0df9a 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -778,7 +778,7 @@ array|false - string|false + string diff --git a/test/classes/ConfigStorage/RelationTest.php b/test/classes/ConfigStorage/RelationTest.php index f516897750..4f4f7fa3d0 100644 --- a/test/classes/ConfigStorage/RelationTest.php +++ b/test/classes/ConfigStorage/RelationTest.php @@ -52,7 +52,8 @@ class RelationTest extends AbstractTestCase $db = 'information_schema'; $table = 'PMA'; - $this->assertFalse( + $this->assertSame( + '', $relation->getDisplayField($db, $table), ); }