diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 73ae547596..b4b7eec579 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1775,11 +1775,6 @@ parameters: count: 1 path: src/Controllers/Database/DesignerController.php - - - message: "#^Cannot access offset 'name' on mixed\\.$#" - count: 1 - path: src/Controllers/Database/EventsController.php - - message: "#^Cannot call method isSuccess\\(\\) on mixed\\.$#" count: 1 @@ -1787,7 +1782,7 @@ parameters: - message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" - count: 18 + count: 16 path: src/Controllers/Database/EventsController.php - @@ -1797,7 +1792,7 @@ parameters: - message: "#^Parameter \\#1 \\$identifier of static method PhpMyAdmin\\\\Util\\:\\:backquote\\(\\) expects string\\|Stringable\\|null, mixed given\\.$#" - count: 3 + count: 2 path: src/Controllers/Database/EventsController.php - @@ -6935,21 +6930,6 @@ parameters: count: 6 path: src/Database/Events.php - - - message: "#^Cannot access offset 'Name' on mixed\\.$#" - count: 1 - path: src/Database/Events.php - - - - message: "#^Cannot access offset 'Status' on mixed\\.$#" - count: 1 - path: src/Database/Events.php - - - - message: "#^Cannot access offset 'Type' on mixed\\.$#" - count: 1 - path: src/Database/Events.php - - message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" count: 13 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index c420b39355..eb2a12f1c1 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1024,16 +1024,9 @@ - - - - - - - $event @@ -4778,11 +4771,6 @@ - - - - - @@ -4796,7 +4784,6 @@ - $event diff --git a/src/Controllers/Database/EventsController.php b/src/Controllers/Database/EventsController.php index 2818fd01ef..699cb669e0 100644 --- a/src/Controllers/Database/EventsController.php +++ b/src/Controllers/Database/EventsController.php @@ -86,25 +86,23 @@ final class EventsController extends AbstractController mb_strtoupper($_POST['item_name']), ), ); - if (! empty($event)) { - $sqlDrop = sprintf( - 'DROP EVENT IF EXISTS %s', - Util::backquote($event['name']), - ); - $this->response->addJSON( - 'new_row', - $this->template->render('database/events/row', [ - 'db' => Current::$database, - 'table' => Current::$table, - 'event' => $event, - 'has_privilege' => Util::currentUserHasPrivilege('EVENT', Current::$database), - 'sql_drop' => $sqlDrop, - 'row_class' => '', - ]), - ); - } + $sqlDrop = sprintf( + 'DROP EVENT IF EXISTS %s', + Util::backquote($event['name']), + ); + $this->response->addJSON( + 'new_row', + $this->template->render('database/events/row', [ + 'db' => Current::$database, + 'table' => Current::$table, + 'event' => $event, + 'has_privilege' => Util::currentUserHasPrivilege('EVENT', Current::$database), + 'sql_drop' => $sqlDrop, + 'row_class' => '', + ]), + ); - $this->response->addJSON('insert', ! empty($event)); + $this->response->addJSON('insert', true); $this->response->addJSON('message', $output); } else { $this->response->setRequestStatus(false); diff --git a/src/Database/Events.php b/src/Database/Events.php index f4fe185497..1d39dd83e3 100644 --- a/src/Database/Events.php +++ b/src/Database/Events.php @@ -362,7 +362,7 @@ class Events * @param string $db db name * @param string $name event name * - * @return mixed[] information about EVENTs + * @return array{name:string, type:string, status:string}[] information about EVENTs */ public function getDetails(string $db, string $name = ''): array { @@ -381,6 +381,7 @@ class Events $result = []; $events = $this->dbi->fetchResult($query); + /** @var string[] $event */ foreach ($events as $event) { $result[] = ['name' => $event['Name'], 'type' => $event['Type'], 'status' => $event['Status']]; }