From cd3e481642f281974ca7a894be4ae3d8d8e49c25 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 20 Sep 2024 19:14:09 +0100 Subject: [PATCH] Remove getRelationsAndStatus Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 12 +----------- src/ConfigStorage/Relation.php | 19 ------------------- .../Database/DataDictionaryController.php | 8 +++----- src/Plugins/Export/ExportHtmlword.php | 8 +++----- src/Plugins/Export/ExportLatex.php | 8 +++----- src/Plugins/Export/ExportOdt.php | 8 +++----- src/Plugins/Export/ExportSql.php | 8 +++----- src/Plugins/Export/ExportTexytext.php | 8 +++----- 8 files changed, 19 insertions(+), 60 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 36a461ee02..55b6d68f51 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -9822,7 +9822,7 @@ parameters: - message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" - count: 2 + count: 1 path: src/Plugins/Export/ExportSql.php - @@ -9850,16 +9850,6 @@ parameters: count: 2 path: src/Plugins/Export/ExportSql.php - - - message: "#^Cannot access offset 'foreign_field' on mixed\\.$#" - count: 1 - path: src/Plugins/Export/ExportSql.php - - - - message: "#^Cannot access offset 'foreign_table' on mixed\\.$#" - count: 1 - path: src/Plugins/Export/ExportSql.php - - message: "#^Cannot access offset 'index_list' on mixed\\.$#" count: 1 diff --git a/src/ConfigStorage/Relation.php b/src/ConfigStorage/Relation.php index 4aa6071f2b..2fd6e05901 100644 --- a/src/ConfigStorage/Relation.php +++ b/src/ConfigStorage/Relation.php @@ -1532,25 +1532,6 @@ class Relation $this->getRelationParameters(); } - /** - * Gets the relations info and status, depending on the condition - * - * @param bool $condition whether to look for foreigners or not - * @param string $db database name - * @param string $table table name - * - * @return mixed[] - */ - public function getRelationsAndStatus(bool $condition, string $db, string $table): array - { - if ($condition) { - // Find which tables are related with the current one and write it in an array - return $this->getForeigners($db, $table); - } - - return []; - } - /** * Verifies that all pmadb features are disabled */ diff --git a/src/Controllers/Database/DataDictionaryController.php b/src/Controllers/Database/DataDictionaryController.php index 18a8e6524a..c8cfad3ffd 100644 --- a/src/Controllers/Database/DataDictionaryController.php +++ b/src/Controllers/Database/DataDictionaryController.php @@ -50,11 +50,9 @@ final class DataDictionaryController implements InvocableController $this->dbi->getTableIndexes(Current::$database, $tableName), ); - $foreigners = $this->relation->getRelationsAndStatus( - $relationParameters->relationFeature !== null, - Current::$database, - $tableName, - ); + $foreigners = $relationParameters->relationFeature !== null + ? $this->relation->getForeigners(Current::$database, $tableName) + : []; $columnsComments = $this->relation->getComments(Current::$database, $tableName); diff --git a/src/Plugins/Export/ExportHtmlword.php b/src/Plugins/Export/ExportHtmlword.php index 1005e7bf45..f04b50e6a4 100644 --- a/src/Plugins/Export/ExportHtmlword.php +++ b/src/Plugins/Export/ExportHtmlword.php @@ -336,11 +336,9 @@ class ExportHtmlword extends ExportPlugin $dbi->selectDb($db); // Check if we can use Relations - $foreigners = $this->relation->getRelationsAndStatus( - $doRelation && $relationParameters->relationFeature !== null, - $db, - $table, - ); + $foreigners = $doRelation && $relationParameters->relationFeature !== null + ? $this->relation->getForeigners($db, $table) + : []; /** * Displays the table structure diff --git a/src/Plugins/Export/ExportLatex.php b/src/Plugins/Export/ExportLatex.php index e0a1525ca8..5ad445936b 100644 --- a/src/Plugins/Export/ExportLatex.php +++ b/src/Plugins/Export/ExportLatex.php @@ -473,11 +473,9 @@ class ExportLatex extends ExportPlugin $dbi->selectDb($db); // Check if we can use Relations - $foreigners = $this->relation->getRelationsAndStatus( - $doRelation && $relationParameters->relationFeature !== null, - $db, - $table, - ); + $foreigners = $doRelation && $relationParameters->relationFeature !== null ? + $this->relation->getForeigners($db, $table) + : []; /** * Displays the table structure */ diff --git a/src/Plugins/Export/ExportOdt.php b/src/Plugins/Export/ExportOdt.php index 0171e511f3..55451a7bd0 100644 --- a/src/Plugins/Export/ExportOdt.php +++ b/src/Plugins/Export/ExportOdt.php @@ -423,11 +423,9 @@ class ExportOdt extends ExportPlugin $dbi->selectDb($db); // Check if we can use Relations - $foreigners = $this->relation->getRelationsAndStatus( - $doRelation && $relationParameters->relationFeature !== null, - $db, - $table, - ); + $foreigners = $doRelation && $relationParameters->relationFeature !== null ? + $this->relation->getForeigners($db, $table) + : []; /** * Displays the table structure */ diff --git a/src/Plugins/Export/ExportSql.php b/src/Plugins/Export/ExportSql.php index 727839ebb2..96a30a498e 100644 --- a/src/Plugins/Export/ExportSql.php +++ b/src/Plugins/Export/ExportSql.php @@ -1747,11 +1747,9 @@ class ExportSql extends ExportPlugin $schemaCreate = ''; // Check if we can use Relations - $foreigners = $this->relation->getRelationsAndStatus( - $doRelation && $relationParameters->relationFeature !== null, - $db, - $table, - ); + $foreigners = $doRelation && $relationParameters->relationFeature !== null ? + $this->relation->getForeigners($db, $table) + : []; $mimeMap = null; if ($doMime && $relationParameters->browserTransformationFeature !== null) { diff --git a/src/Plugins/Export/ExportTexytext.php b/src/Plugins/Export/ExportTexytext.php index 332d2dc189..8dd696e790 100644 --- a/src/Plugins/Export/ExportTexytext.php +++ b/src/Plugins/Export/ExportTexytext.php @@ -352,11 +352,9 @@ class ExportTexytext extends ExportPlugin $dbi->selectDb($db); // Check if we can use Relations - $foreigners = $this->relation->getRelationsAndStatus( - $doRelation && $relationParameters->relationFeature !== null, - $db, - $table, - ); + $foreigners = $doRelation && $relationParameters->relationFeature !== null ? + $this->relation->getForeigners($db, $table) + : []; /** * Displays the table structure