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 <tekiela246@gmail.com>
This commit is contained in:
Kamil Tekiela 2023-04-19 22:57:47 +01:00
parent a2a35c19de
commit 0bb63c997f
3 changed files with 2 additions and 59 deletions

View File

@ -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,

View File

@ -7981,7 +7981,6 @@
<code>$whereClause</code>
<code>$whereClause</code>
<code>$whereClause</code>
<code>$whereClause</code>
<code><![CDATA[min(max($column['len'], 4), $GLOBALS['cfg']['LimitChars'])]]></code>
</MixedArgument>
<MixedArgumentTypeCoercion>
@ -7991,6 +7990,7 @@
<code>$thisUrlParams</code>
<code>$urlParams</code>
<code>$valueSets</code>
<code>$whereClauseArray</code>
</MixedArgumentTypeCoercion>
<MixedArrayAccess>
<code><![CDATA[$_SESSION['tmpval']['relational_display']]]></code>
@ -8093,7 +8093,6 @@
<code><![CDATA[$_GET['sql_query']]]></code>
<code><![CDATA[$_GET['sql_signature']]]></code>
<code>$whereClause</code>
<code>$whereClause</code>
</PossiblyInvalidArgument>
<PossiblyInvalidArrayOffset>
<code><![CDATA[$_POST['fields']['multi_edit']]]></code>

View File

@ -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
*/