From 0bb63c997f7ec90fba6cd70c04ba64f4307c6d55 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Wed, 19 Apr 2023 22:57:47 +0100 Subject: [PATCH] Remove getWhereClauseArray() This weird array cast is not adding anything useful. The psalm type hint tells us that elements are strings, but that's not guaranteed in any way. Signed-off-by: Kamil Tekiela --- libraries/classes/InsertEdit.php | 22 +------------------ psalm-baseline.xml | 3 +-- test/classes/InsertEditTest.php | 36 -------------------------------- 3 files changed, 2 insertions(+), 59 deletions(-) diff --git a/libraries/classes/InsertEdit.php b/libraries/classes/InsertEdit.php index 8572a97fbe..5db59c5166 100644 --- a/libraries/classes/InsertEdit.php +++ b/libraries/classes/InsertEdit.php @@ -132,26 +132,6 @@ class InsertEdit return $formParams; } - /** - * Creates array of where clauses - * - * @param string[]|string|null $whereClause where clause - * - * @return string[] whereClauseArray array of where clauses - */ - private function getWhereClauseArray(array|string|null $whereClause): array - { - if ($whereClause === null) { - return []; - } - - if (is_array($whereClause)) { - return $whereClause; - } - - return [$whereClause]; - } - /** * Analysing where clauses array * @@ -1757,7 +1737,7 @@ class InsertEdit if (isset($whereClause)) { // we are editing $insertMode = false; - $whereClauseArray = $this->getWhereClauseArray($whereClause); + $whereClauseArray = (array) $whereClause; [$whereClauses, $result, $rows, $foundUniqueKey] = $this->analyzeWhereClauses( $whereClauseArray, $table, diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 1371fb7330..d7995ad5a5 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -7981,7 +7981,6 @@ $whereClause $whereClause $whereClause - $whereClause @@ -7991,6 +7990,7 @@ $thisUrlParams $urlParams $valueSets + $whereClauseArray @@ -8093,7 +8093,6 @@ $whereClause - $whereClause diff --git a/test/classes/InsertEditTest.php b/test/classes/InsertEditTest.php index d167bae171..f1440aaa7e 100644 --- a/test/classes/InsertEditTest.php +++ b/test/classes/InsertEditTest.php @@ -181,42 +181,6 @@ class InsertEditTest extends AbstractTestCase ); } - /** - * Test for getWhereClauseArray - */ - public function testGetWhereClauseArray(): void - { - $this->assertEquals( - [], - $this->callFunction( - $this->insertEdit, - InsertEdit::class, - 'getWhereClauseArray', - [null], - ), - ); - - $this->assertEquals( - [1, 2, 3], - $this->callFunction( - $this->insertEdit, - InsertEdit::class, - 'getWhereClauseArray', - [[1, 2, 3]], - ), - ); - - $this->assertEquals( - ['clause'], - $this->callFunction( - $this->insertEdit, - InsertEdit::class, - 'getWhereClauseArray', - ['clause'], - ), - ); - } - /** * Test for analyzeWhereClauses */