Skip to content

Commit

Permalink
Use parameters instead of globals in sendEditor()
Browse files Browse the repository at this point in the history
The two globals in this method are read-only. There is an unused
parameter in the signature. Let's add one more and use them instead of globals.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
  • Loading branch information
kamil-tekiela committed Dec 1, 2021
1 parent eb97aa9 commit 51e05a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
7 changes: 3 additions & 4 deletions libraries/classes/Database/Triggers.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public function handleEditor(): void
$mode = 'edit';
}

$this->sendEditor($mode, $item, $title, $db);
$this->sendEditor($mode, $item, $title, $db, $table);
}

/**
Expand Down Expand Up @@ -449,11 +449,10 @@ private function checkResult($result, $createStatement, array $errors)
* @param array|null $item Data necessary to create the editor
* @param string $title Title of the editor
* @param string $db Database
* @param string $table Table
*/
private function sendEditor($mode, ?array $item, $title, $db): void
private function sendEditor($mode, ?array $item, $title, $db, $table): void
{
global $db, $table;

if ($item !== null) {
$editor = $this->getEditorForm($db, $table, $mode, $item);
if ($this->response->isAjax()) {
Expand Down
7 changes: 1 addition & 6 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5498,7 +5498,7 @@
</RedundantPropertyInitializationCheck>
</file>
<file src="libraries/classes/Database/Triggers.php">
<MixedArgument occurrences="33">
<MixedArgument occurrences="31">
<code>$_POST['item_definer']</code>
<code>$_POST['item_definer']</code>
<code>$_POST['item_name']</code>
Expand All @@ -5516,8 +5516,6 @@
<code>$db</code>
<code>$db</code>
<code>$db</code>
<code>$db</code>
<code>$db</code>
<code>$errors</code>
<code>$errors</code>
<code>$errors</code>
Expand Down Expand Up @@ -5602,9 +5600,6 @@
<code>$trigger['create']</code>
<code>$trigger['drop']</code>
</PossiblyNullArrayAccess>
<UnusedParam occurrences="1">
<code>$db</code>
</UnusedParam>
</file>
<file src="libraries/classes/DatabaseInterface.php">
<DocblockTypeContradiction occurrences="1">
Expand Down

0 comments on commit 51e05a5

Please sign in to comment.